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

Unit Group - Order Move

Status
Not open for further replies.
Level 5
Joined
Mar 24, 2020
Messages
80
Hi guys,

Can someone help me create a trigger that picks every unit in a group, creates a point variable (for each unit) and then issues each individual the order to attack move?

I've managed to get them to target a single point, but I need a loop or something that recreates the random location for each unit in a way that it doesn't leak.

The below works, but obviously has the location leak.

  • Refresh
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Player 11 (Dark Green) matching ((Issued order) Equal to (Order(stop))).) and do (Unit - Order (Picked unit) to Attack-Move To (Random point in (Playable map area)))
I can remove the location leak with the below, but it sends all units in the group to the same location.
  • Refresh
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Set VariableSet SpawnLocation = (Random point in (Playable map area))
      • Unit Group - Pick every unit in (Units owned by Player 11 (Dark Green) matching ((Issued order) Equal to (Order(stop))).) and do (Unit - Order (Picked unit) to Attack-Move To (Spawn Location)
      • Custom script: call RemoveLocation(udg_SpawnLocation)
 
Level 24
Joined
Feb 28, 2007
Messages
3,480
If you think about it, you are setting the location before ordering every unit to attack-move to said location.
In a nutshell: You are not setting a unique location per picked unit.

You'll probably want to do something like this:
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units owned by Player 11 (Dark Green).) and do (Actions)
      • Loop - Actions
        • Set VariableSet Point = (Random point in (Playable map area))
        • Unit - Order (Picked unit) to Attack-Move To Point
        • Custom script: call RemoveLocation(udg_Point)
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
If you think about it, you are setting the location before ordering every unit to attack-move to said location.
In a nutshell: You are not setting a unique location per picked unit.

You'll probably want to do something like this:
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units owned by Player 11 (Dark Green).) and do (Actions)
      • Loop - Actions
        • Set VariableSet Point = (Random point in (Playable map area))
        • Unit - Order (Picked unit) to Attack-Move To (Center of (Playable map area))
        • Custom script: call RemoveLocation(udg_Point)
Just so others don't get confused, you forgot to change (Center of (Playable map area)) to Point in your example.
 
Level 5
Joined
Mar 24, 2020
Messages
80
Sorry for the bump - I've tried to update this trigger so it work's better.
I am trying to create a unit group - all units owned by all players in a player group where the units current order is stop. However that order doesn't seem to like being detected. The trigger works if it is 'current order is not attack', but ideally I want the timer to be every 5 seconds and only reassigns orders to units that have reached the random point they are walking towards.

Works
  • Reassign Orders
    • Events
      • Time - ReassignOrdersTimer expires
    • Conditions
    • Actions
      • Player Group - Pick every player in UndeadForces and do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Issued order) Not equal to (Order(attack))).) and do (Actions)
            • Loop - Actions
              • Set VariableSet AttackPoint = (Random point in MapCorners[(Random integer number between 1 and 4)])
              • Unit - Order (Picked unit) to Attack-Move To AttackPoint
              • Custom script: call RemoveLocation(udg_AttackPoint)
      • Countdown Timer - Start ReassignOrdersTimer as a One-shot timer that will expire in 60.00 seconds
Doesn't work
  • Reassign Orders
    • Events
      • Time - ReassignOrdersTimer expires
    • Conditions
    • Actions
      • Player Group - Pick every player in UndeadForces and do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Issued order) Equal to (Order(stop))).) and do (Actions)
            • Loop - Actions
              • Set VariableSet AttackPoint = (Random point in MapCorners[(Random integer number between 1 and 4)])
              • Unit - Order (Picked unit) to Attack-Move To AttackPoint
              • Custom script: call RemoveLocation(udg_AttackPoint)
      • Countdown Timer - Start ReassignOrdersTimer as a One-shot timer that will expire in 5.00 seconds
Any thoughts welcomed.

Thank you.
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
You want to check their CURRENT ORDER not their Issued Order. The "stand down" order is useful for getting idle units.
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units owned by (Picked player).) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Or - Any (Conditions) are true
              • Conditions
                • (Current order of (Picked unit)) Equal to (Order(stand down))
                • (Current order of (Picked unit)) Equal to (Order(hold position))
                • (Current order of (Picked unit)) Equal to (Order(stop))
          • Then - Actions
          • Else - Actions
Issued order is used in response to these Events:
  • Untitled Trigger 002
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(stop))
    • Actions
 
Level 5
Joined
Mar 24, 2020
Messages
80
You want to check their CURRENT ORDER not their Issued Order. The "stand down" order is useful for getting idle units.
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units owned by (Picked player).) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Or - Any (Conditions) are true
              • Conditions
                • (Current order of (Picked unit)) Equal to (Order(stand down))
                • (Current order of (Picked unit)) Equal to (Order(hold position))
                • (Current order of (Picked unit)) Equal to (Order(stop))
          • Then - Actions
          • Else - Actions
Issued order is used in response to these Events:
  • Untitled Trigger 002
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(stop))
    • Actions

I understand! I will have a play with those different order strings and see how it goes!
This will really improve the system on my map. Thanks again, Uncle!
 
Level 5
Joined
Mar 24, 2020
Messages
80
This is the working final version. "Stop" didn't work. "Stand Down" worked but caused units every 2 seconds to go to the new location.

  • Reassign Orders
    • Events
      • Time - ReassignOrdersTimer expires
    • Conditions
    • Actions
      • Player Group - Pick every player in UndeadForces and do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching (((Current order of (Matching unit)) Not equal to (Order(move))) and ((Current order of (Matching unit)) Not equal to (Order(attack)))).) and do (Actions)
            • Loop - Actions
              • Set VariableSet AttackPoint = (Random point in MapCorners[(Random integer number between 1 and 4)])
              • Unit - Order (Picked unit) to Attack-Move To AttackPoint
              • Custom script: call RemoveLocation(udg_AttackPoint)
      • Countdown Timer - Start ReassignOrdersTimer as a One-shot timer that will expire in 2.00 seconds
 
Status
Not open for further replies.
Top