HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detecting when an unit attacks

02-18-2009, 05:51 PM#1
RolePlaynGamer
Hello.

I'm putting together a boss script right now, and I'm wondering, what's the most safest and efficient way to detect when that boss attacks? The boss is recycled, so I only need to put up the event once.

Thanks in advance.
02-18-2009, 07:10 PM#2
xombie
Depending on what units you are planning on having in the game you could just add an EVENT_UNIT_DAMAGED triggerevent to every unit in the game, more or less the same principal behind a damage detection engine though usually bosses can't attack more than a select few units.

When you add the damage event, then just detect GetTriggerUnit for the unit being attacked, and then GetEventDamageSource() for the attacking unit.

Other than this the only option would be EVENT_UNIT_ATTACKS.
02-19-2009, 11:33 PM#3
RolePlaynGamer
I don't want to make a trigger which fires everytime an unit takes damage, It's not really very efficient.

Also, last time I looked there were no EVENT_UNIT_ATTACKS constant.

Detecting when the boss is ordered to attack won't work either, because it would only fire once. Damn.

Any ideas?
02-19-2009, 11:35 PM#4
Bobo_The_Kodo
Quote:
I don't want to make a trigger which fires everytime an unit takes damage, It's not really very efficient.

Yes it really is.

Or you could use the EVENT_PLAYER_UNIT_ATTACKED, but that fires when a unit starts their damage point, not when it ends the damage point... so ><
02-19-2009, 11:47 PM#5
xombie
Yes, ATTACKED. Where there is an attack, there is an attacked unit. Indeed, the other method would be to detect when they initialize their attack, it isn't even certain that they would have dealt the damage at all if they cancel the attack before the backswing.
02-20-2009, 01:26 AM#6
Bobo_The_Kodo
Quote:
Yes, ATTACKED. Where there is an attack, there is an attacked unit. Indeed, the other method would be to detect when they initialize their attack, it isn't even certain that they would have dealt the damage at all if they cancel the attack before the backswing.

You're confused :). There is no EVENT_PLAYER_UNIT_ATTACKS / EVENT_UNIT_ATTACKS ... You WERE thinking of EVENT_UNIT_ATTACKED, which is when they start damage point timer like i said
02-20-2009, 02:12 AM#7
xombie
I thought that's what I was trying to say.