• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Moving a unit in a line

Status
Not open for further replies.
Level 6
Joined
May 1, 2009
Messages
215
Bizarre, I must be doing something obviously wrong here... but I can't seem to figure it out.


  • Events
    • Unit - A unit begins casting an ability
  • Conditions
    • Ability equal to Line Slash
  • Actions
    • Set SlashCast = Casting Unit
    • Set SlashCastPoint = Target of point ability being cast
    • Set SlashCastedPoint = Point of Casting Unit
    • Unit - Pause SlashCast
    • Unit - Make SlashCast Invulnerable
    • Region - Center SlashRegion on SlashCastPoint
    • Trigger - Turn on Move
  • Events
    • Time - Every 0.3 seconds of game time
  • Conditions
    • SlashCast is paused Equal to True
  • Actions
    • Unit - Move SlashCast instantly to SlashCastPoint offset by (((Distance between (Center of SlashRegion and SlashCastedPoint) / 4 + 100) towards (Facing of SlashCast) degrees)
  • Evemts
    • Unit - A unit enters SlashRegion
  • Conditions
    • Unit-type of Entering Unit Equal to Dummy
    • Entering Unit is paused Equal to True
  • Actions
    • Unit - Unpause (entering unit)
    • Selection - Add Entering unit to selection for owner of entering unit
    • Unit - Make SlashCast vulnerable
    • Custom Script: call RemoveLocation(Udg_SlashCastedPoint)
    • Custom Script: call RemoveLocation(Udg_SlashCastPoint)
    • Trigger - Turn off Move

The idea of this spell is the user will move 1/4 the distance of the target point of the ability being cast every 0.3 seconds (so basically 1 second to move the distance to the target). It seems simple, but I'm probably doing something rather foolish here. Anyone care to point it out for me? I'm stumped.

For whatever reason, the caster only moves once then stays there, invulnerable and paused. Now that I think about it, perhaps it's how I'm asking it to move the unit (perhaps I need it to move with a different offeset mechanism)....
 
Level 5
Joined
Jul 14, 2008
Messages
121
So your trying to make the unit move forward to 1/4 of distance of target. Mean while being invulnerable and paused. I could make triggers for you.

Your triggers are leaking and I'm not sure to understand how is that supposed to work...

Edit: Also do you want the unit to always take same time to get to target, or use same speed ?

Edit2: Well I made some triggers for you.

  • Spell Trigger 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to [Your Spell]
    • Actions
      • Set SpellCaster = (Triggering unit)
      • Set SpellLoc[1] = (Position of SpellCaster)
      • Set SpellLoc[2] = (Target point of ability being cast)
      • Set SpellDistance = ((Distance between SpellLoc[1] and SpellLoc[2]) / 4.00)
      • Set SpellLoc[3] = (SpellLoc[1] offset by SpellDistance towards (Angle from SpellLoc[1] to SpellLoc[2]) degrees)
      • Set SpellSpeed = 10
      • Unit - Pause SpellCaster
      • Unit - Make SpellCaster Invulnerable
      • Trigger - Turn on Spell Trigger 2 <gen>
      • Custom script: call RemoveLocation(udg_SpellLoc[1])
      • Custom script: call RemoveLocation(udg_SpellLoc[2])
Second trigger is Initially Off.

  • Spell Trigger 2
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set SpellLoc[4] = (Position of SpellCaster)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between SpellLoc[4] and SpellLoc[3]) Greater than 50.00
        • Then - Actions
          • Set SpellLoc[5] = (SpellLoc[4] offset by SpellSpeed towards (Angle from SpellLoc[4] to SpellLoc[3]) degrees)
          • Unit - Move SpellCaster instantly to SpellLoc[5]
          • Custom script: call RemoveLocation(udg_SpellLoc[4])
          • Custom script: call RemoveLocation(udg_SpellLoc[5])
        • Else - Actions
          • Unit - Unpause SpellCaster
          • Unit - Make SpellCaster Vulnerable
          • Custom script: call RemoveLocation(udg_SpellLoc[3])
          • Custom script: call RemoveLocation(udg_SpellLoc[4])
          • Trigger - Turn off this trigger
It move your caster to 1/4 of target distance, with always the same speed. I didn't tested it but I think it should work, if there's any bugs or things you'd like me to change just tell me. Also, if you have any questions about the triggers, feel free to ask.

I hope it helped.
 
Last edited:
...You can also save yourself that complicated shit...

  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (your spell)
      • Caster is paused equal to true
    • Actions
      • Set Caster = (Casting unit)
      • Set Point = (Target point of ability being cast)
      • Unit - Pause Caster
      • Unit - Make Caster Invulnerable
      • Trigger - Turn on Untitled Trigger 002 <gen>
  • (Initially Off)Untitled Trigger 002
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
    • Actions
      • Unit - Make Caster face Point over 0.00 seconds
      • Unit - Move Caster instantly to ((Position of Caster) offset by 10.00 towards (Facing of Caster) degrees)
      • Region - Center (Your region) on Point
  • Untitled Trigger 003
    • Events
      • Unit - A unit enters (Your region)
    • Conditions
      • (Triggering unit) Equal to Caster
    • Actions
      • Trigger - Turn off Untitled Trigger 002 <gen>
      • Unit - Unpause Caster
      • Unit - Make Caster Vulnerable
Point is a point variable.
Caster is a unit variable.
 
Level 5
Joined
Jul 14, 2008
Messages
121
@Chief-Oblivion:
Yours leaks location every 0.3 seconds. Don't use Casting Unit, Triggering Unit is faster.

And your triggers wouldn't even work, in the conditions of your first trigger it check if variable "Caster" is paused, you define variable "Caster" after this condition. Also, your unit wouldn't be paused at this point, he is paused 3 actions after that condition.

Mines isn't complicated, all are into variables, even speed of the movement.

Edit:
@FlowerofSpeech:
If you need it to be MUI, I can make you one. This one, I don't think it's, but it doesn't leak and should work very well if it ain't casted twice at the exact same time.

Edit2:
I'm actually working on one MUI with more options. I got some free time.

Edit3:
I made new triggers for your spell, it's leak free, MUI and very easy to configure.

  • Spell Trigger 1
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set SpellHashTable = (Last created hashtable)
      • Trigger - Turn off (This trigger)
  • Spell Trigger 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to [Your Spell]
    • Actions
      • -------- SETTINGS: --------
      • -------- Unit that's going to move --------
      • Set SpellCaster = (Triggering unit)
      • -------- Position if the unit that's going to move --------
      • Set SpellLoc[1] = (Position of SpellCaster)
      • -------- Target of your spell --------
      • Set SpellLoc[2] = (Target point of ability being cast)
      • -------- Distance your going to move --------
      • Set SpellDistance = ((Distance between SpellLoc[1] and SpellLoc[2]) / 4.00)
      • -------- Location your going to move to --------
      • Set SpellLoc[3] = (SpellLoc[1] offset by SpellDistance towards (Angle from SpellLoc[1] to SpellLoc[2]) degrees)
      • -------- Animation your unit going to have during move, empty if none --------
      • Set SpellAnimation = spell
      • -------- Speed of move --------
      • Set SpellSpeed = 10.00
      • -------- Animation speed --------
      • Set SpellAnimSpeed = 100.00
      • -------- UNDER THAT NOTHING NEED TO BE CHANGED --------
      • Set SpellCount = 0
      • Hashtable - Save Handle OfSpellLoc[3] as 0 of (Key (Triggering unit)) in SpellHashTable
      • Hashtable - Save SpellAnimation as 1 of (Key (Triggering unit)) in SpellHashTable
      • Hashtable - Save SpellSpeed as 2 of (Key (Triggering unit)) in SpellHashTable
      • Hashtable - Save SpellCount as 3 of (Key (Triggering unit)) in SpellHashTable
      • Hashtable - Save SpellAnimSpeed as 4 of (Key (Triggering unit)) in SpellHashTable
      • Unit Group - Add SpellCaster to SpellGroupCaster
      • Custom script: call RemoveLocation(udg_SpellLoc[1])
      • Custom script: call RemoveLocation(udg_SpellLoc[2])
      • Custom script: call RemoveLocation(udg_SpellLoc[3])
  • Spell Trigger 3
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SpellGroupCaster and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 3 of (Key (Picked unit)) from SpellHashTable) Equal to 0
            • Then - Actions
              • Unit - Pause (Picked unit)
              • Unit - Make (Picked unit) Invulnerable
              • Animation - Play (Picked unit)'s (Load 1 of (Key (Picked unit)) from SpellHashTable) animation
              • Animation - Change (Picked unit)'s animation speed to (Load 4 of (Key (Picked unit)) from SpellHashTable)% of its original speed
              • Set SpellLoc[4] = (Position of (Picked unit))
              • Set SpellLoc[5] = (SpellLoc[4] offset by (Load 2 of (Key (Picked unit)) from SpellHashTable) towards (Angle from SpellLoc[4] to (Load 0 of (Key (Picked unit)) in SpellHashTable)) degrees)
              • Unit - Move (Picked unit) instantly to SpellLoc[5]
              • Hashtable - Save 1 as 3 of (Key (Picked unit)) in SpellHashTable
              • Custom script: call RemoveLocation(udg_SpellLoc[4])
              • Custom script: call RemoveLocation(udg_SpellLoc[5])
            • Else - Actions
              • Set SpellLoc[6] = (Position of (Picked unit))
              • Set SpellLoc[7] = (Load 0 of (Key (Picked unit)) in SpellHashTable)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between SpellLoc[6] and SpellLoc[7]) Greater than 50.00
                • Then - Actions
                  • Set SpellLoc[4] = (Position of (Picked unit))
                  • Set SpellLoc[5] = (SpellLoc[4] offset by (Load 2 of (Key (Picked unit)) from SpellHashTable) towards (Angle from SpellLoc[4] to (Load 0 of (Key (Picked unit)) in SpellHashTable)) degrees)
                  • Unit - Move (Picked unit) instantly to SpellLoc[5]
                  • Custom script: call RemoveLocation(udg_SpellLoc[4])
                  • Custom script: call RemoveLocation(udg_SpellLoc[5])
                • Else - Actions
                  • Unit Group - Remove (Picked unit) from SpellGroupCaster
                  • Animation - Reset (Picked unit)'s animation
                  • Unit - Make (Picked unit) Vulnerable
                  • Unit - Unpause (Picked unit)
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SpellHashTable
              • Custom script: call RemoveLocation(udg_SpellLoc[6])
              • Custom script: call RemoveLocation(udg_SpellLoc[7])
Hope it helped.
 
Last edited:
Level 6
Joined
May 1, 2009
Messages
215
Thanks a ton Dvoth - but I have a question. You said my original trigger would leak? Where? I mean in the first two triggers I don't have any leak removing but that's because I'm destroying everything in the final trigger (when the unit reaches the desired region). There aren't any stray points/unit groups being created inbetween, they're all being assigned to variables.
 
Level 5
Joined
Jul 14, 2008
Messages
121
Nevermind, your doesn't leak I just looked it to fast...

You can change that line in the third trigger:
  • Time - Every 0.05 seconds of game time
to:
  • Time - Every 0.04 seconds of game time
or:
  • Time - Every 0.03 seconds of game time
If you feel it ain't smooth enough.

With those triggers you can make much more then only spells, so whenever you need to make some unit slide, you can use same trigger by changing events, condition and the settings part.
If you find any bugs, tell me.
 
Level 6
Joined
May 1, 2009
Messages
215
I found a bug. If I use my spell too close to the hero (less than 50 distance) he will infinitely move back and forth (lol). It's fixable though, I'm going to make a condition that makes the spell uncastable if the user targets something that close.

But besides that, it's great! Thanks. I've never tried a "sliding" spell before, and I'm glad you got it working for me :p
 
Level 5
Joined
Jul 14, 2008
Messages
121
Ah, didn't though about that bug, make not able to target less then 200 distance. Because you spell move to 1/4 of the target distance as you asked.

Edit:
You could also change that line in the third trigger:
  • (Distance between SpellLoc[6] and SpellLoc[7]) Greater than 50.00
to:
  • (Distance between SpellLoc[6] and SpellLoc[7]) Greater than [X]
X = whatever you want it.

But your speed variable can't be higher then the X.
 
Level 5
Joined
Jul 14, 2008
Messages
121
Actually didn't took me time at all.

Just change your third trigger for:

  • Spell Trigger 3
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SpellGroupCaster and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 3 of (Key (Picked unit)) from SpellHashTable) Equal to 0
            • Then - Actions
              • Unit - Pause (Picked unit)
              • Unit - Make (Picked unit) Invulnerable
              • Animation - Play (Picked unit)'s (Load 1 of (Key (Picked unit)) from SpellHashTable) animation
              • Animation - Change (Picked unit)'s animation speed to (Load 4 of (Key (Picked unit)) from SpellHashTable)% of its original speed
              • Set SpellLoc[4] = (Position of (Picked unit))
              • Set SpellLoc[5] = (SpellLoc[4] offset by (Load 2 of (Key (Picked unit)) from SpellHashTable) towards (Angle from SpellLoc[4] to (Load 0 of (Key (Picked unit)) in SpellHashTable)) degrees)
              • Unit - Move (Picked unit) instantly to SpellLoc[5]
              • Hashtable - Save 1 as 3 of (Key (Picked unit)) in SpellHashTable
              • Custom script: call RemoveLocation(udg_SpellLoc[4])
              • Custom script: call RemoveLocation(udg_SpellLoc[5])
            • Else - Actions
              • Set SpellLoc[6] = (Position of (Picked unit))
              • Set SpellLoc[7] = (Load 0 of (Key (Picked unit)) in SpellHashTable)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between SpellLoc[6] and SpellLoc[7]) Greater than 50.00
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between SpellLoc[6] and SpellLoc[7]) Less than or equal to SpellSpeed
                    • Then - Actions
                      • Unit - Move (Picked unit) instantly to SpellLoc[7]
                    • Else - Actions
                      • Set SpellLoc[4] = (Position of (Picked unit))
                      • Set SpellLoc[5] = (SpellLoc[4] offset by (Load 2 of (Key (Picked unit)) from SpellHashTable) towards (Angle from SpellLoc[4] to (Load 0 of (Key (Picked unit)) in SpellHashTable)) degrees)
                      • Unit - Move (Picked unit) instantly to SpellLoc[5]
                      • Custom script: call RemoveLocation(udg_SpellLoc[4])
                      • Custom script: call RemoveLocation(udg_SpellLoc[5])
                • Else - Actions
                  • Unit Group - Remove (Picked unit) from SpellGroupCaster
                  • Animation - Reset (Picked unit)'s animation
                  • Unit - Make (Picked unit) Vulnerable
                  • Unit - Unpause (Picked unit)
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SpellHashTable
              • Custom script: call RemoveLocation(udg_SpellLoc[6])
              • Custom script: call RemoveLocation(udg_SpellLoc[7])
That should work, you also should be able to make speed variable higher then the X thingy.
 
Status
Not open for further replies.
Top