• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] BlzGetAbilityByIndex Failing to Return An Ability

Status
Not open for further replies.
Level 19
Joined
Oct 17, 2012
Messages
860
Is it just me or is this native not working on the latest patch?

I have attempted to display the name of the ability by first using the new native, BlzGetAbilityId, to get the rawcode of the ability. All I am getting, however, is four dots, which indicate no ability exists. I also tried several indexes to be sure and made sure that the unit had abilities.
 
I just updated to patch 1.33.0.19308 on my PC and then tried this native in a tiny trigger in a test map. I looped the indices of the unit and printed the ability names for this priest:

1663217290862.png



My trigger was hacked together in the editor and is very lazy, just looping the abilities and printing their object names using the new native you mentioned:

vJASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i = 0
local ability a = null

loop
    set a = BlzGetUnitAbilityByIndex(u, i)
    exitwhen (a == null)
    call BJDebugMsg(I2S(i) + ": " + GetObjectName(BlzGetAbilityId(a)))
    set i = i + 1
endloop
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Untitled_Trigger_001, gg_rct_Region_000 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

Does this work for you? (You might need to change the region that fired my trigger to a region from your map.) If not, are you using a different language localization?


---
Edit: If I use the Patch 1.32 natives instead of the new Patch 1.33 native, and so I print the instanced name instead of the map-wide ability type's name from the object editor, the instanced versions worked for me as well using the following code (really only the print line changed):

vJASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i = 0
local ability a = null

loop
    set a = BlzGetUnitAbilityByIndex(u, i)
    exitwhen (a == null)
    call BJDebugMsg(I2S(i) + ": " + BlzGetAbilityStringField(a, ABILITY_SF_NAME))
    set i = i + 1
endloop
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Untitled_Trigger_001, gg_rct_Region_000 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
 
Status
Not open for further replies.
Top