Warcraft III resources & community, 2003–2006 · archived

check if unit is attacked

6 posts
#1

check if unit is attacked

how do you make an effective way to check if a unit is attacked by using JASS? sorry for the inconvenience.
#2
Well, usually the idea is to create a local trigger, with the event EVENT_UNIT_DAMAGE and for the (Triggering Unit), and as a condition to make it so that only the attacker actually affects the unit. The only thing would be to give a time limit in which the unit can be damaged, because if not, if players abuse the EVENT_UNIT_ATTACKED delay then there will be dozens of leaks causing lag.

~Daelin
#3
ok, now im confused. i use the EVENT_UNIT_DAMAGE to check that a unit is damaged? then what what do i use EVENT_UNIT_ATTACKED for? :oops: (sorry this is actually my first time trying out JASS)
#4
Well, EVENT_PLAYER_UNIT_ATTACKED actually because it works for any unit. It's a generic event. Practically this technique makes EVENT_UNIT_DAMAGED generic as well. There may be other techniques to prevent the leaking but I never studied this problem in depth.

~Daelin
#5
so i add EVENT_UNIT_DAMAGED as a condition right? then do i need to add the other one? (man im feeling stupid right now :cry: )
#6
No, EVENT_UNIT_DAMAGED is an event for a local trigger into the trigger with the generic (an unit is attacked) event. ;)

~Daelin