HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Safest Way to Check a Unit's Existence

02-21-2007, 09:59 PM#1
Rising_Dusk
Title says it all --
What is the safest and most reliable way to check if a unit exists or not?
02-21-2007, 10:06 PM#2
Captain Griffen
GetUnitTypeId(u) != 0 ought to work.
02-21-2007, 10:11 PM#3
Vexorian
MaxLife() != 0 works also.

It is better to avoid these situations anyways
02-21-2007, 10:15 PM#4
Mythic Fr0st
what about

IsUnitAlive()

?
02-21-2007, 11:59 PM#5
Pyrogasm
A unit still "exists" after it dies; a corpse still counts as "existance". Thus, IsUnitAlive() is not sufficient.
02-22-2007, 05:04 AM#6
emjlr3
i don't understand the question, r u asking whether a unit is dead?

in which case I'd use GetWidgetLife()>.405

or do you care if the unit exists period?

in which case id just see if the unit!=null
02-22-2007, 05:08 AM#7
PipeDream
Impossible to know with out leaking under general circumstances.
02-22-2007, 12:42 PM#8
Rising_Dusk
Well, for example.
A unit is removed after it has finished decaying upon death.

I have lots of global variables, and I'd like to do X or Y to them only if they haven't decayed.
I was just seeing if there was a better way than GetWidgetLife() to check if it was removed/there/whatever.
Thanks all.