| 04-08-2008, 09:27 AM | #1 |
Yes. it's so simple but effective =) (i blame me what i just found it out not much earlier) ok here we go xD JASS:function IsUnitDeadBX takes unit u returns boolean return IsUnitType(u,UNIT_TYPE_DEAD) // no matching needed imho aka ==true endfunction 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 |
You make me lol, how come nobody brought it up xD -Av3n |
| 04-08-2008, 09:41 AM | #3 |
what ever... i havent see such way of detecting if unit is dead in any map. |
| 04-08-2008, 10:12 AM | #4 |
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 |
This method will fail if the unit has decayed. |
| 04-08-2008, 11:30 AM | #6 |
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 | |
Quote:
|
| 04-08-2008, 12:39 PM | #8 | |
Quote:
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 |
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 | |
Quote:
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 |
On a related note, here is a function you may find useful: JASS:function IsUnitDecayed takes unit u returns boolean return GetUnitTypeId(u) == 0 endfunction |
| 04-08-2008, 01:28 PM | #12 |
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 | |
Quote:
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 |
JASS:function IsUnitDecayed takes unit u returns boolean return GetUnitTypeId(u) == 0 and u != null endfunction |
| 04-08-2008, 01:41 PM | #15 |
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? |
