Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
I have been searching google and these forums for guides on how to create a trigger that would randomize teams. I came across such one here - How do I make random even teams?
But then I realized, if I get this setup, the teams wont be "together" and enemy bases could be directly side by side. Is there anyway to change a players starting position after a map has initialized? Or should I just not bother trying to create a random teams trigger?
No you can't change their position, but start positions do not really matter (except for AI I think). You can just create the starting units at a different location and move the camera of the player to that point, so it's quite easy to do.
hmmm.... well, if somebody is playing with AI they can pick standard teams and not RT... so I guess this might be possible after all! just have to get those triggers all setup now, its going to be awesome if I can pull this all off haha XD
well I got my team randomizer triggers setup, and it sort of works... but something really funny happens!! everytime, no matter how the teams come out, the allies are always on opposite sides... it makes no sense!! if p1red and p2blue are normally side by side, but if I press random team it will put blue on the opposite side (when we are allies) but if it teams me with p3teal or p4purp then they two are on opposite sides, no matter whos team I get we are cross spawns
lol like how the hell?? how is it possible for blue to be far away from red when by default red and blue should be together?? I did not make any triggers to move players
If anyone is interested in an efficient algorithm to assign a team for each player, here is one option:
It takes the player amount and splits them into a certain number of random teams.
It also works for numbers like 8 players into 5 teams (1,1,2,2,2). The first teams will have less players, but since it's random in which team you will be, every player has the same chance to get into a smaller team.
JASS:
function CreateTeams takes integer playerCount, integer teamCount returns nothing
local integer i //for loop
local integer currentValue //algorithm variable
local integer k //temporary result
local integer array teamMaxPlayers //maximum players in the team
local integer array teamPlayerCount //current players in the team
local integer array teamId //maps random integer to team index
local integer index
//force setup
set i = 0
set currentValue = playerCount
loop
exitwhen i>=teamCount
set k = R2I(((currentValue*1.00)/(1.00*teamCount-i)))
set teamMaxPlayers[i]=k
set currentValue=currentValue - k
set teamPlayerCount[i] = 0
set teamId[i]=i
set i = i + 1
endloop
//team creation
set i = 0
set currentValue = teamCount
loop
exitwhen i>=playerCount
set k = GetRandomInt(0, currentValue-1)
set index = teamId[k]
set teamPlayerCount[index] = teamPlayerCount[index] + 1
if(teamPlayerCount[index]>=teamMaxPlayers[index]) then
set currentValue = currentValue - 1
set teamId[k] = teamId[currentValue]
endif
//place your code here
// i = player index
// index = team index
call BJDebugMsg(GetPlayerName(Player(i))+" in team: "+I2S(index))
//end of your code
set i = i + 1
endloop
endfunction
This is only an algorithm to give every players a team index. No actual teams will be created, so you will have to create your teams afterwards depending on the results of the algorithm.
Start positions are usually random (unless you tick fixed start posititions)
Also if you use a trigger to refer to a player's start position, you will get the start position, that was randomly assigned to that player. If you want to get the start position you see in the world editor, you either have to check fixed start position, so they don't change or use regions to get the exact points.
I'm a pretty big newb, still learning most of the basic stuff. Is there a good tutorial for custom scripts??
Jampion seems pretty good at this stuff, so I sent him a copy of my map and hopefully he can fix the issue I'm having
Like I said, I created triggers for creating random teams, and it works (yay!!) but it always seems to set allies on opposite/far sides of the map no matter who the ally is, its really messed up because its moving player 2 who should be next to player 1 so I dont get it at all
But for the most part, my dialogue voting system is almost complete so I can start moving on to the juicier parts of my map!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.