• 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.

Ability causes crashes in my map

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,928
I made an ability called "Command" that when the hero damages a unit it gives an aura that increase %5 damage with each attack and desapear after 10 seconds of not attacking.
To do that I have a base ability and a ability to the aura (I use the trick of puting Y position -11, because I'm using 1.26) and add it that ability when is the first charge and remove it when there are not more charges, but for some reason when the hero dies with at least 1 charge the game crashes I think when passes the 10 seconds, but I wanna know if there is an special reason to that, I know the problem is related to the Aura ability because the ID apeared in the crashlog, here is the spell:
vJASS:
//'A08F' Base ability
//'A07W' Damage aura

function Trig_Command_Hero_Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(udg_DamageEventSource,'A08F')>0
endfunction

function Trig_Command_Hero_Actions2 takes nothing returns nothing
    local integer i=GetTimerData(GetExpiredTimer())
    if udg_Command_descarga[i]>0 then
        set udg_Command_descarga[i]=udg_Command_descarga[i]-1
    else
        if GetUnitAbilityLevel(udg_UDexUnits[i],'A07W')>1 then
            call DecUnitAbilityLevel(udg_UDexUnits[i],'A07W')
        else
            call UnitRemoveAbility(udg_UDexUnits[i],'A07W')
            call ReleaseTimer(GetExpiredTimer())
        endif
    endif
endfunction

function Trig_Command_Hero_Actions takes nothing returns nothing
    local integer i=GetUnitUserData(udg_DamageEventSource)
    set udg_Command_descarga[i]=10
    if GetUnitAbilityLevel(udg_DamageEventSource,'A07W')==0 then
        call UnitAddAbility(udg_DamageEventSource,'A07W')
        call TimerStart(NewTimerEx(i),1.00,true,function Trig_Command_Hero_Actions2)
    else
        if GetUnitAbilityLevel(udg_DamageEventSource,'A07W')<4*GetUnitAbilityLevel(udg_DamageEventSource,'A08F') then
            call IncUnitAbilityLevel(udg_DamageEventSource,'A07W')
        endif
    endif
endfunction

//===========================================================================
function InitTrig_Command_Hero takes nothing returns nothing
    set gg_trg_Command_Hero=CreateTrigger()
    call TriggerRegisterVariableEvent(gg_trg_Command_Hero,"udg_DamageEvent",EQUAL,1.00)
    call TriggerAddCondition(gg_trg_Command_Hero,Condition(function Trig_Command_Hero_Conditions))
    call TriggerAddAction(gg_trg_Command_Hero,function Trig_Command_Hero_Actions)
endfunction
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
I know the problem is related to the Aura ability because the ID apeared in the crashlog
This just means it was in memory somewhere near the point of the crash. Does not necessarily mean it was the cause and could even be memory garbage in some cases. Without source code it is hard to make use of such logs.

I would suggest replacing the code that modifies or adds abilities with debug messages to see if the crash still occurs. If it stops, then the ability is likely the cause. If it still does occur then something else must be the cause.

If the ability is the cause then it might be related to modifying the abilities of a dead unit. Not all Warcraft III natives were safe with regard to invalid arguments, for example Player(16) causes a crash in legacy versions. It might even be a bug with the native code for the auras. If this is the case then adding checks that the unit is alive might help, and possibly add clean-up code to the ability for when units die.
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
What I did is only the timer works if the hero is alive and only remove the aura ability when the hero revives, and the crashes stopped.
Edit: I changed it to remove the ability when the detects the hero is dead, so I guess the function "DecUnitAbilityLevel" causes the crashes.
 
Last edited:
Status
Not open for further replies.
Top