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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      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