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

How to make a unit never stop moving

Status
Not open for further replies.
Level 12
Joined
Jun 15, 2016
Messages
472
How do you control it? WSAD/arrow keys/mouse?

If it's by mouse I'd create two triggers:

1. When the unit is issued an order at point, the trigger will save the point and run the second trigger. It will also disable the second trigger at the beginning so your unit will have only one movement trigger active on it.
2. Whenever the unit gets close to the point saved in the first trigger, calculate a new point further away from your unit and order it to go there.

This isn't perfect, and one cliff in the unit's way will change its direction, but it's a start.
 
Level 8
Joined
Jul 29, 2010
Messages
319
How do you control it? WSAD/arrow keys/mouse?

If it's by mouse I'd create two triggers:

1. When the unit is issued an order at point, the trigger will save the point and run the second trigger. It will also disable the second trigger at the beginning so your unit will have only one movement trigger active on it.
2. Whenever the unit gets close to the point saved in the first trigger, calculate a new point further away from your unit and order it to go there.

This isn't perfect, and one cliff in the unit's way will change its direction, but it's a start.
Thank you, i was originally thinking something along the lines of having a region constantly infront of the unit, when the unit is issued an order targeting a point or object, the region moves to the position of the order until the unit enters the region then the first trigger kicks in and moves the region ahead of the unit again ordering the unit to follow the region, will this work?, i will try your idea first though
 
Level 8
Joined
Jul 29, 2010
Messages
319
How do you control it? WSAD/arrow keys/mouse?

If it's by mouse I'd create two triggers:

1. When the unit is issued an order at point, the trigger will save the point and run the second trigger. It will also disable the second trigger at the beginning so your unit will have only one movement trigger active on it.
2. Whenever the unit gets close to the point saved in the first trigger, calculate a new point further away from your unit and order it to go there.

This isn't perfect, and one cliff in the unit's way will change its direction, but it's a start.
how do i make it so that when a unit reaches a point it chooses a new position further away but still inline with it's original course, blizzards Worm scenario does it perfectly but i do not know how to use their triggers with my own map.
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
  • Events
    • Unit - A unit is issued an order targeting a unit
    • -------- Basically make nearly identical triggers for both types of orders --------
    • Unit - A unit is issued an order targeting a point
  • Conditions
    • Unit type of (Triggering unit) equal to <your unit>
    • Or - Any Conditions
      • (Issued Order) equal to attack
      • (Issued Order) equal to move
      • (Issued Order) equal to smart
  • Actions
    • If (All conditions) then (actions) else (actions)
      • If - Conditions
        • (Triggering unit) is in MoveGroup equal to false
      • Then - Actions
        • Unit Group - Add (Triggering Unit) to MoveGroup
      • Else - Actions
    • Set TempPoint1 = Position of (Triggering unit)
    • Set TempPoint2 = Target position of issued order
    • Hashtable - Save (Angle between TempPoint1 and TempPoint2) as MoveAngle of (Handle ID of (Triggering Unit)) in YourHashTable
    • -------- Might not have written that right, but store the angle to the target under the handle ID of the triggering unit in the hash table --------
    • Custom script: call RemoveLocation(TempPoint1)
    • Custom script: call RemoveLocation(TempPoint2)
  • Events
    • Unit - A unit is issued an order with no target
  • Conditions
    • Unit type of (Triggering unit) equal to <your unit>
    • Or - Any Conditions
      • (Issued Order) equal to stop
      • (Issued order) equal to holdposition
  • Actions
    • Unit Group - Remove (Triggering Unit) from MoveGroup
  • Events
    • Every 0.50 seconds of game-time
  • Conditions
  • Actions
    • Trigger - Turn off YourOnPointOrUnitOrderTriggers <gen>
    • Trigger - Turn off BothOfThem <gen>
    • Unit Group - Pick every unit in MoveGroup and do Actions
      • Loop - Actions
        • Set TempPoint1 = Position of (Picked Unit)
        • Set TempPoint2 = TempPoint1 offset by MOVE_OFFSET toward (Hashtable - Load MoveAngle of (Handle ID of (Picked Unit)) from YourHashTable) degrees)
        • Unit - Order (Picked Unit) to move to TempPoint2
        • Custom script: call RemoveLocation(TempPoint1)
        • Custom script: call RemoveLocation(TempPoint2)
    • Trigger - Turn on YourOnPointOrUnitOrderTriggers <gen>
    • Trigger - Turn on BothOfThem <gen>
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set YourHashTable = New Hashtable
 
Last edited:
Status
Not open for further replies.
Top