/trunk/Stuf_Range
## Interface: 50400 |
## Interface: 60000 |
## Title: Stuf_Range |
## Author: TotalPackage |
## Notes: Displays estimate distance using LibRangeCheck-2.0. |
--[[ |
Name: LibRangeCheck-2.0 |
Revision: $Revision: 136 $ |
Revision: $Revision: 149 $ |
Author(s): mitch0 |
Website: http://www.wowace.com/projects/librangecheck-2-0/ |
Description: A range checking library based on interact distances and spell ranges |
-- @class file |
-- @name LibRangeCheck-2.0 |
local MAJOR_VERSION = "LibRangeCheck-2.0" |
local MINOR_VERSION = tonumber(("$Revision: 136 $"):match("%d+")) + 100000 |
local MINOR_VERSION = tonumber(("$Revision: 149 $"):match("%d+")) + 100000 |
local lib, oldminor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION) |
if not lib then |
local checkers_Item = setmetatable({}, { |
__index = function(t, item) |
local func = function(unit) |
if IsItemInRange(item, unit) == 1 then |
return true |
end |
return IsItemInRange(item, unit) |
end |
t[item] = func |
return func |
-- return the spellIndex of the given spell by scanning the spellbook |
local function findSpellIdx(spellName) |
if not spellName or spellName == "" then |
return nil |
end |
for i = 1, getNumSpells() do |
local spell, rank = GetSpellBookItemName(i, BOOKTYPE_SPELL) |
if spell == spellName then return i end |
if spellList then |
for i = 1, #spellList do |
local sid = spellList[i] |
local name, _, _, _, _, _, _, minRange, range = GetSpellInfo(sid) |
local name, _, _, _, minRange, range = GetSpellInfo(sid) |
local spellIdx = findSpellIdx(name) |
if spellIdx and range then |
minRange = math.floor(minRange + 0.5) |
if type(spell) == 'number' then |
spell = GetSpellInfo(spell) |
end |
if not spell then return nil end |
return findSpellIdx(spell) |
end |
local item = items[i] |
if GetItemInfo(item) then |
minRangeCheck = function(unit) |
return (IsItemInRange(item, unit) == 1) |
return IsItemInRange(item, unit) |
end |
break |
end |