function MeleeGetAllyCount takes player whichPlayer returns integer
local integer playerIndex
local integer playerCount
local player indexPlayer
// Count the number of not-yet-defeated co-allies.
set playerCount = 0
set playerIndex = 0
loop
set indexPlayer = Player(playerIndex)
if PlayersAreCoAllied(whichPlayer, indexPlayer) and not bj_meleeDefeated[playerIndex] and (whichPlayer != indexPlayer) then
set playerCount = playerCount + 1
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
return playerCount
endfunction