• 🏆 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!

[Crash] Changing ability level of dead units.

Status
Not open for further replies.
Level 5
Joined
Aug 30, 2009
Messages
114
Hello guys, its been a while since my last post.

So, I was testing my map out with some friends, and I found many crashes, and all with abilities that give "dummy" abilities to units! The easiest example I can give you guys is this ability:

Every attack given by an unit with the A0T6 ability causes the attacked to loose armor for a few seconds based upon the level of the ability.

JASS:
private function Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetAttacker(), 'A0T6') > 0
endfunction

private function Actions takes nothing returns nothing
    local unit U = GetAttacker()
    local unit T = GetTriggerUnit()
    local integer Lv = GetUnitAbilityLevel(U, 'A0T6')
    local integer Stacks = GetUnitAbilityLevel(T, 'A0T7')
    local real Wait = 3 + (2 * Lv)
    if Stacks == 0 then
        call UnitAddAbility(T, 'A0T7')
    else
        call IncUnitAbilityLevel(T, 'A0T7')
    endif
    call CustomWait(Wait)
    if (GetUnitAbilityLevel(T, 'A0T7') == 1 then
        call UnitRemoveAbility(T, 'A0T7')
    else
        call DecUnitAbilityLevel(T, 'A0T7')
    endif
    set U = null
    set T = null
endfunction

Note: That "CustomWait" function is a simple optimized PolledWait I made, which has no leaks. The crash has nothing to do with this function since I use it everywhere and I had absolutely no problem with it so far.

The problem is: The spell works perfectly fine, but if the enemy dies and the duration expires, the game crashes.

So, my question is the following: Does change ability level of dead units crash the game or the source of my problem must be somewhere else ???

Thanks guys.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
This is indeed the problem. It might be possible to change level of ability with the SetUnitAbilityLevel function instead, but that seems unlikely.

I recently encountered this problem myself too when making some abilities with my buff system(buffs are abilities and their level shows stacks).
 
Level 5
Joined
Aug 30, 2009
Messages
114
o_O

Now that is what I call efficiency !!! You were fast sir Xonok !!! Rep+ for you !!

Thank you, do you know any workaround this ?? "SetUnitAbilityLevel" crashes too, I have other abilities doing the same crash. Maybe if I check if the enemy's dead and then simply remove the ability from it, might work... right ?
 
Status
Not open for further replies.
Top