1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  4. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Moving Projectiles

Discussion in 'World Editor Help Zone' started by hdm, Sep 1, 2012.

  1. hdm

    hdm

    Joined:
    Nov 19, 2011
    Messages:
    384
    Resources:
    0
    Resources:
    0
    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 ?
     
  2. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    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.
     
  3. hdm

    hdm

    Joined:
    Nov 19, 2011
    Messages:
    384
    Resources:
    0
    Resources:
    0
    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
     
  4. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    Start at 20 and adjust it from there.

    The projectile speed is 3% of what warcraft speed is - e.g. if an archer fires an arrow at 1800 speed, multiple 1800 by 0.03 to see what speed you want.
     
  5. hdm

    hdm

    Joined:
    Nov 19, 2011
    Messages:
    384
    Resources:
    0
    Resources:
    0
    hmm,it still hard to understand.Er...can you post the map here ?
     
  6. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    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)
     
  7. Elfansoer

    Elfansoer

    Joined:
    Aug 26, 2012
    Messages:
    122
    Resources:
    0
    Resources:
    0
    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)

    )
     
  8. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,846
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    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)
     
  9. Elfansoer

    Elfansoer

    Joined:
    Aug 26, 2012
    Messages:
    122
    Resources:
    0
    Resources:
    0
    Er.. Edo494, what do you mean?
    (I still don't understand where the leaks...)
     
  10. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,846
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    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
     
  11. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    edo494, I agree that a movement system in component form is superior, but you must keep in mind that the OP of this thread wants a simple system to understand how it works.

    To this end, Elfansoer's trigger would be the first logical step. The next step of course to clean up leaks, then MUI eventually.
     
  12. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,846
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    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
     
  13. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    Component method advantages:
    • Less CPU intensive; hence more particles supported at a time
    • Easier to calculate changes in trajectory
    • SetUnitX/Y doesn't interrupt unit orders
     
  14. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,846
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    "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