1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Crash] Changing ability level of dead units.

Discussion in 'World Editor Help Zone' started by Narg666, Aug 20, 2014.

  1. Narg666

    Narg666

    Joined:
    Aug 30, 2009
    Messages:
    112
    Resources:
    0
    Resources:
    0
    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.

    Code (vJASS):

    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.
     
  2. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,039
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    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).
     
  3. Narg666

    Narg666

    Joined:
    Aug 30, 2009
    Messages:
    112
    Resources:
    0
    Resources:
    0
    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 ?
     
  4. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,039
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    Why do you so desperately need to mess with abilities of dead units? Will they be resurrected or something?

    In any case, removing shouldn't crash. If it doesn't want to remove, then it will simply return false.
     
  5. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,539
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    Could use damage detection and fake the death combined with locust then hide it then un-locust it. That'd pretty much resolve both your guys problems. Only issue being having to morph every unit back, could remove that unit and then recreate the units instead if you don't mind the small unit-creation leaks.
     
  6. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,039
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    Morphing units appears to have the unit creation leak too btw. Also, this technique requires at least 1 ability per unit type.
     
  7. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,539
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    Sadly. . . =(

    So it's just easier to remove the unit after it expires and trigger revives and stuff or free up all data right away that your using to call back to the unit.