• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

[General] BlzGetAbilityByIndex Failing to Return An Ability

Status
Not open for further replies.
Level 17
Joined
Oct 17, 2012
Messages
796
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