I am working on a Risk game and I am working on the give bases to player trigger. Basically it counts the number of bases and the number of players, then iterates through the players assigning random bases. The problem is that its not really random, bases are always assigned the same.
-
Randomize Bases
-
Events
-
Time - Elapsed game time is 1.00 seconds
-
-
Conditions
-
Actions
-
-------- Count Bases --------
-
Set tempGroup1 = (Units owned by Neutral Hostile matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
-
Set numOfBases = (Number of units in tempGroup1)
-
-------- Count Players --------
-
Set tempForce1 = (All players matching (((Matching player) slot status) Equal to Is playing))
-
Set numOfPlayers = (Number of players in tempForce1)
-
Set numOfBasesPerPlayer = (numOfBases / numOfPlayers)
-
-------- Create Bases --------
-
Unit Group - Pick every unit in tempGroup1 and do (Actions)
-
Loop - Actions
-
Set tempUnit1 = (Picked unit)
-
Set tempPlayer1 = (Random player from tempForce1)
-
Set tempPoint1 = (Position of tempUnit1)
-
Set tempPoint2 = (tempPoint1 offset by (0.00, -220.00))
-
Unit - Create 1 defaultUnitType for Neutral Hostile at tempPoint2 facing Default building facing degrees
-
Set tempUnit2 = (Last created unit)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
tempInt[(Player number of tempPlayer1)] Less than numOfBasesPerPlayer
-
-
Then - Actions
-
Unit - Change ownership of tempUnit1 to tempPlayer1 and Change color
-
Unit - Change ownership of tempUnit2 to tempPlayer1 and Change color
-
Unit - Order tempUnit1 to Undead Necromancer - Unholy Frenzy tempUnit2
-
Set tempInt[(Player number of tempPlayer1)] = (tempInt[(Player number of tempPlayer1)] + 1)
-
-
Else - Actions
-
-
Custom script: call RemoveLocation( udg_tempPoint1 )
-
Custom script: set udg_tempPoint1 = null
-
Custom script: call RemoveLocation( udg_tempPoint2 )
-
Custom script: set udg_tempPoint2 = null
-
Custom script: set udg_tempUnit1 = null
-
Custom script: set udg_tempUnit2 = null
-
Player Group - Remove tempPlayer1 from tempForce1
-
Player Group - Add tempPlayer1 to tempForce2
-
Custom script: set udg_tempPlayer1 = null
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of players in tempForce1) Equal to 0
-
-
Then - Actions
-
Player Group - Pick every player in tempForce2 and do (Actions)
-
Loop - Actions
-
Player Group - Add (Picked player) to tempForce1
-
Player Group - Remove (Picked player) from tempForce2
-
-
-
-
Else - Actions
-
-
-
-
Set tempGroup2 = (Units owned by Neutral Hostile matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
-
Unit Group - Pick every unit in tempGroup2 and do (Actions)
-
Loop - Actions
-
Set tempUnit1 = (Picked unit)
-
Set tempPlayer1 = (Owner of tempUnit1)
-
Set tempPoint1 = (Position of tempUnit1)
-
Set tempPoint2 = (tempPoint1 offset by 300.00 towards 270.00 degrees)
-
Set G_TempGroup = (Units within 150.00 of tempPoint2 matching ((((((Matching unit) is alive) Equal to True) and (((Matching unit) is in G_Group) Not equal to True)) and (((Matching unit) is A structure) Not equal to True)) and ((Owner of (Matching unit)) Equal to tempPlayer1))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(G_TempGroup is empty) Equal to False
-
-
Then - Actions
-
Unit - Order tempUnit1 to Undead Necromancer - Unholy Frenzy (Random unit from G_TempGroup)
-
-
Else - Actions
-
Unit - Create 1 dummyType for tempPlayer1 at tempPoint2 facing 270.00 degrees
-
Unit - Order tempUnit1 to Undead Necromancer - Unholy Frenzy (Last created unit)
-
-
-
Custom script: call RemoveLocation( udg_tempPoint1 )
-
Custom script: set udg_tempPoint1 = null
-
Custom script: call RemoveLocation( udg_tempPoint2 )
-
Custom script: set udg_tempPoint2 = null
-
Custom script: set udg_tempUnit1 = null
-
Custom script: set udg_tempPlayer1 = null
-
Custom script: call DestroyGroup (udg_G_TempGroup)
-
-
-
Custom script: call DestroyForce( udg_tempForce1 )
-
Custom script: set udg_tempForce1 = null
-
Custom script: call DestroyForce( udg_tempForce2 )
-
Custom script: set udg_tempForce2 = null
-
Custom script: call DestroyGroup( udg_tempGroup1 )
-
Custom script: set udg_tempGroup1 = null
-
Custom script: call DestroyGroup( udg_tempGroup2 )
-
Custom script: set udg_tempGroup2 = null
-
Custom script: call DestroyTrigger( GetTriggeringTrigger() )
-
-
Last edited: