HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

IsUnitDeadBX

04-08-2008, 09:27 AM#1
Toadcop
Yes. it's so simple but effective =) (i blame me what i just found it out not much earlier) ok here we go xD
Collapse JASS:
function IsUnitDeadBX takes unit u returns boolean
   return IsUnitType(u,UNIT_TYPE_DEAD) // no matching needed imho aka ==true
endfunction 
yes the sense of this is it's 100% bullet proofed if unit is dead it will defenetly return true.
lol yes it's so simple... aka GetUnitStata(u,UNIT_STATE_LIFE)<.406 say bb (cause it may be also tricked for example by setting unit life after it's dead etc.)
gl hf
04-08-2008, 09:29 AM#2
Av3n
You make me lol, how come nobody brought it up xD

-Av3n
Attached Images
File type: gifHero4_First.gif (1.2 KB)
04-08-2008, 09:41 AM#3
Toadcop
what ever... i havent see such way of detecting if unit is dead in any map.
04-08-2008, 10:12 AM#4
grim001
unless someone has a problem with this method I will probably start using it over the GetWidgetLife method since it seems more sensible and accurate.
04-08-2008, 11:18 AM#5
Strilanc
This method will fail if the unit has decayed.
04-08-2008, 11:30 AM#6
Toadcop
Strilanc this will fail if this unit doesnt exist in the game =) if you need to do operation's with not existing units...
04-08-2008, 12:29 PM#7
Rising_Dusk
Quote:
Originally Posted by Toadcop
if you need to do operation's with not existing units...
How can you possibly know the state of units over time without fully monitoring it? (Not worth the time as far as I'm concerned) That's reason enough for me to not use it.
04-08-2008, 12:39 PM#8
Strilanc
Quote:
Originally Posted by Toadcop
Strilanc this will fail if this unit doesnt exist in the game =) if you need to do operation's with not existing units...

There are situations, though rare, where you can end up not checking on a unit until after it decayed. A proper function should handle border cases (IsUnitDeadBJ returns true when they're decayed, and you do not want to do worse than a BJ).
04-08-2008, 12:41 PM#9
Rising_Dusk
Actually, for me, it's those border cases that wind up being the most important. If a unit with the artillery attack type explodes a unit and this method fails, it would be a catastrophe.
04-08-2008, 12:59 PM#10
Vexorian
Quote:
Originally Posted by Av3n
You make me lol, how come nobody brought it up xD

-Av3n
Because it doesn't really work either.

If you want a bullet proof method, just detect EVENT_UNIT_DEAD and mark units accordingly. Else I am gonna stick to GetWidgetLife or whatever, both checking the life and this one are equally ineffective.
--
I had thousands of issues with death detection when making a corpse explode spell, my conclussion there was that IsUnitType(u,UNIT_TYPE_DEAD) was ... the same to the unit life check. I don't think they changed it in a recent patch, but it is a possibility, it would be nice if blizz documented patch changes more.


--
Making this a function is absurd, it is easier to understand what it does without reading that whole BX stuff and you save a function call.
04-08-2008, 01:11 PM#11
Strilanc
On a related note, here is a function you may find useful:
Collapse JASS:
function IsUnitDecayed takes unit u returns boolean
    return GetUnitTypeId(u) == 0
endfunction
04-08-2008, 01:28 PM#12
Captain Griffen
That'll return true on a null object.

GetWidgetLife has never been a problem for me (I strangely enough never set a dead unit's health up).
04-08-2008, 01:36 PM#13
Strilanc
Quote:
Originally Posted by Captain Griffen
That'll return true on a null object.

GetWidgetLife has never been a problem for me (I strangely enough never set a dead unit's health up).

Good point, but the appropriate value for null is to be decayed, not alive. You will treat null as a decayed unit more often than as an active unit.

On the other hand, some people like to follow some sort of "always return 0/false/null for weird arguments" rule.
04-08-2008, 01:38 PM#14
Rising_Dusk
Collapse JASS:
function IsUnitDecayed takes unit u returns boolean
    return GetUnitTypeId(u) == 0 and u != null
endfunction
Ficksed.
04-08-2008, 01:41 PM#15
Vexorian
You would need to constantly keep a jass reference to the unit, else the id would get recycled.

I guess this is fixed if you stop using I2H. But there might be other cases?