- Joined
- Sep 14, 2009
- Messages
- 284
Hello. I'm making a map for 6 players, and depending on the number of players, each player may pick a certain number of heroes. To limit the heroes, i modify the food cap for each player.
Here is how it's supposed to work:
6 Players = 1 Food Cap
5 Players = 1 Food Cap (+1 Food Cap for 1 Random Player)
4 Players = 1 Food Cap (+1 Food Cap for 2 Random Players)
3 Players = 2 Food Cap
2 Players = 3 Food Cap
1 Player = 6 Food Cap
So it's pretty obvious that when there are 5 or 4 players, it get's more complicated.
I could easily use "ForcePickRandomPlayer", but I want to try and make it free from non-natives.
It's the last loop I have problem with. And it's not finished.
Here is the code so far:
Here is how it's supposed to work:
6 Players = 1 Food Cap
5 Players = 1 Food Cap (+1 Food Cap for 1 Random Player)
4 Players = 1 Food Cap (+1 Food Cap for 2 Random Players)
3 Players = 2 Food Cap
2 Players = 3 Food Cap
1 Player = 6 Food Cap
So it's pretty obvious that when there are 5 or 4 players, it get's more complicated.
I could easily use "ForcePickRandomPlayer", but I want to try and make it free from non-natives.
It's the last loop I have problem with. And it's not finished.
Here is the code so far:
JASS:
function CountPlayers_Actions takes nothing returns nothing
local integer i = 0
local integer playercount = 0
local integer r = 0
local force f = CreateForce()
loop
exitwhen i > 5
if GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer(f, (Player(i)))
set playercount = playercount + 1
endif
set i = i + 1
endloop
set i = 0
loop
exitwhen i > 5
if IsPlayerInForce(Player(i), f) == true then
if playercount >= 6 then
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_FOOD_CAP, 1)
else
if playercount == 5 then
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_FOOD_CAP, 1)
set r = 1
else
if playercount == 4 then
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_FOOD_CAP, 1)
set r = 2
else
if playercount == 3 then
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_FOOD_CAP, 2)
else
if playercount == 2 then
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_FOOD_CAP, 3)
else
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_FOOD_CAP, 6)
endif
endif
endif
endif
endif
endif
set i = i + 1
endloop
set i = 0
//This is the part I have problem with, setting the extra food cap for the 5 or 4 player case
loop
exitwhen i > r
if IsPlayerInForce(Player(i), f) == true then
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_FOOD_CAP, 2)
call ForceRemovePlayer(f, Player(i))
else
set i = i + 1
endif
endloop
call DestroyForce(f)
set f = null
endfunction
//===========================================================================
function InitTrig_CountPlayers takes nothing returns nothing
set gg_trg_CountPlayers = CreateTrigger()
call TriggerAddAction(gg_trg_CountPlayers, function CountPlayers_Actions)
endfunction