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

[JASS] Fastest way to check for invulnerability?

Status
Not open for further replies.
Level 4
Joined
May 17, 2008
Messages
75
Am I missing something here? Of all the unittype variables none of them correspond to "invulnerable".

What's the fastest way to determine if a unit is invulnerable? Checking for a long list of buffs and abilities that make it invulnerable hardly seems efficient, even if it only bothers to check units determined to be spell immune (apparently invulnerable units are always magic immune).
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Just wondering how many invulnerability spell will you have in your map, in order for the long list to be ... long.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
For having the ability?
Is it activated?
Check for buffs. When making one unit invulnerable via triggers add some buff.
To make it easier make a function that enlists all the buffs for invulnerability that returns false or true and call it whenever you want to see.
function inv takes unit a returns boolean
if(UnitHasBuffBJ(a, 'Bvul') == true) then
return false
else
call DoNothing()
endif
if(UnitHasBuffBJ(a, 'BHds') == true) then
return false
else
call DoNothing()
endif
if(UnitHasBuffBJ(a, 'BOvd') == true) then
return false
else
call DoNothing()
endif
return true
endfunction
 
Level 4
Joined
May 17, 2008
Messages
75
I'm currently doing that with a list of "and"'s, and am not aware of any triggers causing invulnerability. There are several buffs (Divine Shield, potion of invulnerability, Cyclone, Tornado Spin, Big Bad Voodoo). These may not be in the map, but there may be other custom buffs instead because I'm not the only one working on the map.

Even that's not ideal because some other abilities have some sort of transient invulnerability effect (Mirror Image, Impale, Sleep). I was wondering if there was any method that considered all cases.

I suppose I could check if a dummy is able to be ordered to use a channel spell on the unit that targets spell immunes but not invulnerables, but I'm not sure how slow that would be even if it only checks units found to be spell immune.
 
Level 4
Joined
May 17, 2008
Messages
75
Yes, I'm using GetUnitAbilityLevel.

I would have expected the damage suggestion not to work because damage events always seem to be set off only when the elapsed time is a multiple of .125 seconds, so I looked up the armor detection system which uses this method and found that it has a "IsUnitInvulnerable" function based on it.

Thanks!

Also, is there any difference in speed or reliability between "is GetWidgetLife(u) < 0.405" and "IsUnitType(u, UNIT_TYPE_DEAD)" ?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Damage events fire as soon as the damage is inflected but before the actual damage is delt. Thus you can get the damage inflected but the hitpoints will be as if it was not in conditions or actions run by the event.

It also seems that units are only dead with 0 HP. If the HP are less than 1 then it automatically rounds to 0 or something like that and thus a unit dies and its hp are set to 0. A unit can not have negetive HP unless you exceede the maximum number capacity of the HP object in which case you are really stupid and your maps badly made.

However in games like supreme commander where it rounds properly, it is actually possiable to get a unit with 0 HP out of however many and it will still be alive.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
if you use the gui function ok, but if you use the native one, what is wrong with use 0.405 instead of 0.
More hard ? :p
It's longer, and yields no advantages 99.999% of the time.

And according to HINDYhat it's faster
Did you even read HINDY's post?

and just try you will see that it's not a random number ...
It isn't random, but as I said, it's still useless 99.999% of the time.
 
Status
Not open for further replies.
Top