Skip to content

Commit

Permalink
Update LibRangeCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
brittyazel committed Aug 26, 2024
1 parent ebca09b commit c8f6cf8
Showing 1 changed file with 37 additions and 17 deletions.
54 changes: 37 additions & 17 deletions Libs/LibRangeCheck-3.0/LibRangeCheck-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ License: MIT
-- @class file
-- @name LibRangeCheck-3.0
local MAJOR_VERSION = "LibRangeCheck-3.0"
local MINOR_VERSION = 20
local MINOR_VERSION = 26

---@class lib
local lib, oldminor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
Expand Down Expand Up @@ -76,27 +76,25 @@ local UnitIsUnit = UnitIsUnit
local UnitGUID = UnitGUID
local UnitIsDeadOrGhost = UnitIsDeadOrGhost
local CheckInteractDistance = CheckInteractDistance
local IsSpellInRange = _G.IsSpellInRange or function(id, unit)
local result = C_Spell.IsSpellInRange(id, unit)
local IsSpellBookItemInRange = _G.IsSpellInRange or function(index, spellBank, unit)
local result = C_Spell.IsSpellInRange(index, unit)
if result == true then
return 1
elseif result == false then
return 0
end
return nil
end
local IsSpellBookItemInRange = _G.IsSpellInRange or function(index, spellBank, unit)
-- Deprecated_11_0_0.lua set BOOKTYPE_SPELL to "spell" but doesn't provide a compatibility wrapper for IsSpellBookItemInRange
local spellTypes = {"SPELL", "FUTURESPELL", "PETACTION", "FLYOUT"}
local GetSpellBookItemInfo = _G.GetSpellBookItemInfo or function(index, spellBank)
if type(spellBank) == "string" then
spellBank = (spellBank == "spell") and Enum.SpellBookSpellBank.Player or Enum.SpellBookSpellBank.Pet;
end
local result = C_SpellBook.IsSpellBookItemInRange(index, spellBank, unit)
if result == true then
return 1
elseif result == false then
return 0
local info = C_SpellBook.GetSpellBookItemInfo(index, spellBank)
--map spell-type
if info and spellTypes[info.itemType or 0] then
return spellTypes[info.itemType or 0] or "None", info.spellID, info
end
return nil
end
local UnitClass = UnitClass
local UnitRace = UnitRace
Expand Down Expand Up @@ -168,8 +166,9 @@ for _, n in ipairs({ "EVOKER", "DEATHKNIGHT", "DEMONHUNTER", "DRUID", "HUNTER",
end

-- Evoker
tinsert(HarmSpells.EVOKER, 369819) -- Disintegrate (25 yards)
tinsert(HarmSpells.EVOKER, 362969) -- Azure Strike (25 yards)

tinsert(FriendSpells.EVOKER, 355913) -- Emerald Blossom (25 yards)
tinsert(FriendSpells.EVOKER, 361469) -- Living Flame (25 yards)
tinsert(FriendSpells.EVOKER, 360823) -- Naturalize (Preservation) (30 yards)

Expand Down Expand Up @@ -273,6 +272,7 @@ tinsert(FriendSpells.PRIEST, 527) -- Purify / Dispel Magic (40 yards retail, 30
tinsert(FriendSpells.PRIEST, 2061) -- Flash Heal (40 yards, level 3 retail, level 20 tbc)

tinsert(HarmSpells.PRIEST, 589) -- Shadow Word: Pain (40 yards)
tinsert(HarmSpells.PRIEST, 8092) -- Mind Blast (40 yards)
tinsert(HarmSpells.PRIEST, 585) -- Smite (40 yards)
tinsert(HarmSpells.PRIEST, 5019) -- Shoot (30 yards)

Expand Down Expand Up @@ -308,6 +308,8 @@ if not isRetail then
end

tinsert(HarmSpells.SHAMAN, 370) -- Purge (30 yards)
tinsert(HarmSpells.SHAMAN, 8042) -- Earth Shock (40 yards)
tinsert(HarmSpells.SHAMAN, 117014) -- Elemental Blast (40 yards)
tinsert(HarmSpells.SHAMAN, 188196) -- Lightning Bolt (40 yards)
tinsert(HarmSpells.SHAMAN, 73899) -- Primal Strike (Melee Range)

Expand All @@ -328,9 +330,12 @@ if not isRetail then
end

-- Warlocks
tinsert(FriendSpells.WARLOCK, 132) -- Detect Invisibility (30 yards, level 26)
if isEra then
tinsert(FriendSpells.WARLOCK, 132) -- Detect Invisibility (30 yards, level 26)
else
tinsert(FriendSpells.WARLOCK, 20707) -- Soulstone (40 yards) ~ this can be precasted so leave it in friendly as well as res
end
tinsert(FriendSpells.WARLOCK, 5697) -- Unending Breath (30 yards)
tinsert(FriendSpells.WARLOCK, 20707) -- Soulstone (40 yards) ~ this can be precasted so leave it in friendly as well as res

if isRetail then
tinsert(HarmSpells.WARLOCK, 234153) -- Drain Life (40 yards, level 9)
Expand All @@ -342,14 +347,19 @@ else
tinsert(HarmSpells.WARLOCK, 17877) -- Shadowburn (Destruction) (20/22/24 yards, rank 1)
tinsert(HarmSpells.WARLOCK, 18223) -- Curse of Exhaustion (Affliction) (30/33/36/35/38/42 yards)
tinsert(HarmSpells.WARLOCK, 689) -- Drain Life (Affliction) (20/22/24 yards, level 14, rank 1)
end
if isEra then
tinsert(HarmSpells.WARLOCK, 403677) -- Master Channeler (Affliction) (20/22/24 yards, level 14, rank 1)
tinsert(HarmSpells.WARLOCK, 426320) -- Shadowflame (30/33/36/39/42 yards, level 14, rank 1)
end

tinsert(HarmSpells.WARLOCK, 5019) -- Shoot (30 yards)
tinsert(HarmSpells.WARLOCK, 686) -- Shadow Bolt (Demonology, Affliction) (40 yards)
tinsert(HarmSpells.WARLOCK, 5782) -- Fear (30 yards)

tinsert(ResSpells.WARLOCK, 20707) -- Soulstone (40 yards)
if not isEra then
tinsert(ResSpells.WARLOCK, 20707) -- Soulstone (40 yards)
end

tinsert(PetSpells.WARLOCK, 755) -- Health Funnel (45 yards)

Expand Down Expand Up @@ -635,6 +645,9 @@ end

local function getNumSpells()
local _, _, offset, numSpells = GetSpellTabInfo(GetNumSpellTabs())
if not offset or not numSpells then
return 0
end
return offset + numSpells
end

Expand All @@ -646,7 +659,14 @@ local function findSpellIdx(spellName)
for i = 1, getNumSpells() do
local spell = GetSpellBookItemName(i, BOOKTYPE_SPELL)
if spell == spellName then
return i
local spellType, spellID, spellInfo = GetSpellBookItemInfo(i, BOOKTYPE_SPELL)
if spellInfo then -- new API output available
if Enum.SpellBookItemType and spellInfo.itemType == Enum.SpellBookItemType.Spell and not spellInfo.isOffSpec then -- retail - filter for only active spec "SPELL"
return spellID
end
elseif spellType == "SPELL" then -- classic/era
return i
end
end
end
return nil
Expand All @@ -668,7 +688,7 @@ local function findMinRangeChecker(origMinRange, origRange, spellList, interactL
local sid = spellList[i]
local name, minRange, range, spellIdx = getSpellData(sid)
if range and spellIdx and origMinRange <= range and range <= origRange and minRange == 0 then
return checkers_Spell[findSpellIdx(name)]
return checkers_Spell[spellIdx]
end
end
for index, range in pairs(interactLists) do
Expand Down

0 comments on commit c8f6cf8

Please sign in to comment.