I have the below trigger that is selecting 3 random units around my voidwalker and spawns a dummy unit to attack them. The dummy unit / attacking works fine.
HOWEVER
I can't for the life of me get the "Random N" to stop selecting duplicate units. I tried implementing the below code to no avail. Can anyone help me here? I want the code to select three unique units every time. The below seems to at least 1 out of 5 times, select and attack the same unit three times (I put ~20 units a circle within the dummy attack range around the voidwalker, no issues there.)
HOWEVER
I can't for the life of me get the "Random N" to stop selecting duplicate units. I tried implementing the below code to no avail. Can anyone help me here? I want the code to select three unique units every time. The below seems to at least 1 out of 5 times, select and attack the same unit three times (I put ~20 units a circle within the dummy attack range around the voidwalker, no issues there.)
-
Shadow Strikes
-
Events
-
Time - Every 4.00 seconds of game time
-
-
Conditions
-
Actions
-
Set VariableSet i = 1
-
For each (Integer i) from 1 to 3, do (Actions)
-
Loop - Actions
-
Unit Group - Pick every unit in (Random 1 units from (Units within 700.00 of (Position of Greater Voidwalker 0014 <gen>).)) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is in shadowStrikePicks.) Equal to False
-
((Picked unit) is in (Units owned by Neutral Hostile.).) Equal to True
-
((Picked unit) is dead) Equal to False
-
-
Then - Actions
-
Unit Group - Add (Picked unit) to shadowStrikePicks
-
-
Else - Actions
-
Set VariableSet i = (i - 1)
-
Unit Group - Remove (Picked unit) from shadowStrikePicks.
-
Game - Display to (All players) the text: duplicate found
-
-
-
-
-
-
-
Unit Group - Pick every unit in shadowStrikePicks and do (Actions)
-
Loop - Actions
-
Unit - Create 1 Shadowstrikedummy for Player 1 (Red) at (Position of Greater Voidwalker 0014 <gen>) facing (Position of (Picked unit))
-
Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
-
Unit - Order (Last created unit) to Attack (Picked unit)
-
Game - Display to (All players) the text: attack committed
-
-
-
Unit Group - Remove all units from shadowStrikePicks.
-
-
Last edited: