Warcraft III resources & community, 2003–2006 · archived

How to detect when a projectile hits a unit?

32 posts
#1

How to detect when a projectile hits a unit?

Is it what I want to do, a spell based in storm bolt that stuns and deals damage based in the Intelligence of the Hero, then, this damage must be triggered with the action Unit - Damage target, but, this spell must to have a missile art too and I want this damage happening only when the projectile of the storm bolt hits the foe.
How to do it :?:
#2
Without going into the editor and fooling around a bit, the best I could say is you have to set variables for distance of target from triggering unit or caster or ability then do arithmetic to calculate how long it would take the projectile to get there based on its speed, then take that time and do a Wait action?

Maybe I'm thinking way too complex...
#3
That is correct frog15, almost completely correct. You simply need to add a wait, with no variables and no nothing. The wait's value is equal to the (distance between the two points)/Missile Speed (which unfortunately cannot be determined through a function, so you will have to take it from the object editor).

After that wait, apply the correct damage.

~Daelin
#4
Wow, and here I was thinking that I was being stupid and making this alot more complex than it needed to be.
#5
I have this problem to... Why didnt blizzard make the opposite of damage source :!: :evil:
#6
Attacked unit?
#7
No, the opposite of attacked is attacking, so when u use those 2, the trigger will be activated when the ranged unit fires, not when it hits its target
#8
Slow down a bit, this thing is not that simple. The thought crossed my mind when I was making a missile chain spell. What if the target is moving or starts to move after the missile has be launched? Then the timing will be incorrect.
Let's say you simulate a fireball skill with splash damage and spell casting on units in the hit area. You launch the missile but then the targets starts moving away form the caster and let's say it is a very fast unit. Then the explosion effect will occure behind the target, before the missile has even hit it.
I a shadow of an idea that I need to test...
#9
I've been thinking about this too. Is there some way the wait function can wait until the targeted unit has the stun buff to apply the damage?
#10
Alright, I thought about it, and here's the best I could come up with:

Let's say it's a fireball spell.

You make a trigger specifically checking for that spell, it sets a variable to, anything. (Event: a unit casts an ability, ability = firebal, set var = 1, set var = target unit of ability being cast)

Then you have another trigger, this one is:
Event: a unit is attacked
Condition: variable = on/true/1 whatever, and variable2 = unit
Actions: Then you can do all that distance from attacking unit or damage source/speed of projectile and reset both variables.

Would that work (I haven't tested so I don't know for sure)?

If the A unit is attacked doesn't work, you can use WE Unlimited's Any Unit Takes Damage.

Also, I guess you'd have to add in there more variables, like who was the target of the fireball spell.

You could just use a chain lightning spell you know? Instant projectile. No time lapse?
#11
The opposite of (Damage Source) is (Triggering Unit) for all those who don't know, because the event is "X unit IS DAMAGED" so the event occurs when an unit is damaged, not when an unit damages another unit.

And units cannot move THAT fast to make the wait significant. Inrease the missile speed if you must and that should do it. Yes, it's a tiny bug but I usually ignore it.

You can also simulate the projectile by creating a dummy unit as a projectile and ordering it to attack the unit (melee range). Put a wait for condition (distance between dummy and target is less than or equal to 50) and then change the owner of the dummy to Neutral Passive, kill it, and damage the target.

~Daelin
#12
Does damage event register spell damage? This is the key tomy idea.
#13
:D In only 1 day 11 replies appeared :lol: !
I never thought in this way to add a wait action that equals to the distance between the caster and the target, it really works perfect!

Thanks to you all! :wink:
#14
The opposite of damage source isnt triggering unit. I tried this with my skill but nothing happens
#15
Two units, Unit A and Unit B.

Unit A attacks Unit B

A unit is attacked refers to Unit B, Triggering Unit refers to Unit B, damage source refers to Unit A, Attacked Unit refers to Unit B, and Attacking Unit refers to Unit A.

You can not use any Target(ed) unit conditions.

I don't understand what you mean by Damage Source or opposite of Damage Source because I don't know what Event you're using. You could be using A unit begins casting an ability, or A unit begins the effects of an Ability. Etc.. Etc..

In each of those the Damage Source changes, actually, in any Event that mentions an Ability, there is no Damage Source. Because there is no damage being done.

So if you pasted the trigger so we could look, instead of just telling us something doesn't work, it would be much easier.