Is unit dead?

dudeim

New Member
Reaction score
22
Hey,

got a little question there are a few ways to check if a unit is dead, but all have their disadvantages.
So the question is if the "A Unit Dies" event triggers is the unit really considered dead so can't there be any way to revive him by setting his hp higher? (I'm not talking about the hero revive action thingy)
So will the "Unit dies" event not fail or does it fail?

Thanks (hope you get what I mean:p)
 

Azlier

Old World Ghost
Reaction score
461
I'm not sure I understand. If a unit dies by taking damage or through KillUnit or possibly other means, the unit dies event will always fire. If the unit is removed via RemoveUnit, it does not fire.

If you wish to know if a unit you currently have a reference to is dead, you can use this native, once you paste it into your map. Make sure you're using a recent Jasshelper version, though.

JASS:
native UnitAlive            takes unit id                               returns boolean
 

dudeim

New Member
Reaction score
22
But doesn't this native bugs when you compress a map using an optimizer? That's what I heard atleast (or something along that way)
 

Sevion

The DIY Ninja
Reaction score
413
Use [ljass]IsUnitType(whichUnit, UNIT_TYPE_DEAD) or GetUnitTypeId(whichUnit) == 0[/ljass]. That will return true for dead and/or removed units.
 

Jedi

New Member
Reaction score
63
I really want to puke everywhere because of this retarded IsUnitDead-Alive discussion.
 

Sevion

The DIY Ninja
Reaction score
413
I really want to puke everywhere because of this retarded IsUnitDead-Alive discussion.

It's not retarded. Many methods have different pros and cons.

You should research before you make such comments.
 

Jedi

New Member
Reaction score
63
If you dont increase a dead unit's life, I see nothing wrong with GetWidgetLife.
 

Azlier

Old World Ghost
Reaction score
461
First, UnitAlive has no known cons whatsoever.

Second, GetWidgetLife isn't magically safe even if you're careful to check before modifying life. Some abilities have been reported to increase life after death, such as Stone Form. Best to avoid dodgy methods when there are better ones available.
 

Nestharus

o-o
Reaction score
84
First, UnitAlive has no known cons whatsoever.

Second, GetWidgetLife isn't magically safe even if you're careful to check before modifying life. Some abilities have been reported to increase life after death, such as Stone Form. Best to avoid dodgy methods when there are better ones available.

I heard UnitAlive returns true the instant a unit is removed (same with IsUnitType((u, UNIT_TYPE_DEAD), hence the GetUnitTypeId != 0 check. I guess you could actually use not (UnitAlive(u) and GetUnitTypeId(u) == 0) to see if a unit was currently dead and (UnitAlive(u) and GetUnitTypeId(u) != 0) to see if a unit is alive..
 

emjlr3

Change can be a good thing
Reaction score
395
that is a very rare occurrence when you will be checking whether a unit is alive at the same moment it is removed - if that is the only time it doesn't function properly, I say its pretty reliable
 

Azlier

Old World Ghost
Reaction score
461
GetUnitTypeId(u) == 0)

I seriously doubt GetUnitTypeId will return 0 the instant a unit is removed, as the unit isn't truly removed right then and there. The moment GetUnitTypeId returns 0 is the same moment that UnitAlive works.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top