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.
  • 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 The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top