Before anyone says, yes I do know there is a Squad System on this site. I would use it but for some reason my World Editor doesn't accept the script.
Anyway, for some reason my Squad System attempt works for the first unit squad created, but doesn't work on the next lot, although it does deselect the units that aren't Squad Leader.
3 Variables being used, Num (Integer, default value of 1), Squad (Unit Group Array) and TempGroup (Unit Group).
I've figured that the problem is caused by the custom value of the Squad Leaders past the 1 Squad not being set. I'd like to know why this is so and how I can fix it. +rep to anyone that can help.
Anyway, for some reason my Squad System attempt works for the first unit squad created, but doesn't work on the next lot, although it does deselect the units that aren't Squad Leader.
Code:
Unit Created
Events
Unit - A unit Finishes training a unit
Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of (Trained unit)) Equal to Conscript
Actions
Set TempPoint = (Position of (Triggering unit))
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit - Create 1 (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at TempPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to TempGroup
Unit Group - Order TempGroup to Attack-Move To (Rally-Point of (Triggering unit) as a point)
Unit Group - Pick every unit in TempGroup and do (Unit - Add classification of Summoned to (Picked unit))
Unit Group - Add (Trained unit) to Squad[Num]
Unit Group - Add all units of TempGroup to Squad[Num]
Unit Group - Pick every unit in Squad[Num] and do (Unit - Set the custom value of (Picked unit) to Num)
Set Num = (Num + 1)
Unit Group - Remove all units from TempGroup
Code:
Selected
Events
Player - Player 1 (Red) Selects a unit
Player - Player 2 (Blue) Selects a unit
Player - Player 3 (Teal) Selects a unit
Player - Player 4 (Purple) Selects a unit
Player - Player 5 (Yellow) Selects a unit
Player - Player 6 (Orange) Selects a unit
Player - Player 7 (Green) Selects a unit
Player - Player 8 (Pink) Selects a unit
Player - Player 9 (Gray) Selects a unit
Player - Player 10 (Light Blue) Selects a unit
Player - Player 11 (Dark Green) Selects a unit
Player - Player 12 (Brown) Selects a unit
Conditions
((Triggering unit) is Summoned) Equal to True
Actions
Selection - Remove (Triggering unit) from selection for (Triggering player)
Unit Group - Pick every unit in Squad[(Custom value of (Triggering unit))] and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) is Summoned) Equal to False
Then - Actions
Selection - Add (Picked unit) to selection for (Triggering player)
Else - Actions
Code:
Move Squad
Events
Unit - A unit Is issued an order targeting an object
Unit - A unit Is issued an order targeting a point
Unit - A unit Is issued an order with no target
Conditions
(Custom value of (Ordered unit)) Greater than 0
((Ordered unit) is Summoned) Equal to False
Actions
Unit Group - Pick every unit in Squad[(Custom value of (Ordered unit))] and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) is Summoned) Equal to True
Then - Actions
Unit - Order (Picked unit) to Follow (Ordered unit)
Else - Actions
3 Variables being used, Num (Integer, default value of 1), Squad (Unit Group Array) and TempGroup (Unit Group).
I've figured that the problem is caused by the custom value of the Squad Leaders past the 1 Squad not being set. I'd like to know why this is so and how I can fix it. +rep to anyone that can help.