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

Moving Projectiles

Status
Not open for further replies.

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
Can you show me a basic tigger that shows how to move dummies projectiles.Because I have problems understanding how the HW's guys can use that tigger "Move unit instantly to..." not being instantly.

And can you please show one created by you,not getting from the Spells Section ?
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
The idea is that if you move something instantly, but many times in one second to give the illusion of movement.

Here's a basic trigger to move one dummy unit:
  • Loop Dummy
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set tempLocation = (Position of ProjectileUnit)
      • Set tempLocation2 = (tempLocation offset by ProjectileSpeed towards (Facing of ProjectileUnit) degrees)
      • Unit - Move ProjectileUnit instantly to tempLocation2
      • Custom script: call RemoveLocation(udg_tempLocation)
      • Custom script: call RemoveLocation(udg_tempLocation2)
You'll have to set ProjectileUnit and ProjectileSpeed in another trigger, and this trigger only works for one unit, but it gives the basic idea.
 

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
What COuld be projectile speed ?I understood all the rest, but i'm missing projectile speed.Give me some idea of how should be it
 

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
hmm,it still hard to understand.Er...can you post the map here ?
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Would this make it simpler:

  • Loop Dummy
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set tempLocation = (Position of Footman 0001)
      • Set tempLocation2 = (tempLocation offset by 25 towards (Facing of Footman 0001) degrees)
      • Unit - Move Footman 0001 instantly to tempLocation2
      • Custom script: call RemoveLocation(udg_tempLocation)
      • Custom script: call RemoveLocation(udg_tempLocation2)
 
Level 4
Joined
Aug 26, 2012
Messages
123
Just wanna explains what rulerofiron means...

The projectile speed on Object editor is self explaining, right?
(If you don't understand, it means "how many points (length) it passed for one second". You know that, right?)

The projectile speed on trigger is more or less the same basic as above, as "how many points (templocation2_variable) it passed for periodic time (0.03 seconds)"...
The rulerofiron's speed is 25 point per 0.03 second. And for one second... do the math!
(Which is means you can set your dummy's speed each second by:
///templocation2 = speed_var = projectile_speed * periodic_time///

So, in rulerofiron's trigger:
  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
    • Unit - Move (unitx) instantly to ((position of (unitx)) offset by speed_var towards (facing of (unitx) degrees)
)
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
So, in rulerofiron's trigger:
  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
    • Unit - Move (unit) instantly to ((position of (unit)) offset by speed_var towards (facing of (unitx) degrees)

except he has no leaks, you have 2 point leaks every 0.03 second = gf map

the faster way of doing it is:
  • Actions
    • Custom script: call SetUnitX(udg_projectile, GetUnitX(udg_projectile) + udg_distance * Cos(udg_angle * bj_DEGTORAD))
    • Custom script: call SetUnitY(udg_projectile, GetUnitY(udg_projectile) + udg_distance * Sin(udg_angle * bj_DEGTORAD))
in which:
udg_projectile is unit variable of name projectile, udg_distance is real variable of name distance(per one interval, this can be for instance 100*0.03 if you want the projectile to go 100 away every 1 second) and udg_angle is real variable of name angle, in this case
  • Set angle = (Facing of projectile)
the * bj_DEGTORAD part is there because the angles in GUI are in degrees but in Jass they are radians(blizzards trolling has no limitations)
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
    • Unit - Move (unitx) instantly to ((position of (unitx)) offset by speed_var towards (facing of (unitx) degrees)

whenever this function is called, you create new location which points to the position of unitx as well as location which points to the coordinates at position of unitx offseted by speedvar towards some degrees.
Those handles are not recyclated and so you will keep them. Location(point in GUI) leaks are amongst the biggest ones in Wc3
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
well, I actually dont think my way is really that better in this case, this is projectile, the thing I have wrote is PolarProjection which is more usefull when moving units while not cancelling order, but projectile most likely wont have any order so your one is good and easy to understand I agree :D
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
"mine" is better yes but its harder to understand for new people and it would be even better if I preset the Cos and Sin to some variable because those takes shit load of time and memory to calculate(as well as things like Pow) and it looks like the projectile goes in one direction so its constant
 
Status
Not open for further replies.
Top