Unit Formation Trigger

Edward

New Member
Reaction score
2
Ok, so I want 12 units to line up in a vertical line. Here is what I have, why doesn't it work (Ignore memory leaks atm).

As of right now, they simply move to some far off point without lining up at all. The only thing that does work is that they move south (270 degrees).

Trigger:
  • Verticle Line
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units currently selected by Player 1 (Red)) and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 12, do (Actions)
            • Loop - Actions
              • Set FormVertRed[(Integer A)] = (Picked unit)
              • Unit - Turn collision for FormVertRed[(Integer A)] Off
              • Unit - Move FormVertRed[(Integer A)] instantly to ((Position of FormVertRed[1]) offset by (75.00 x (Real((Integer A)))) towards 270.00 degrees), facing 0.00 degrees


But it's still not perfect. The problem here is that it picks random units, thus does not exclude units it already picked.

I got about 9 footmen to line up once.

Trigger:
  • Verticle Line
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set FormVertRed[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for FormVertRed[(Integer A)] Off
          • Unit - Move FormVertRed[(Integer A)] instantly to ((Position of FormVertRed[1]) offset by (75.00 x (Real((Integer A)))) towards 270.00 degrees), facing 0.00 degrees


Here's a better trigger than the last two. I'll draw a Diagram (horizontally) of how they lined up.

XX XXXX XX X

The other three didn't move at all because they weren't "randomly" selected.

Trigger:
  • Verticle Line
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set FormVertRedFulcrum = (Random unit from FormVertRedGroup)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set FormVertRed[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for FormVertRed[(Integer A)] Off
          • Unit - Move FormVertRed[(Integer A)] instantly to ((Position of FormVertRedFulcrum) offset by (75.00 x (Real((Integer A)))) towards 270.00 degrees), facing 0.00 degrees
 

crabbb622

New Member
Reaction score
9
There are many solutions to this.

You can keep an array of what units have been selected and check that array every time you try to get a random unit, and then get a different random unit if it's already chosen.

You can pre-scramble your list of units by doing x = random integer from 1 to 12...if keeptrack[1, 2, 3, 4...] does not equal x...Set FormVertRed[x] = Picked Unit...Set keeptrack[index] = x
 

Edward

New Member
Reaction score
2
I might

I think I can figure it out from your instructions, better to learn on your own, give me 15 - 20 minutes before telling me the answer.

:)
 

Edward

New Member
Reaction score
2
It doesn't work

I believe I followed your directions wrong because it doesn't work at all. My first one works better.

Trigger:
  • Verticle Line Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set FormVertRedFulcrum = (Random unit from FormVertRedGroup)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set x = (Random integer number between 1 and 12)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • keeptrackx[(Integer A)] Not equal to x
            • Then - Actions
              • Set FormVertRed[(Integer A)] = (Random unit from FormVertRedGroup)
              • Unit - Turn collision for FormVertRed[x] Off
              • Unit - Move FormVertRed[x] instantly to ((Position of FormVertRedFulcrum) offset by (75.00 x (Real(x))) towards 270.00 degrees), facing 0.00 degrees
              • Set keeptrackx[(Integer A)] = x
            • Else - Actions
              • Set x = (Random integer number between 1 and 12)
 

Silver

New Member
Reaction score
21
Not sure, but you might want to add a Trigger - Run this Trigger (Ignoring Conditions) to the Else - Actions (after the "Set x = (Random integer number between 1 and 12)" of course
 

Edward

New Member
Reaction score
2
This trigger works better than the rest

but is still not perfect.

The else action need to be "repeat entire loop"

Trigger:
  • Verticle Line Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set FormVertRedFulcrum = (Random unit from FormVertRedGroup)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set x = (Random integer number between 1 and 12)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • keeptrackx[1] Not equal to x
              • keeptrackx[2] Not equal to x
              • keeptrackx[3] Not equal to x
              • keeptrackx[4] Not equal to x
              • keeptrackx[5] Not equal to x
              • keeptrackx[6] Not equal to x
              • keeptrackx[7] Not equal to x
              • keeptrackx[8] Not equal to x
              • keeptrackx[9] Not equal to x
              • keeptrackx[10] Not equal to x
              • keeptrackx[11] Not equal to x
              • keeptrackx[12] Not equal to x
            • Then - Actions
              • Set FormVertRed[x] = (Random unit from FormVertRedGroup)
              • Unit - Turn collision for FormVertRed[x] Off
              • Unit - Move FormVertRed[x] instantly to ((Position of FormVertRedFulcrum) offset by (75.00 x (Real(x))) towards 270.00 degrees), facing 0.00 degrees
              • Set keeptrackx[(Integer A)] = x
            • Else - Actions
              • Do nothing
 

AoW_Hun7312

I'm a magic man, I've got magic hands.
Reaction score
76
Trigger:
  • Verticle Line
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Set FormVertGroup = (Units currently selected by (Triggering player))
      • Set VertTrack = 0
      • Unit Group - Pick every unit in FormVertGroup and do (Actions)
        • Loop - Actions
          • Set VertTrack = (VertTrack + 1)
          • Set VertUnit[VertTrack] = (Picked unit)
      • For each (Integer A) from 1 to (Number of units in FormVertGroup), do (Actions)
        • Loop - Actions
          • Set VertUPoint = (Position of VertUnit[(Integer A)])
          • Set VertPoint = (VertUPoint offset by 75.00 towards 270.00 degrees)
          • Unit - Turn collision for VertUnit[(Integer A)] Off
          • Unit - Order VertUnit[(Integer A)] to Move To VertPoint
          • Custom script: call RemoveLocation(udg_VertUPoint)
          • Custom script: call RemoveLocation(udg_VertPoint)
      • Custom script: call DestroyGroup(udg_FormVertGroup)


Works perfectly, but the formula for the VertUPoin and VertPoint (for verticle line) is messed up.
 

Edward

New Member
Reaction score
2
This works?

Trigger:
  • Verticle Line
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Set FormVertGroup = (Units currently selected by (Triggering player))
      • Set VertTrack = 0
      • Unit Group - Pick every unit in FormVertGroup and do (Actions)
        • Loop - Actions
          • Set VertTrack = (VertTrack + 1)
          • Set VertUnit[VertTrack] = (Picked unit)
      • For each (Integer A) from 1 to (Number of units in FormVertGroup), do (Actions)
        • Loop - Actions
          • Set VertUPoint = (Position of VertUnit[(Integer A)])
          • Set VertPoint = (VertUPoint offset by 75.00 towards 270.00 degrees)
          • Unit - Turn collision for VertUnit[(Integer A)] Off
          • Unit - Order VertUnit[(Integer A)] to Move To VertPoint
          • Custom script: call RemoveLocation(udg_VertUPoint)
          • Custom script: call RemoveLocation(udg_VertPoint)
      • Custom script: call DestroyGroup(udg_FormVertGroup)


Works perfectly, but the formula for the VertUPoin and VertPoint (for verticle line) is messed up.

I'm currently on a different computer with no World Editor, does this work?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top