1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  4. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  5. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. 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.

Hero is actually dead, still considered Alive

Discussion in 'World Editor Help Zone' started by MN Lahmar, Jan 19, 2019.

  1. MN Lahmar

    MN Lahmar

    Joined:
    Jul 28, 2013
    Messages:
    585
    Resources:
    9
    Models:
    7
    Icons:
    1
    Skins:
    1
    Resources:
    9
    Hello guys,

    Something strange happened after i tested like a 3 thousands times. The trigger goes like this: A unit enters a region, if a player's specific hero is dead then resurrect him. So, the hero i'm talking about is a specific hero (Kael 0001) for example. For an unknown reason, after millions of tests a hero was considered alive when he was actually dead (i'm 100% certain about that). So, i thought since the trigger that i'm using is 100% correct, the problem might actually be something to do with a dynamic allocation or a variable with a false value because Kael 0001 is dead (he's truly dead i mean he's gone really his icon is black and white :p) but still considered alive when you apply the Trigger Editor's condition "Kael 0001 is dead equals True". As i mentioned before, this happened 1 time in like 3 thousands times and the game lasted 3hours what made me think about a game bug like a variable received the wrong value or something :p. Maybe the new patch :p

    So, i thought maybe it would be best if i Create a Variable Kael = Kael 0001 and use that variable instead of directly selecting the label Kael 0001 from the Editor.


    Please let me know what do you think about this guys. Maybe someone has an idea about this.

    Thank you.
     
  2. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,042
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    That condition checks whether the unit has less than 0 health. The thing is, dead units can be healed, with Tranquility for example, so they might seem alive.
    Try checking for something else, like if the unit is selectable or something.
     
  3. BloodSoul

    BloodSoul

    Joined:
    May 10, 2009
    Messages:
    728
    Resources:
    2
    Spells:
    2
    Resources:
    2
    Since vanilla world editor now supports JassHelper, you might want to make use of the UnitAlive function from common.ai. You just need to declare it only once in your map header, and use it at will.
    native UnitAlive            takes unit id                               returns boolean


    Code (vJASS):
    If not UnitAlive(udg_KaelVar) then
        // unit is dead.
    endif


    If you don't feel like using that one, then use IsUnitType function.
    Code (vJASS):

        if IsUnitType(udg_KaelVar, UNIT_TYPE_DEAD) then
           // unit is dead
        endif

        // If your hero can be removed from the map at any time, then do this instead
        if IsUnitType(udg_KaelVar, UNIT_TYPE_DEAD) or (GetUnitTypeId(udg_KaelVar) == 0) then
           // unit is dead
        endif
     

    In GUI

    • Custom script: set udg_IsUnitDead = UnitAlive(udg_KaelVar)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • IsUnitDead Equal to True
      • Then - Actions
      • Else - Actions

    • Custom script: set udg_IsUnitDead = IsUnitType(udg_KaelVar, UNIT_TYPE_DEAD)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • IsUnitDead Equal to True
      • Then - Actions
      • Else - Actions