Skip to content

Commit

Permalink
Avoid objective carrier being balanced to the other team (issue #37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo Smit committed Aug 4, 2016
1 parent fc88fcf commit 2524a1b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions luascripts/admin/balancer.lua
Expand Up @@ -109,17 +109,19 @@ function balancer.findPlayer(team, teamGreater, teamSmaller)
for _, playerId in ipairs(team) do
local health = tonumber(et.gentity_get(playerId, "health"))

local blueflag = et.gentity_get(playerId, "ps.powerups", 5) -- bg_public.h enum powerup_t PW_REDFLAG 6 and PW_BLUEFLAG 7
local redflag = et.gentity_get(playerId, "ps.powerups", 6)

if
(not bits.hasbit(playerSelection, balancer.BALANCE_ONLY_DEAD) or health <= 0)
-- TODO: find secure way to check for objective drops
-- and
-- (not bits.hasbit(playerSelection, balancer.BALANCE_NOT_OBJECTIVE) or stats.get(playerId, "hasObjective"))
and
(not bits.hasbit(playerSelection, balancer.BALANCE_NOT_OBJECTIVE) or (blueflag ~= 0 and redflag ~= 0))
then
table.insert(players, playerId)
end
end

if bits.hasbit(playerSelection, balancer.BALANCE_ONLY_DEAD) and #players == 0 then
if #players == 0 then
players = team
end

Expand Down

0 comments on commit 2524a1b

Please sign in to comment.