• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Ordering multiple units in the same region

Level 10
Joined
Jul 5, 2014
Messages
425
Something happens, you a group of units going to the same region. However, there are issues I've encountered.

1. Apparently, they're not like being ordered to the same spot and they turn around and go home when I try.

2. Being obstructed even for a moment by each other or another unit also makes them go home.

I figure I might have to send them to offset, which requires each of them to be ordered individually. Plus, I suspect offsets leak too.

So far, this is the best I could do in my testing

  • test region points Copy
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit - Order Paladin 0627 <gen> to Move To (Center of Region 189 <gen>)
      • Unit - Order Reanimated Footman 0626 <gen> to Move To ((Center of Region 189 <gen>) offset by (-150.00, -300.00))
      • Unit - Order Reanimated Footman 0616 <gen> to Move To ((Center of Region 189 <gen>) offset by (-150.00, -180.00))
      • Unit - Order Reanimated Footman 0608 <gen> to Move To ((Center of Region 189 <gen>) offset by (-150.00, -60.00))
      • Unit - Order Reanimated Footman 0600 <gen> to Move To ((Center of Region 189 <gen>) offset by (-150.00, 60.00))
Periodic event forces them not to wander back and I'm experimenting with a reasonable spacing. However, is there a less micromanaging, more efficient solution?
 
Level 27
Joined
Aug 29, 2012
Messages
1,210
Yup they certainly are. Well I tried ordering a computer footman around in a test map and he didn't seem to turn back, although I know it does happen at times. Do you have an AI script running for said player? You could try this function in any case to see if that changes anything

1720890031676.png
 
Level 10
Joined
Jul 5, 2014
Messages
425
Yup they certainly are. Well I tried ordering a computer footman around in a test map and he didn't seem to turn back, although I know it does happen at times. Do you have an AI script running for said player? You could try this function in any case to see if that changes anything

View attachment 479792
No AI script for them. Ignoring guard position did the trick, especially since these units don't need to be in combat, so there isn't issue with luring them away without guard position. The positioning is ugly because I sent everyone to the same spot but they didn't return to the starting zone and didn't stop on the way either. So, now that they're apparently obedient, they just need to spread out more. Does giving a group "random point of the region sends everyone to a random position?
 
Level 10
Joined
Jul 5, 2014
Messages
425
If you order units invidiually like you did, each would go to a random location, but if you add those in a group and issue the order to the unit group, all of them will go to a single random point
Strange. I just tested it with giving a group order and ordering them to random point. They spread out nicely, although the random point wasn't in variable.
 
Level 23
Joined
Feb 27, 2019
Messages
767
Formation? I just told all picked units to go to the random point of the region. And they spread out. They didn't even stand in formation in their original place.
Pick every unit runs in kind of a loop, each action is run for each unit so each unit gets its own random location in region. If you set the location to a variable beforehand, they will go to the same location.
 
Level 27
Joined
Aug 29, 2012
Messages
1,210
Yep it's as if you box select them yourself and issue the order. It's also why you're limited to 12 units that way, it emulates a player control group. Otherwise you'd need to use "pick every unit in unit group" to affect more than that, and they wouldn't follow the same rule

1720900928837.png
 
Level 10
Joined
Jul 5, 2014
Messages
425
Pick every unit runs in kind of a loop, each action is run for each unit so each unit gets its own random location in region. If you set the location to a variable beforehand, they will go to the same location.
And do they all leak? If so, I'm not sure if those can be patched easily.

Yep it's as if you box select them yourself and issue the order. It's also why you're limited to 12 units that way, it emulates a player control group. Otherwise you'd need to use "pick every unit in unit group" to affect more than that, and they wouldn't follow the same rule

View attachment 479802
I used pick all units, not ordering the group like your screenshot.
 
Level 23
Joined
Feb 27, 2019
Messages
767
And do they all leak? If so, I'm not sure if those can be patched easily.
For each unit that is picked and ordering it to move to "Random point in" it leaks a location. In this case its super easy though. Set the location before Pick every unit. Use the location within Pick every unit. Remove the location after Pick every unit.

If you instead wanted each unit to move to a random location youd simply set the location within the Pick every unit and remove it at after use within Pick every unit. Its equally easy.
 
Level 10
Joined
Jul 5, 2014
Messages
425
For each unit that is picked and ordering it to move to "Random point in" it leaks a location. In this case its super easy though. Set the location before Pick every unit. Use the location within Pick every unit. Remove the location after Pick every unit.

If you instead wanted each unit to move to a random location youd simply set the location within the Pick every unit and remove it at after use within Pick every unit. Its equally easy.
Isn't setting the location makes it into only one point? I'm a little confused how it works.
 
Level 23
Joined
Feb 27, 2019
Messages
767
Isn't setting the location makes it into only one point? I'm a little confused how it works.
Yes. A point variable can only be one location at a time. I think the confusion comes from how you are visually seeing the function Unit Group - Pick every unit in...and do actions. What this function does it Pick every units, lets say its 5 units and it runs the actions 5 times because 5 units were picked. The action doesnt run 1 time for all 5 units. It runs 5 times independently for all 5 units. Does that make sense?

So to easily understand...
Pick every unit picks 2 units
Order unit 1 to move to random point in region
Order unit 2 to move to random point in region

Pick every unit picks 5 units
Order unit 1 to move to random point in region
Order unit 2 to move to random point in region
Order unit 3 to move to random point in region
Order unit 4 to move to random point in region
Order unit 5 to move to random point in region

Now understand that "random point in region" is a function. So it sets a new random point each time its run. If you instead did this, they would all move to the same location:
set Point = random point in region
Pick every unit picks 5 units
Order unit 1 to move to Point
Order unit 2 to move to Point
Order unit 3 to move to Point
Order unit 4 to move to Point
Order unit 5 to move to Point
 
Level 23
Joined
Feb 27, 2019
Messages
767
So I was thinking right. With variable, it marks only one random point. Which is bad for me because I want all units go to a different random point in the region.
Its no problem at all. I suppose we are talking about removing leaks here. Set the variable to random point in... within the Pick every unit actions. Remove the location after its used within the Pick every unit actions.

  • Unit Group - Pick every unit in TempGroup and do (Actions)
    • Loop - Actions
      • Set VariableSet TempPoint = (Random point in (Playable map area))
      • Unit - Order (Picked unit) to Move To TempPoint
      • Custom script: call RemoveLocation(udg_TempPoint)
 
Last edited:
Level 10
Joined
Jul 5, 2014
Messages
425
Its no problem at all. I suppose we are talking about removing leaks here. Set the variable to random point in... within the Pick every unit actions. Remove the location after its used within the Pick every unit actions.

  • Unit Group - Pick every unit in TempGroup and do (Actions)
    • Loop - Actions
      • Set VariableSet TempPoint = (Random point in (Playable map area))
      • Unit - Order (Picked unit) to Move To TempPoint
      • Custom script: call RemoveLocation(udg_TempPoint)
So, that way, there are multiple points and multiple leak removals at once?
 
Level 10
Joined
Jul 5, 2014
Messages
425
Pretty much but the general terminology of "at once" is not correct but functionally thats what it is. Thats because several code doesnt run "at once". It runs one after another.
I didn't mean it as in "the same time" but doing it all with a single action. I didn't know that putting it into a group action applies it to everyone and multiple points can be removed with a single script.
 
Level 23
Joined
Feb 27, 2019
Messages
767
I didn't mean it as in "the same time" but doing it all with a single action. I didn't know that putting it into a group action applies it to everyone and multiple points can be removed with a single script.
Yeah, so Pick every unit and do action does it with a single action because the action repeats for every unit that is picked.
 
Level 10
Joined
Jul 5, 2014
Messages
425
Yeah, so Pick every unit and do action does it with a single action because it repeats for all units that are picked.
Well, true. That case is probably the only one when I relied on random point instead of center. Seems to be working as intended, so thank you.

Edit: Unfortunately, units ordered to move sometimes stop before reaching their points and once they didn't even stop their original orders, despite they were issued a stop order before moving to the location.
 
Last edited:
Top