Skip to content

Commit

Permalink
Offspec spells won't work either. (#33)
Browse files Browse the repository at this point in the history
* Offspec spells won't work either.

This covers unlearned spells from off-specs which appear in the spellbook.
  • Loading branch information
cont1nuity authored Aug 22, 2024
1 parent cf92afa commit 5a653fb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions 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 = 24
local MINOR_VERSION = 25

---@class lib
local lib, oldminor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
Expand Down Expand Up @@ -85,14 +85,15 @@ local IsSpellBookItemInRange = _G.IsSpellInRange or function(index, spellBank, u
end
return nil
end
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 info = C_SpellBook.GetSpellBookItemInfo(index, spellBank)
-- we are looking for "Spell" here, as "FutureSpell" and passives are not working with C_Spell.IsSpellInRange
if info and not info.isPassive and info.itemType == Enum.SpellBookItemType.Spell then
return info.itemType, info.spellID
--map spell-type
if info and spellTypes[info.itemType or 0] then
return spellTypes[info.itemType or 0] or "None", info.spellID, info
end
end
local UnitClass = UnitClass
Expand Down Expand Up @@ -654,11 +655,13 @@ local function findSpellIdx(spellName)
for i = 1, getNumSpells() do
local spell = GetSpellBookItemName(i, BOOKTYPE_SPELL)
if spell == spellName then
local spellType, spellID = GetSpellBookItemInfo(i, BOOKTYPE_SPELL)
if spellType == "SPELL" then -- classic/era
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
elseif Enum.SpellBookItemType and spellType == Enum.SpellBookItemType.Spell then -- retail
return spellID
end
end
end
Expand Down

0 comments on commit 5a653fb

Please sign in to comment.