HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

detecting attacks

05-17-2008, 04:18 PM#1
Quldan Elwood
I know i can do the "unit-is attacked" thing but that triggers right as the unit is about to attack. I want it to trigger the moment the unit's weapon hits it's target. (example: archer shoots and arrow, trigger when arrow reaches target) Is there any way i can detect this or am i just going to have to deal?
05-17-2008, 04:50 PM#2
chobibo
You could setup your own attack detect engine or just use one from the resources section. I suggest you to look at emjlr3's onAttack Template as it does exactly what you want.
05-17-2008, 05:49 PM#3
Themerion
Event: Unit - Takes Damage
Notice that it must be a specific unit who takes damage. Player owner or generic won't work.

In order to check this for every unit, you usually start like this:

Trigger:
Register for damage
Events
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Collapse Loop - Actions
Trigger - Add to Unit is damaged <gen> the event (Unit - (Picked unit) Takes damage)

You will also want to register units who enter the playable map area.
05-17-2008, 05:57 PM#4
Quldan Elwood
i already have it working just fine as detecting generic units but as i have said it triggers before the hit is done. The thing is your system wouldn't work with what i am doing b/c my trigger is the thing causing the damage the unit itself doesn't cause any damage ( attack type is set to a type that is prevented 100% to all). also all units will be added into the unit group and may cause leaks during large battles (that will happen in my game). so i thank you for the idea but it doesn't work for what i am doing
05-17-2008, 06:26 PM#5
Quldan Elwood
Quote:
Originally Posted by chobibo
You could setup your own attack detect engine or just use one from the resources section. I suggest you to look at emjlr3's onAttack Template as it does exactly what you want.
this didn't help, that system was too complicated to understand even if everyone else was saying how simple it is. On top of that from my understanding it only detects units that are being damaged, my units are not receiving any damage until after the trigger. ( trigger is a system i have created to allows me to have an infinite number of Damage and Armor types, as well as my own system of applying armor reduction % rather then using blizzards armor system. this way i can decided if i want a particular armor type to prevent say 5% and then 10% more per upgrade..ect)
05-17-2008, 07:15 PM#6
Themerion
Well, unless you want to script/trigger a missile engine for ranged attacks, there is no other way than to use Unit Takes Damage. Unit Takes Damage responds exactly when the unit is hit (which is what you wanted).

I think you are using Unit Is Attacked. That is not the same thing.

Takes Damage will trigger even if you have selected 100% resistance in gameplay constants. Check my trigger above for how to use it in the generic case, if you don't know.
05-17-2008, 08:50 PM#7
Quldan Elwood
Quote:
Originally Posted by Themerion
Well, unless you want to script/trigger a missile engine for ranged attacks, there is no other way than to use Unit Takes Damage. Unit Takes Damage responds exactly when the unit is hit (which is what you wanted).

I think you are using Unit Is Attacked. That is not the same thing.

Takes Damage will trigger even if you have selected 100% resistance in gameplay constants. Check my trigger above for how to use it in the generic case, if you don't know.
I have used your trigger and it originally created a loop b/c a unit would attack (dealing damage with 100% prevention) then get dealt damage ( using my system) but the new damage caused the trigger to trigger again killing the unit over a few seconds lol. I fixed to looping turning off the trigger before dealing the damage and then turning it back so tank you very much for the suggestion.
Addition: I have tweaked your method a little more and it works perfectly for what i was doing, thank you very ,uch. i didn't think it was going to work at first but it work :D +rep
05-18-2008, 12:12 AM#8
Themerion
Yeah, the trigger wasn't a complete one, I just wanted to show you the idea of it. I'm delighted to see that you were able to figure out how to solve the damage recursion problems by yourself (since I obviously should have mentioned it).

Don't forget the trigger which looks like this:

Trigger:
Register New Units For Damage
Collapse Events
Unit - A unit enters (Playable map area)
Conditions
Collapse Actions
Trigger - Add to Damage Detection Trigger <gen> the event (Unit - (Entering unit) Takes damage)

Well... glad I could help.
05-18-2008, 01:35 AM#9
chobibo
Hey sorry about not being able to help lol, and nice job Themerion!
05-18-2008, 10:42 AM#10
d07.RiV
first of all, the Takes Damage would work because even if you set damage to 0% in the editor it will still deal 1 damage.
also if you want the trigger to deal additional damage, how would you do it? you perhaps would need a dummy unit that deals the damage, otherwise if you use Unit - Damage Target it will get picked up by the takes damage event again and so on and so on. So create a dummy unit and add a condition like Unit Type of (Damage Source) is not equal to Dummy Unit.
05-19-2008, 06:18 PM#11
Quldan Elwood
Quote:
Originally Posted by Themerion
Yeah, the trigger wasn't a complete one, I just wanted to show you the idea of it. I'm delighted to see that you were able to figure out how to solve the damage recursion problems by yourself (since I obviously should have mentioned it).

Don't forget the trigger which looks like this:

Trigger:
Register New Units For Damage
Collapse Events
Unit - A unit enters (Playable map area)
Conditions
Collapse Actions
Trigger - Add to Damage Detection Trigger <gen> the event (Unit - (Entering unit) Takes damage)

Well... glad I could help.
LOL this is exactly how i solved to loop problem!! All units on my map are spawned during "set-up" to reduce game load time so i only needed this trigger for it to work.


Quote:
Hey sorry about not being able to help lol, and nice job Themerion!
hey im just glad you tried to help me out so dont worry about it

Quote:
first of all, the Takes Damage would work because even if you set damage to 0% in the editor it will still deal 1 damage.
also if you want the trigger to deal additional damage, how would you do it? you perhaps would need a dummy unit that deals the damage, otherwise if you use Unit - Damage Target it will get picked up by the takes damage event again and so on and so on. So create a dummy unit and add a condition like Unit Type of (Damage Source) is not equal to Dummy Unit.
1) the unit still is not dealt 1 damage as you say, I've tested that theory but it dose still trigger the the trigger even without the damage.
2) the trigger is not ever dealing additional damage, the trigger has a set of calculations that calculates damage of attacks similar to the normal calculation done by blizzard but i wanted more then what blizzard offered.
3) the whole point of this thread was to get around the "Unit - Damage Target" event, you would know this if you read the beginning of the thread
4) also there is no use of a dummy unit to cause any damage... if you read..
Quote:
trigger is a system i have created to allows me to have an infinite number of Damage and Armor types, as well as my own system of applying armor reduction % rather then using blizzards armor system. this way i can decided if i want a particular armor type to prevent say 5% and then 10% more per upgrade..ect
therefore any "extra" damage cause by the difference of attack and armor types are within the calculation of damage. So thanks, i guess, but your post was pointless.... no offence.