• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Unit is attacked

Status
Not open for further replies.
Level 12
Joined
Nov 5, 2007
Messages
730
Probably a noob question...

Im making a spell.When a unit is attacked its supposed to do something,for example,blow up.

However,it doesnt work very well.By "is attacked" the editor obviously refers to the point when the enemy unit starts attacking,so my problem is that the spell looks pretty bad.

Example: Attacker fires a missile.Missile gets to 1/10 of its way to the target,target blows up.This doesnt look good at all,since the point of the spell is to look like the hit caused the explosion.

There are tons of different units with different missile speeds and attack speed animations,so i cant rely on the "wait" funcion.

Is there a way to make an action trigger when a unit takes damage?Ive looked for such an event but couldnt find it.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
That requiers a Damage Detection system which is really not suggested in GUI (because it will bug in case more then one unit gets attacked at the same time which is a big possiblity in warcraft maps).

I will maybe try to make one in JASS soon.

In case you do want to make it in GUI, you will basicly need to set the attacked unit (via the "a unit is attacked") to a variable and create another trigger that will have as a event the "specific unit gets hit" with the variable.

If you ever tried to make something like this, you probably know you can't put variable values in the "unit gets hit" event so you'll need to add it in a "add event" action in yet another trigger.

Im just too lazy to make it at the moment to show you ^^
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Put it in a trigger called "AddDmg" (name the trigger before you put in the code).
You will need to add actions to it as you can see.

By the way purple, wouldn't creating a new trigger each time a unit is attacked be more efficient then creating it for every unit on the map ?
Also, I didn't know you can make the Init function act like a normal function instead of only assigning the event/conditions/actions, c00l ! :)
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
By the way purple, wouldn't creating a new trigger each time a unit is attacked be more efficient then creating it for every unit on the map ?
Also, I didn't know you can make the Init function act like a normal function instead of only assigning the event/conditions/actions, c00l ! :)

no...
(lol I quoted you)
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
I mean that damage detection also detects damage from spells and triggers, but if you only added the event on attack then it wouldn't be very accurate... (And while this thread is for A Unit is Attacked, it's always handy to have a tool that is less restricted and with no great disadvantages to being so)
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
[Off-topic]
Do you know a good buff applier ability (I think slow poison doesnt work with AoE's).
My system (lol "system", "script", "program") detects slow poison buff to detect normal attack, but it doesnt work when unit has AoE damage
/Off-topic]
 
Status
Not open for further replies.
Top