• 🏆 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!

[Spell] Range between units in time interval

Status
Not open for further replies.

sentrywiz

S

sentrywiz

Suppose I have a spell "Frost Bolt" that is supposed to launch a missile, hit the target and apply a slow afterwards. Since there is no such default spell in warcraft I figure I'd make a Fireball and cast a Slow afterwards.

Thing is, I want the slow after the missile hits the target, if I just make it on starts the effect of an ability, it will look junky and bad. It will cast the slow before missile hits the target.

So how do I calculate the range between the two units and then convert it into a time interval so the dummy unit will wait X seconds before casting?
I should also note -- how would the missile speed impact the calculation?
 
I don't know what the calculation would be but my best bet is to use DDS. Not sure if it can do the job but i think it can.

That's highly inaccurate; if the hero is ranged and the attack's missile is faster than the spell's missile, DDS will fire incorrectly, so the slow will occur inaccurately.

What you need here is to code everything (it's the simplest missile spell you could do anyway); use Cripple to slow the enemy once the missile hits the target.
 

sentrywiz

S

sentrywiz

That's highly inaccurate; if the hero is ranged and the attack's missile is faster than the spell's missile, DDS will fire incorrectly, so the slow will occur inaccurately.

What you need here is to code everything (it's the simplest missile spell you could do anyway); use Cripple to slow the enemy once the missile hits the target.

Doesn't matter what the missile spell is and what the slow spell is.
how does the calculation of range between two units into time go?
 
I'm not sure of the internal distance calculation. Assuming it's 32, it would be [0.03125*((Distance between Unit1 and Unit2)/(MissileSpeed/32))]; where MissileSpeed = Art - Missile Speed field of the ability. This will output the time (seconds) it takes for the missile to get from Point1 to Point2. However, you also need to take into account that the unit's locations may change in the process, which means that you need to make the calculations within a timed event or function and subtract distance already covered.
 
I'm not sure of the internal distance calculation. Assuming it's 32, it would be [0.03125*((Distance between Unit1 and Unit2)/(MissileSpeed/32))]; where MissileSpeed = Art - Missile Speed field of the ability. This will output the time (seconds) it takes for the missile to get from Point1 to Point2. However, you also need to take into account that the unit's locations may change in the process, which means that you need to make the calculations within a timed event or function and subtract distance already covered.

Aye. And really. A spell where the distance is a relevant factor should be triggered.
Anything else will look clumsy one way or another.
 

sentrywiz

S

sentrywiz

I'm not sure of the internal distance calculation. Assuming it's 32, it would be [0.03125*((Distance between Unit1 and Unit2)/(MissileSpeed/32))]; where MissileSpeed = Art - Missile Speed field of the ability. This will output the time (seconds) it takes for the missile to get from Point1 to Point2. However, you also need to take into account that the unit's locations may change in the process, which means that you need to make the calculations within a timed event or function and subtract distance already covered.

Care to make an example map of how its done?

I don't need an exact calculation, the missile will be moving at minimum of 1000 speed anyway. The point is to not look insta-dumb, like the missile is flying and the dummy unit casts the slow while the missile is in the air. Anything approximately would be satisfying
 
Level 12
Joined
May 20, 2009
Messages
822
Someone needs to make a system or something for this. It's such a common question. Even I've needed something like this once or twice and decided to not go with the spell I needed it for because this exact thing is just too complicated for me.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
If you are okay with firebolt's stun.Just use a custom buff.When that unit takes damage, if damage taken unit has "frostbolt" buff, apply slow.
 

sentrywiz

S

sentrywiz

Someone needs to make a system or something for this. It's such a common question. Even I've needed something like this once or twice and decided to not go with the spell I needed it for because this exact thing is just too complicated for me.

A system is too much. A simple tutorial would be fine.

If you are okay with firebolt's stun.Just use a custom buff.When that unit takes damage, if damage taken unit has "frostbolt" buff, apply slow.

What are you talking about, what custom buff?

And also, there is no exact event for unit taking damage without using a system for it, even less for damage from spells.
 

EdgeOfChaos

E

EdgeOfChaos

Using damage detection is far better than using a formula to determine time. With DDS, you can do exactly what you want with no math or anything. And it's guaranteed to be precise.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I just realized there is a spell which throws a missile and can slow the target unit when it hits.It is called acid bomb.

Also there is drunken haze.
 

sentrywiz

S

sentrywiz

Using damage detection is far better than using a formula to determine time. With DDS, you can do exactly what you want with no math or anything. And it's guaranteed to be precise.

DDS is just bothersome to implement for one or two spells.

I just realized there is a spell which throws a missile and can slow the target unit when it hits.It is called acid bomb.

Also there is drunken haze.

You think I wouldn't have thought of that before asking the question?
The damage it deals is overtime, and I want the slow effect from it.
Even if I set the damage to be dealt in the same second as it is cast, the slow effect would only last as long.

Drunken Haze doesn't deal damage, so it would be the same as using a dummy to cast slow only in this case I'd require the same formula only to deal damage on impact.

In both cases, I need that formula to create a timer so that I can chain the effects in the best appropriate time.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
In StarCraft II this would be like 30 seconds work with the highly flexible data editor.

In WC3 sadly you only have two options.
1. Damage Detection System with some logic to detect when the fireball impacts. Even if it deals 0 damage it should still generate a damage event. When fireball is cast you enter a "waiting for impact" state where you look for a damage event with the source being the fireball caster and the amount being 0. When such an event is detected you apply your slow with a dummy. Will have problems if there can be multiple fireballs in the air from the same caster at a given time (slow projectile speed, low cooldown). There will obviously be problems if something else does 0 damage from that caster (false positive impact, only very minor problem if the missile has a high speed so maximum inaccurate time is minimal).

2. Trigger the projectile using a dummy ability like channel as a base. This removes all problem with impact detection (you decide when it impacts) but introduces the problem with all projectile systems (smooth movement, high frequency periodic code). Since the projectile homes in you can just move it X towards the target until the distance to the target is less than X which registers as an impact (assumes unlimited rotation rate).
 

sentrywiz

S

sentrywiz

In StarCraft II this would be like 30 seconds work with the highly flexible data editor.

In WC3 sadly you only have two options.
1. Damage Detection System with some logic to detect when the fireball impacts. Even if it deals 0 damage it should still generate a damage event. When fireball is cast you enter a "waiting for impact" state where you look for a damage event with the source being the fireball caster and the amount being 0. When such an event is detected you apply your slow with a dummy. Will have problems if there can be multiple fireballs in the air from the same caster at a given time (slow projectile speed, low cooldown). There will obviously be problems if something else does 0 damage from that caster (false positive impact, only very minor problem if the missile has a high speed so maximum inaccurate time is minimal).

2. Trigger the projectile using a dummy ability like channel as a base. This removes all problem with impact detection (you decide when it impacts) but introduces the problem with all projectile systems (smooth movement, high frequency periodic code). Since the projectile homes in you can just move it X towards the target until the distance to the target is less than X which registers as an impact (assumes unlimited rotation rate).

1. That's just too much work for something of a simple nature. Though, DDS is always useful.

2. This requires a dummy custom missile. I was asking for the formula if I were to use a spell like Firebolt, to calculate the time needed when the dummy unit that casts the slow so it doesn't look bad.

How is Acid Bomb invalid again? Aside from being a DoT which you have to deal with if you can't use a Buff Checker, lfh's PDDS or create a missile system.

You said it, its a dot. If I was to use it for the slow, I'd still need the same formula to calculate when to "deal" the damage.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
2. This requires a dummy custom missile. I was asking for the formula if I were to use a spell like Firebolt, to calculate the time needed when the dummy unit that casts the slow so it doesn't look bad.
There is no such formula as one could potentially bounce the projectile around indefinitely through teleportation.

The closest would be assuming the target is static (never is) it should be {distance between caster / speed of missile}. If the target moves away from the caster this will fire too soon while if the target moves towards the caster it will impact too late. You will obviously need a timer for the required timing precision.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
If you would use something to detect damage and deal damage when acid bomb hits we wouldn't need a page discussion.
 

sentrywiz

S

sentrywiz

There is no such formula as one could potentially bounce the projectile around indefinitely through teleportation.

The closest would be assuming the target is static (never is) it should be {distance between caster / speed of missile}. If the target moves away from the caster this will fire too soon while if the target moves towards the caster it will impact too late. You will obviously need a timer for the required timing precision.

The missile travels far faster than the target would be able to move. But yes, its not gonna be static.

I don't need to bounce the projectile. I need to calculate the time between two points so that when the timer for X seconds runs out, a dummy is created that will cast the slow. By that time, the missile would of surely hit the target and the slow wouldn't be applied before the hit.

If you would use something to detect damage and deal damage when acid bomb hits we wouldn't need a page discussion.

That beats the point. Surely someone around here knows how to calculate range between two points. That's all I'm asking, how to calculate the range between two points in seconds.

Nothing is easy in coding. If you don't wanna code it is easier but you're in a cage.

No nothing is. Then again, most things can be solved easily and usually such a solution is best. Occam's razor
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
I don't need to bounce the projectile. I need to calculate the time between two points so that when the timer for X seconds runs out, a dummy is created that will cast the slow. By that time, the missile would of surely hit the target and the slow wouldn't be applied before the hit.
Take the worst case, the unit is moving away at maximum speed from the caster. Most of the time it will always apply slow too late but it fulfils your requirements.
 
If you really want there is a triangle for Speed, Distance and Time.
g_dst_triangle.gif

In this case, you are looking for time. Divide distance by speed.
 

sentrywiz

S

sentrywiz

If you really want there is a triangle for Speed, Distance and Time.
g_dst_triangle.gif

In this case, you are looking for time. Divide distance by speed.

I see. That makes lot of sense.

Take the worst case, the unit is moving away at maximum speed from the caster. Most of the time it will always apply slow too late but it fulfils your requirements.

Not if there aren't a lot of speed modifiers.
 
Status
Not open for further replies.
Top