• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] use BlzGetUnitAbility

Level 7
Joined
Sep 19, 2020
Messages
190
hi
I try to use BlzGetUnitAbility
but I get an error
Which version of wc3 support it I use 1.26

JASS:
function Slash_Condition takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
function Slash_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local location start_position = GetUnitLoc(caster)
    local group enemies = CreateGroup()
    local unit temp
    local integer count = 5
    local location temp_loc
    local location effect_loc
    local effect blink_effect
    local ability ab = BlzGetUnitAbility(GetTriggerUnit(),'A000')
    call GroupEnumUnitsInRangeOfLoc(enemies,start_position,500.,null)
    loop
        set temp = FirstOfGroup(enemies)
        exitwhen temp == null or count == 0
        
        if IsUnitEnemy(temp,GetOwningPlayer(caster)) and IsUnitAliveBJ(temp) then
            set temp_loc = GetUnitLoc(temp)
            set effect_loc = GetUnitLoc(temp)
            set blink_effect = AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl",effect_loc)
            call SetUnitPositionLoc(caster,temp_loc)
            call UnitDamageTarget(caster,temp,150,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,null)
            set count = count - 1
            if IsUnitDeadBJ(temp) then
                BlzSetAbilityRealField(ab,ABILITY_RLF_COOLDOWN,1.0)
            endif
            call RemoveLocation(temp_loc)
            call RemoveLocation(effect_loc)
            call DestroyEffect(blink_effect)
        endif
        
        call GroupRemoveUnit(enemies,temp)
        
    endloop
    call SetUnitPositionLoc(caster,start_position)
    call RemoveLocation(start_position)
    call DestroyGroup(enemies)
    set caster = null
    set start_position = null
    set enemies = null
    set temp = null
    set temp_loc = null
    set effect_loc = null
    set blink_effect = null
endfunction
function InitTrig_Slash takes nothing returns nothing
 set gg_trg_Slash = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Slash, Condition(function Slash_Condition))
    call TriggerAddAction(gg_trg_Slash, function Slash_Actions)
endfunction
 
Top