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

Hero is actually dead, still considered Alive

Status
Not open for further replies.
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.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
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.
 
Level 13
Joined
May 10, 2009
Messages
868
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

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

If you don't feel like using that one, then use IsUnitType function.
JASS:
    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

  • 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
 
Status
Not open for further replies.
Top