• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

How to detect when a projectile hits a unit?

Status
Not open for further replies.
Level 6
Joined
Aug 12, 2005
Messages
205
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 :?:
 
Level 3
Joined
Oct 21, 2004
Messages
72
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...
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
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
 
Level 3
Joined
Oct 21, 2004
Messages
72
Wow, and here I was thinking that I was being stupid and making this alot more complex than it needed to be.
 
Level 12
Joined
Apr 29, 2005
Messages
999
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...
 
Level 2
Joined
May 2, 2005
Messages
20
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?
 
Level 3
Joined
Oct 21, 2004
Messages
72
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?
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
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
 
Level 3
Joined
Oct 21, 2004
Messages
72
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.
 
Level 22
Joined
Jan 10, 2005
Messages
3,426
Events:
Unit - A unit gets damage
Conditions:
((Damage Source) has buff .... ) Equal to True
Actions:
Unit - Create 1 ... for (Owner of (Damage Source)) at (Position of (Damage Source)) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Attack (???? (there is no opposite of damage source))
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
Umm, Ramza, I tried it myself. If the (Damage Source) is the unit inflicting the damage, (Triggering Unit) is the unit damaged by the (Damage Source). I tried to remove (Triggering Unit) in a trigger with such an event and it worked.

NOTE: This doesn't apply for UMSWE "An Unit is Damaged". If you are using it, then you're wasting your time trying to find the oposite.

And yes, "Unit is Damaged" works for spell damage too. I tested it with Flame Strike.

~Daelin
 
Level 6
Joined
Aug 12, 2005
Messages
205
"Unit gets damage", "Unit is damaged", where do you found these events?
The unique event like that is the "A unit takes damage" but works only for specific units!
I think that blizzard must to do this event for generic units too :evil:
 
Level 10
Joined
Apr 9, 2004
Messages
502
Hmmm i've figured out a rough way to may something like this owrk 99% of your attacks and maybe even more depending on your attack speed. And i've done it without the boost of WEU. Mine's just moreso based off of figuring out a unit you're attacking then assigning them as a global variable, then checking for that variable taking dmaage. It's worked for me and the only problem i could ever see is when my hero attacks before their missile hits which in my maps is rarely-never. I can post my map later and you can see for yourself, i've figured a way to make multiple orb abilites at the same time.
 
Level 6
Joined
Aug 12, 2005
Messages
205
I didn't understand this method well but I'll like if you send the map to see. But the another way to wait a time basing in the distance between the caster and the target divided to the speed of the projectile works perfectly too.
i've figured a way to make multiple orb abilites at the same time
Do you discovered a way to stack Orb Effects?
 
Level 10
Joined
Apr 9, 2004
Messages
502
In a sense, yes. The reason, it's not actually linked to your hero, it's kind of like a secondary unit that casts the effect when you damage a target with your attack. As such it isn't linked to your attack directed so can't be overriden, plus it's not hard to trigger it this way since each effect is actually linked to a dummy spell. The thing doesn't lag mind you, and the game doesn't see it as an orb effect. As such it can be stacked since it doesn't actually replace an attack. This method can allow you to have has many orb effects as you desire. Still if you wan't it to override then you have to use a dummy spell as something that generally will overide orb effects when activated, like searing arrow, for example. I'll get the map up soon so yuo can see.
 
Level 2
Joined
Jul 5, 2005
Messages
19
I think the best thing to do is make a sphere ability that has the projectile you want, then at the "unit issued command" event, give him the sphere. If it gets disrupted you have to take it away, but then when a spell targets a unit or point, a projectile will shoot out (you can use Channel for this).

Then, the "Starts the effect of an ability" event will be triggered when the projectile hits the unit.
 
Level 1
Joined
Dec 21, 2005
Messages
2
back to the topic of the unit's distance to when the projectile hits:

I would make the projectile a dummy unit and the spell a dummy spell, and then i would trigger it so that a dummy unit comes out when the spell is inisiated, then i would trigger it so that the dummy unit is ordered to attack the targeted unit. (dummy unit's range is very small), then make another trigger to see when the dummy unit attacks the targeted unit and remove or kill the dummy unit and then the rest is whatever you want it to be. This was theorized in 5 minutes so it may not work but i am pretty sure it works.
 
Level 3
Joined
Dec 22, 2005
Messages
38
I actually found out something relatively simple for this that you can use without triggers.

Some of the spells like stuns have a BUFF field, and you can make a custom buff with an animation effect on it (with whatever attachment points you want) and link it into that abilities "BUFF" field. The "BUFF" gets applied to the target of the spell when it gets physically hit by it.

Like I just used Fireball and made it into a Pyroblast spell. I wanted them to get hit with an explosion. Well, normally by default it just shows a stun icon when this spell hits. I made a Pyroblast buff, and gave it an explosion animation, and then gave the Pyroblast ability the Pyroblast buff. Everytime I use the pyroblast and at the moment the fireball connects to the target it shows that animation effect of an explosion.

It works pretty nice.
 
Level 3
Joined
Nov 6, 2005
Messages
17
Actually....

It must be something like this but still if you want to make it perfect you have to make it better

In the custom spells the storm bolt has a missile speed

Lets say missile speed is 700

when event: "A unit starts the effect of an ability"
conditions:Ability being cast equal to stormbolt
actions:Wait (Distance between casting unit and target unit of ability being cast/700) that should do it.

example:Cast range is 1400 and missile speed is 700

the trigger will be activated in 2 seconds

but if the unit moves it still will be activated in 2 seconds so...

if you want to make it better you have to make another trigger in progress

a trigger that will be deactivated and activated when spell trigger occurs:Example "trigger:Turn on "Distance Counter"

the Trigger will be on and then Periodic Time:every 0.01 seconds it will set a variable as set tempDistance=Distance between unit(1) and unit(2) and so the trigger can be perfect.
 
Level 2
Joined
Jan 3, 2005
Messages
19
OK ENOUGH OF THIS DEAR GOD!!!

OK LISTEN HERE
THERE IS A WAY TO DO THIS,
In the Events under Units: There is a event that says
(Unit: A Unit Takes Damage)
That activates when the prjectile ACTUALY hits it. Not when its fired.....was that so hard? dear god ><
(If someone else has said this then im sorry for repeating it but i was 2 lazy to read all of them...)
 
Status
Not open for further replies.
Top