Here you go:
Old trigger
trigger
Dummies in Square
Events
Time - Elapsed game time is 2.00 seconds
Conditions
Actions
-------- --------------------------------------------- --------
-------- DEFINE VARIABLES --------
-------- --------------------------------------------- --------
-------- Center of the square --------
Set TempLoc1 = (Center of Rect 016 <gen>)
-------- Replace 256 with how far away from the center do you wan the sides to be --------
Set TempReal1 = 256.00
-------- Number of units per side --------
Set TempInt = 4
-------- --------------------------------------------- --------
-------- DO THE THINGIES --------
-------- --------------------------------------------- --------
-------- Upper right corner of the square --------
Set TempLoc2 = (TempLoc1 offset by (TempReal1, TempReal1))
-------- Calculate distance between units --------
Set TempReal1 = (2.00 x (TempReal1 / (Real((TempInt - 1)))))
-------- Create upper row --------
For each (Integer A) from 1 to (TempInt - 1), do (Actions)
Loop - Actions
Set TempLoc2 = (TempLoc2 offset by ((-1.00 x TempReal1), 0.00))
Unit - Create 1 Footman for Player 1 (Red) at TempLoc2 facing Default building facing (270.0) degrees
-------- Create left side --------
For each (Integer A) from 1 to (TempInt - 1), do (Actions)
Loop - Actions
Set TempLoc2 = (TempLoc2 offset by (0.00, (-1.00 x TempReal1)))
Unit - Create 1 Footman for Player 1 (Red) at TempLoc2 facing Default building facing (270.0) degrees
-------- Crete lower row --------
For each (Integer A) from 1 to (TempInt - 1), do (Actions)
Loop - Actions
Set TempLoc2 = (TempLoc2 offset by (TempReal1, 0.00))
Unit - Create 1 Footman for Player 1 (Red) at TempLoc2 facing Default building facing (270.0) degrees
-------- Create right side --------
For each (Integer A) from 1 to (TempInt - 1), do (Actions)
Loop - Actions
Set TempLoc2 = (TempLoc2 offset by (0.00, TempReal1))
Unit - Create 1 Footman for Player 1 (Red) at TempLoc2 facing Default building facing (270.0) degrees
Custom script: call RemoveLocation(udg_TempLoc1)
Custom script: call RemoveLocation(udg_TempLoc2)
EDIT:
Here's more sophisticated version:
Units in Square
Events
Time - Elapsed game time is 2.00 seconds
Conditions
Actions
-------- DEFINE VARIABLES --------
-------- Center of the square --------
Set TempLoc1 = (Center of Rect 022 <gen>)
-------- Replace 256 with how far away from the center do you wan the sides to be --------
Set TempReal1 = 256.00
-------- Number of units per side --------
Set TempInt = 4
-------- -------------------------------- --------
-------- DO THE THINGIES --------
Set TempLoc2 = (TempLoc1 offset by (TempReal1, TempReal1))
Set TempReal2 = (2.00 x (TempReal1 / (Real((TempInt - 1)))))
Custom script: call RemoveLocation(udg_TempLoc1)
For each (Integer A) from 1 to TempInt, do (Actions)
Loop - Actions
For each (Integer B) from 1 to TempInt, 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
((1.00 - (Real((Integer A)))) x TempReal2) Equal to 0.00
((1.00 - (Real((Integer A)))) x TempReal2) Equal to (-2.00 x TempReal1)
((1.00 - (Real((Integer B)))) x TempReal2) Equal to 0.00
((1.00 - (Real((Integer B)))) x TempReal2) Equal to (-2.00 x TempReal1)
Then - Actions
Set TempLoc1 = (TempLoc2 offset by (((1.00 - (Real((Integer A)))) x TempReal2), ((1.00 - (Real((Integer B)))) x TempReal2)))
Unit - Create 1 Footman for Player 1 (Red) at TempLoc1 facing Default building facing (270.0) degrees
Custom script: call RemoveLocation(udg_TempLoc1)
Else - Actions
Custom script: call RemoveLocation(udg_TempLoc2)
Should be easy enough to edit.
Though you might still want to use your own variables instead of ForLoopA and ForLoopB, since they may clash with other triggers.
Last edited: Aug 17, 2009