void count_alive_players()
{
- totalalive = redalive = bluealive = yellowalive = pinkalive = 0;
if(g_ca)
{
+ totalalive = redalive = bluealive = yellowalive = pinkalive = 0;
FOR_EACH_PLAYER(self) {
if (self.team == COLOR_TEAM1 && self.health >= 1)
{
self.bluealive_stat = bluealive;
}
}
- else if(g_freezetag)
- {
- // count amount of alive players in each team
- FOR_EACH_PLAYER(self) {
- if (self.team == COLOR_TEAM1 && self.freezetag_frozen == 0 && self.health >= 1)
- {
- redalive += 1;
- totalalive += 1;
- }
- else if (self.team == COLOR_TEAM2 && self.freezetag_frozen == 0 && self.health >= 1)
- {
- bluealive += 1;
- totalalive += 1;
- }
- else if (self.team == COLOR_TEAM3 && self.freezetag_frozen == 0 && self.health >= 1)
- {
- yellowalive += 1;
- totalalive += 1;
- }
- else if (self.team == COLOR_TEAM4 && self.freezetag_frozen == 0 && self.health >= 1)
- {
- pinkalive += 1;
- totalalive += 1;
- }
- }
- FOR_EACH_REALCLIENT(self) {
- self.redalive_stat = redalive;
- self.bluealive_stat = bluealive;
- self.yellowalive_stat = yellowalive;
- self.pinkalive_stat = pinkalive;
- }
- }
-
}
/**
TeamScore_AddToTeam(winner.team, ST_SCORE, +1);
}
+ totalalive = redalive = bluealive = yellowalive = pinkalive = 0;
next_round = time + 5;
}
self.nextthink = time;
}
+void freezetag_update_alive_stats()
+{
+ entity e;
+ FOR_EACH_REALCLIENT(e) {
+ e.redalive_stat = redalive;
+ e.bluealive_stat = bluealive;
+ e.yellowalive_stat = yellowalive;
+ e.pinkalive_stat = pinkalive;
+ }
+}
+
+void freezetag_add_alive()
+{
+ if(self.team == COLOR_TEAM1) ++redalive;
+ else if(self.team == COLOR_TEAM2) ++bluealive;
+ else if(self.team == COLOR_TEAM3) ++yellowalive;
+ else if(self.team == COLOR_TEAM4) ++pinkalive;
+ ++totalalive;
+ freezetag_update_alive_stats();
+}
+
+void freezetag_remove_alive()
+{
+ if(self.team == COLOR_TEAM1) --redalive;
+ else if(self.team == COLOR_TEAM2) --bluealive;
+ else if(self.team == COLOR_TEAM3) --yellowalive;
+ else if(self.team == COLOR_TEAM4) --pinkalive;
+ --totalalive;
+ freezetag_update_alive_stats();
+}
+
void freezetag_Freeze(entity attacker)
{
if(self.freezetag_frozen)
MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer)
{
if(self.freezetag_frozen == 0 && self.health >= 1)
- {
- if(self.team == COLOR_TEAM1)
- --redalive;
- else if(self.team == COLOR_TEAM2)
- --bluealive;
- else if(self.team == COLOR_TEAM3)
- --yellowalive;
- else if(self.team == COLOR_TEAM4)
- --pinkalive;
- --totalalive;
- }
+ freezetag_remove_alive();
+
+ freezetag_Unfreeze(world);
if(total_players > 2) // only check for winners if we had more than two players (one of them left, don't let the other player win just because of that)
freezetag_CheckWinner();
- freezetag_Unfreeze(world);
-
return 1;
}
{
if(self.freezetag_frozen == 0)
{
- if(self.team == COLOR_TEAM1)
- --redalive;
- else if(self.team == COLOR_TEAM2)
- --bluealive;
- else if(self.team == COLOR_TEAM3)
- --yellowalive;
- else if(self.team == COLOR_TEAM4)
- --pinkalive;
- --totalalive;
-
freezetag_Freeze(frag_attacker);
+ freezetag_remove_alive();
}
if(frag_attacker == frag_target || frag_attacker == world)
MUTATOR_HOOKFUNCTION(freezetag_PlayerSpawn)
{
+ freezetag_add_alive();
if(time <= game_starttime || total_players == 0)
return 1;
if(total_players == 1) // only one player active on server, start a new match immediately
if(!next_round && warmup && (time < warmup - autocvar_g_freezetag_warmup || time > warmup)) // not awaiting next round
{
+ totalalive = redalive = bluealive = yellowalive = pinkalive = 0;
next_round = time;
return 1;
}
{
centerprint(self, "^1You spawned after the round started, you'll spawn as frozen.\n");
freezetag_Freeze(world);
+ freezetag_remove_alive();
}
return 1;
float n;
vector revive_extra_size;
+ if(next_round || (time > warmup - autocvar_g_freezetag_warmup && time < warmup))
+ return 1; // already waiting for next round to start
+
revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
entity o;
if(self.freezetag_revive_progress >= 1)
{
freezetag_Unfreeze(self);
+ freezetag_add_alive();
// EVERY team mate nearby gets a point (even if multiple!)
FOR_EACH_PLAYER(other) if(self != other)