WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Is C_AlliedRaces.GetAllRacialAbilitiesFromID bugged? (https://www.wowinterface.com/forums/showthread.php?t=58253)

Rilgamon 10-05-20 05:01 AM

Is C_AlliedRaces.GetAllRacialAbilitiesFromID bugged?
 
C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)

Is it just me or does this function return nil on live and wrong/old spellname (racial name for humans was changed) on beta? I dont have a allied race yet to test. Perhaps on live it works only for allied races?

For Clickzz I try to build a spell list you can bind your clicks to. Since some spells from general tab in spellbook are usefull in combat, too I thought to use this function to identify the racial spell with this.

As a temporary fix I use the icon to check. But thats a little bit too hacky ;)

Lua Code:
  1. local racialSpells = {} -- Beta returns the old names with C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)
  2. local function isRacialSpell(spellIcon) -- Replace spellIcon with spellName once the bug is fixed
  3. --  local name, rank, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(spellName)
  4. --  print('start',spellIcon)
  5.     for k, v in pairs(racialSpells) do
  6. --      local nameR, rankR, iconR, castTimeR, minRangeR, maxRangeR, spellIdR = GetSpellInfo(v)
  7. --      print(' check',v)
  8.         if(v == spellIcon) then
  9.             return true
  10.         end
  11.     end
  12. end
  13. local function buildRacialSpells()
  14.     local raceName, raceFile, raceID = UnitRace('player')
  15.     local res = C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)
  16.     if(res) then
  17.         for k, v in pairs(C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)) do
  18.             if(type(v)=='table') then
  19.                 if(not IsPassiveSpell(v['name']) and not isRacialSpell(v['icon'])) then -- Replace icon with name once the bug is fixed
  20.                     racialSpells[#racialSpells+1] = v['icon'] -- Replace icon with name once the bug is fixed
  21.                 end
  22.             end
  23.         end
  24.     end
  25. end
  26. local function buildSpells(self)
  27.     if(InCombatLockdown()) then
  28.         self:RegisterEvent("PLAYER_REGEN_ENABLED")
  29.         return
  30.     end
  31.     local currentSpec = GetSpecialization()
  32.     if currentSpec then
  33.         local classInfo = C_CreatureInfo.GetClassInfo(select(3,UnitClass('player')))
  34.         buildRacialSpells()
  35.         local _, currentSpecName = GetSpecializationInfo(currentSpec)
  36.         db['spells'] = {}
  37.         for tabIndex = 1, GetNumSpellTabs() do
  38.             local name, texture, offset, numEntries, isGuild, offspecID = GetSpellTabInfo(tabIndex)
  39.             if(name == currentSpecName or name == classInfo['className'] or tabIndex==1) then
  40.                 if(offspecID==0) then
  41.                     for spellIndex = offset + 1, offset + numEntries do
  42.                         local skillType, special = GetSpellBookItemInfo(spellIndex, BOOKTYPE_SPELL)
  43.                         if(skillType=="SPELL" and not IsPassiveSpell(spellIndex, BOOKTYPE_SPELL)) then
  44.                             local spellName, spellSubName = GetSpellBookItemName(spellIndex, BOOKTYPE_SPELL)
  45. --                          print(spellName,spellSubName,IsPassiveSpell(spellIndex, BOOKTYPE_SPELL), raceSpell)
  46.                             local _, _, icon = GetSpellInfo(spellName)
  47.                             if(not IsAttackSpell(spellName)) then
  48.                                 if(spellSubName and spellSubName ~= "" and not isRacialSpell(icon)) then
  49. --                                  db['spells'][special] = format("%s (%s)",spellName, spellSubName)
  50.                                     db['spells'][special] = spellName -- Fix when C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID) returns a value
  51.                                 else
  52.                                     db['spells'][special] = spellName
  53.                                 end
  54.                             end
  55.                         end
  56.                     end
  57.                 end
  58.             end
  59.         end
  60.     end
  61. end


All times are GMT -6. The time now is 08:00 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI