• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Time taken between spell cast and hit

Status
Not open for further replies.
Level 7
Joined
Dec 8, 2008
Messages
243
Is there anyway to determine the time taken for a spell to hit a target? I've a spell which once cast deals damage, even before the missile collides with the target and am looking for a way around this, please advise. :pmeh:

[Edit] Perhaps there's a math sum which involves dividing missile speed with distance between caster and target unit of ability being cast?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
This does not work for all spells. Some like cluster rockets (goblin tinker) seem to use a constant for distance so have a constant landing time even if the target is directly infront of the caster or the other side of the map.

You will have to use timers as TriggerSleepAction (wait in GUI) is not accurate enough in multiplayer (its delays very in multiplayer due to it creating net traffic).

Alternativly you could create your own projectile system like many spells use which lets you get when a missle hits. Many premade ones do exist as well.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
This is a blurry idea for the problem (as told by sPy and DSG, to use Wait function)
  • Wait ((Distance between (Position of *YourUnit*) and (Position of *YourEnemyUnit*))) / 1000.00) seconds
The basic formula is Time = Distance / Speed
Let's say the missile speed of the projectile is 1000
The distance is varied, Time will also be varied, only Speed, remains constant
So, let's say our unit and the enemy is distanced by 700, the Time that the projectile will hit the enemy is, 700 (Distance) / 1000 (Speed) = 0.7 second (Time)
It will take about 0.7 second before the projectile is hit
I've attached a test map where you can see the use of this idea, take a look at it
Check the "PN Start" trigger on Trigger Editor
I added a subtract of 0.10 second to adjust the perfect timing on the missile
But be warned, it is buggy because Wait action is NOT MUI
 

Attachments

  • Lady Emily.w3x
    19.3 KB · Views: 32
Level 20
Joined
Jul 6, 2009
Messages
1,885
But be warned, it is buggy because Wait action is NOT MUI

Wait function is MUI :eek:
However,it can cause a spell not to be MUI if used improperly.

Few other ways you could achieve this:
  • When spell is casted create a dummy unit...anywhere; Add an expiration timer of Distance / Missle speed; Save the target in hashtable with dummy handle id as parrent key; check when the dummy dies and apply effect.
  • Create a damage detection system. Whenever you cast a spell (the main spell wouldn't have effect) create a dummy on caster's location which would cast a spell with an effect on the target. When a unit takes damage with damage source being dummy,apply the effect.
  • Trigger the projectile as said above.
 
Status
Not open for further replies.
Top