Hi,
I've been banging my head against this for a while and I just cannot work out the formula...so I thought I'd ask for help!
I have an arena map and I'm working on a function to randomise teams, you can have teams of 2,3,4,6, and 12 (with a total of 24 players available). Where I'm struggling is I had a function that added a random player a player group index, then when that player group had the required number of players it'd bump up to the next index. My problem is working out how to balance the number of players if there isn't a full set of players. For example
if you want to play as teams of 12, but only have 20 players, it needs to work out to bump up the index at 10 players. I have this one working but it doesn't work with the other team sizes.
When I tried 20 players with teams of 2 it calculated 1.6 players per team, which then is rounded down so everyone is on their own team...
I'm sure there's a simple formula for this but my lord am I struggling to work it out
See my trigger below (team size is set up in a seperate trigger - All_Players is a seperate player group variable that only includes active players)
EDIT: A bit I took out of this copied trigger is if "TempPlayerGroup" has any players in it the trigger then repeats itself
I've been banging my head against this for a while and I just cannot work out the formula...so I thought I'd ask for help!
I have an arena map and I'm working on a function to randomise teams, you can have teams of 2,3,4,6, and 12 (with a total of 24 players available). Where I'm struggling is I had a function that added a random player a player group index, then when that player group had the required number of players it'd bump up to the next index. My problem is working out how to balance the number of players if there isn't a full set of players. For example
if you want to play as teams of 12, but only have 20 players, it needs to work out to bump up the index at 10 players. I have this one working but it doesn't work with the other team sizes.
When I tried 20 players with teams of 2 it calculated 1.6 players per team, which then is rounded down so everyone is on their own team...
I'm sure there's a simple formula for this but my lord am I struggling to work it out
See my trigger below (team size is set up in a seperate trigger - All_Players is a seperate player group variable that only includes active players)
Code:
Randomise Teams
Events
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Number of players in TeamGroup[TeamCount]) Equal to TeamSize
(Number of players in TeamGroup[TeamCount]) Equal to ((Number of players in Players_All) / (24 / TeamSize))
Then - Actions
Set VariableSet TeamCount = (TeamCount + 1)
Else - Actions
Set VariableSet TempPlayer = (Random player from TempPlayerGroup)
Set VariableSet PlayerTeamNumber[(Player number of TempPlayer)] = TeamCount
Player Group - Add TempPlayer to TeamGroup[TeamCount]
Player Group - Remove TempPlayer from TempPlayerGroup.
EDIT: A bit I took out of this copied trigger is if "TempPlayerGroup" has any players in it the trigger then repeats itself