Hello we are trying to access quickly a variable that will store multiple info, that we could update.
The following code will allow you to quickly access an array of struct(int,int)
but how can we do with a type of agent?
#SET A STRUCT
coordinates := struct:
X : float = 0.0
Y : float = 0.0
Here when we try to use the struct
OnPlayerStart:=class(creative_device):
#=VARIABLE DECLARATION=
var CoordinateStructArray:[]coordinates =array{}
OnBegin<override>()<suspends> : void =
TeamBalance()
TeamBalance():void=
CoordinateStructArrayTemps:=coordinates{X :=0.0,Y:=0.0}
set CoordinateStructArray+=array{CoordinateStructArrayTemps}
Ok found a solution after multiple attemps, here an array of struct that holds the player information:
#SET A STRUCT
PlayerInfoStruct<public>:=struct:
playerIndex:int=0
playerTeam:?team = false
Here the class
OnPlayerStart:=class(creative_device):
#====================VARIABLE DECLARATION================
var PlayerInfoStrucArray<public>:[]PlayerInfoStruct=array{} #PlayerIndex, PlayerTeam
OnBegin<override>()<suspends> : void =
TeamBalanceAsymmetric():void=
#//==Balancing Teams Asymmetrically
TeamBalanceAsymmetric():void=
Print("Beginning to balance teams")
FortTeamCollection := GetPlayspace().GetTeamCollection()
Print("AllPlayers Length is {AllPlayers.Length}")
for (TeamPlayer : AllPlayers):
var TeamToAssign:?team = false
set TeamToAssign = FindTeamWithLargestDifference()
if (AssignedTeam := TeamToAssign?, FortTeamCollection.AddToTeam[TeamPlayer, AssignedTeam]):
Print("Assigned player to a new team")
#Find the player index and store it in the struc
for(PlayerIndex -> PlayerType : AllPlayers): # Do for loop For all the Player
if(PlayerTemp :player = AllPlayers[PlayerIndex]):
PlayerInfoStructTemp:=PlayerInfoStruct{playerIndex:=PlayerIndex, playerTeam:=TeamToAssign}