enum
{
SURVIVAL_ROLE_NONE, ///< Player is not playing.
- SURVIVAL_ROLE_ATTACKER, ///< Player is an attacker.
- SURVIVAL_ROLE_DEFENDER, ///< Player is a defender.
+ SURVIVAL_ROLE_PLAYER, ///< Player is an attacker or defender.
SURVIVAL_ROLE_CANNON_FODDER ///< Player is a cannon fodder.
};
case surv_attackerteam:
{
surv_numattackers += delta;
- LOG_TRACE("Number of attackers = ", ftos(surv_numattackers));
+ LOG_TRACE("Number of attackers = ", ftos(surv_numattackers),
+ " was = ", ftos(surv_numattackers - delta));
Surv_UpdateTeamStats();
return;
}
case surv_defenderteam:
{
surv_numdefenders += delta;
- LOG_TRACE("Number of defenders = ", ftos(surv_numdefenders));
+ LOG_TRACE("Number of defenders = ", ftos(surv_numdefenders),
+ " was = ", ftos(surv_numdefenders - delta));
Surv_UpdateTeamStats();
return;
}
{
surv_numattackersalive += delta;
LOG_TRACE("Number of alive attackers = ", ftos(
- surv_numattackersalive));
+ surv_numattackersalive), " was = ", ftos(surv_numattackersalive
+ - delta));
Surv_UpdateAliveStats();
return;
}
{
surv_numdefendersalive += delta;
LOG_TRACE("Number of alive defenders = ", ftos(
- surv_numdefendersalive));
+ surv_numdefendersalive), " was = ", ftos(surv_numdefendersalive
+ - delta));
Surv_UpdateAliveStats();
return;
}
LOG_TRACE(player.netname, " now has no role.");
break;
}
- case SURVIVAL_ROLE_ATTACKER:
+ case SURVIVAL_ROLE_PLAYER:
{
- LOG_TRACE(player.netname, " is now an attacker.");
- break;
- }
- case SURVIVAL_ROLE_DEFENDER:
- {
- LOG_TRACE(player.netname, " is now a defender.");
+ LOG_TRACE(player.netname, " is now a player.");
break;
}
case SURVIVAL_ROLE_CANNON_FODDER:
LOG_TRACE("Attackers = ", ftos(surv_numattackers));
if (surv_numattackers < autocvar_g_surv_team_size)
{
- Surv_SetPlayerRole(player, SURVIVAL_ROLE_ATTACKER);
+ Surv_SetPlayerRole(player, SURVIVAL_ROLE_PLAYER);
Surv_ChangeNumberOfPlayers(teamnum, +1);
return true;
}
surv_autobalance = false;
FOREACH_CLIENT(true,
{
- if ((it.surv_role == SURVIVAL_ROLE_ATTACKER) &&
- IS_BOT_CLIENT(it))
+ if ((it.team == surv_attackerteam) && (it.surv_role ==
+ SURVIVAL_ROLE_PLAYER) && IS_BOT_CLIENT(it))
{
+ LOG_TRACE("Changing ", it.netname,
+ " from attacker to cannon fodder.");
Surv_SetPlayerRole(it, SURVIVAL_ROLE_CANNON_FODDER);
- Surv_ChangeNumberOfPlayers(teamnum, -1);
if (!IS_DEAD(it))
{
Surv_ChangeNumberOfAlivePlayers(teamnum, -1);
}
+ Surv_ChangeNumberOfPlayers(teamnum, -1);
removedbot = true;
break;
}
}
LOG_TRACE("Removed bot");
}
- Surv_SetPlayerRole(player, SURVIVAL_ROLE_ATTACKER);
+ Surv_SetPlayerRole(player, SURVIVAL_ROLE_PLAYER);
Surv_ChangeNumberOfPlayers(teamnum, +1);
++surv_numattackerhumans;
LOG_TRACE("Human attackers = ", ftos(surv_numattackerhumans));
LOG_TRACE("Defenders = ", ftos(surv_numdefenders));
if (surv_numdefenders < autocvar_g_surv_team_size)
{
- Surv_SetPlayerRole(player, SURVIVAL_ROLE_DEFENDER);
+ Surv_SetPlayerRole(player, SURVIVAL_ROLE_PLAYER);
Surv_ChangeNumberOfPlayers(teamnum, +1);
return true;
}
surv_autobalance = false;
FOREACH_CLIENT(true,
{
- if ((it.surv_role == SURVIVAL_ROLE_DEFENDER) &&
- IS_BOT_CLIENT(it))
+ if ((it.team == surv_defenderteam) && IS_BOT_CLIENT(it))
{
- LOG_TRACE("Removing bot ", it.netname);
+ LOG_TRACE("Changing ", it.netname,
+ " from defender to cannon fodder.");
SetPlayerTeamSimple(it, surv_attackerteam);
removedbot = true;
break;
}
LOG_TRACE("Removed bot");
}
- Surv_SetPlayerRole(player, SURVIVAL_ROLE_DEFENDER);
+ Surv_SetPlayerRole(player, SURVIVAL_ROLE_PLAYER);
Surv_ChangeNumberOfPlayers(teamnum, +1);
++surv_numdefenderhumans;
LOG_TRACE("Human defenders = ", ftos(surv_numdefenderhumans));
case surv_attackerteam:
{
LOG_TRACE("Attacker team");
- if (player.surv_role != SURVIVAL_ROLE_ATTACKER)
+ if (player.surv_role == SURVIVAL_ROLE_NONE)
{
- if (player.surv_role != SURVIVAL_ROLE_CANNON_FODDER)
- {
- string message = strcat("RemovePlayerFromTeam: ",
- player.netname, " has invalid role.");
- LOG_TRACE(message);
- DebugPrintToChatAll(message);
- }
+ string message = strcat("RemovePlayerFromTeam: ",
+ player.netname, " has invalid role.");
+ DebugPrintToChatAll(message);
+ return;
+ }
+ if (player.surv_role == SURVIVAL_ROLE_CANNON_FODDER)
+ {
+ Surv_SetPlayerRole(player, SURVIVAL_ROLE_NONE);
return;
}
Surv_SetPlayerRole(player, SURVIVAL_ROLE_NONE);
{
if (it.surv_role == SURVIVAL_ROLE_CANNON_FODDER)
{
- Surv_SetPlayerRole(it, SURVIVAL_ROLE_ATTACKER);
+ LOG_TRACE("Changing ", it.netname,
+ " from cannon fodder to attacker.");
+ Surv_SetPlayerRole(it, SURVIVAL_ROLE_PLAYER);
Surv_ChangeNumberOfPlayers(teamnum, +1);
if (!IS_DEAD(it))
{
LOG_TRACE("Cannon fodder. Assuming team switch");
return;
}
- if (player.surv_role != SURVIVAL_ROLE_DEFENDER)
+ if (player.surv_role != SURVIVAL_ROLE_PLAYER)
{
string message = strcat("RemovePlayerFromTeam: ",
player.netname, " has invalid role.");
- LOG_TRACE(message);
DebugPrintToChatAll(message);
return;
}
{
if (it.surv_role == SURVIVAL_ROLE_CANNON_FODDER)
{
+ LOG_TRACE("Changing ", it.netname,
+ " from cannon fodder to defender.");
SetPlayerTeamSimple(it, surv_defenderteam);
return;
}
{
case surv_attackerteam:
{
- if (player.surv_role == SURVIVAL_ROLE_ATTACKER)
+ if (player.surv_role == SURVIVAL_ROLE_PLAYER)
{
Surv_ChangeNumberOfAlivePlayers(teamnum, +1);
}
{
case surv_attackerteam:
{
- if (player.surv_role == SURVIVAL_ROLE_ATTACKER)
+ if (player.surv_role == SURVIVAL_ROLE_PLAYER)
{
Surv_ChangeNumberOfAlivePlayers(teamnum, -1);
}
{
case surv_attackerteam:
{
- if ((it.surv_role == SURVIVAL_ROLE_ATTACKER) && !IS_DEAD(it))
+ if ((it.surv_role == SURVIVAL_ROLE_PLAYER) && !IS_DEAD(it))
{
++surv_numattackersalive;
}
}
case surv_defenderteam:
{
- if ((it.surv_role == SURVIVAL_ROLE_DEFENDER) && !IS_DEAD(it))
+ if ((it.surv_role == SURVIVAL_ROLE_PLAYER) && !IS_DEAD(it))
{
++surv_numdefendersalive;
}
surv_numdefenderhumans = temp;
FOREACH_CLIENT(true,
{
- switch (it.team)
+ if ((it.team == surv_defenderteam) && (it.surv_role ==
+ SURVIVAL_ROLE_CANNON_FODDER))
{
- case surv_attackerteam:
- {
- if (it.surv_role == SURVIVAL_ROLE_DEFENDER)
- {
- Surv_SetPlayerRole(it, SURVIVAL_ROLE_ATTACKER);
- break;
- }
- else
- {
- string message = strcat("SwapTeams: ", it.netname,
- " has invalid role.");
- LOG_TRACE(message);
- DebugPrintToChatAll(message);
- }
- break;
- }
- case surv_defenderteam:
- {
- switch (it.surv_role)
- {
- case SURVIVAL_ROLE_ATTACKER:
- {
- Surv_SetPlayerRole(it, SURVIVAL_ROLE_DEFENDER);
- break;
- }
- case SURVIVAL_ROLE_CANNON_FODDER:
- {
- SetPlayerTeamSimple(it, surv_attackerteam);
- break;
- }
- default:
- {
- string message = strcat("SwapTeams: ", it.netname,
- " has invalid role.");
- LOG_TRACE(message);
- DebugPrintToChatAll(message);
- break;
- }
- }
- break;
- }
+ SetPlayerTeamSimple(it, surv_attackerteam);
}
});
FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
switch (player.surv_role)
{
- case SURVIVAL_ROLE_ATTACKER:
+ case SURVIVAL_ROLE_PLAYER:
{
if (!autocvar_g_surv_attacker_force_overkill_models)
{
case surv_attackerteam:
{
if (IS_REAL_CLIENT(it) && (it.surv_role ==
- SURVIVAL_ROLE_ATTACKER))
+ SURVIVAL_ROLE_PLAYER))
{
centerprint(it, attackmessage);
PrintToChat(it, attackmessage);
centerprint(it, defendmessage);
PrintToChat(it, defendmessage);
}
- if (it.surv_role == SURVIVAL_ROLE_DEFENDER)
+ if (it.surv_role == SURVIVAL_ROLE_PLAYER)
{
WaypointSprite_Spawn(WP_AssaultDestroy, 0, 0, it, '0 0 64',
NULL, surv_attackerteam, it, surv_attack_sprite, false,
MUTATOR_HOOKFUNCTION(surv, CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
{
entity player = M_ARGV(2, entity);
- LOG_TRACE("SURVIVAL: CheckAllowedTeams, player = ", player.netname);
+ LOG_TRACE("Survival: CheckAllowedTeams, player = ", player.netname);
if (!IS_BOT_CLIENT(player))
{
if (surv_type == SURVIVAL_TYPE_COOP)
{
teambits |= surv_attackerteambit;
}
- if (surv_numdefenderhumans < autocvar_g_surv_team_size)
+ if (surv_allowed_to_spawn && (surv_numdefenderhumans <
+ autocvar_g_surv_team_size))
{
teambits |= surv_defenderteambit;
}
return;
}
int teambits = surv_attackerteambit;
- if (surv_numdefenders < autocvar_g_surv_team_size)
+ if ((player.team == surv_defenderteam) || (surv_numdefenders <
+ autocvar_g_surv_team_size))
{
teambits |= surv_defenderteambit;
}
MUTATOR_HOOKFUNCTION(surv, ClientConnect)
{
entity player = M_ARGV(0, entity);
- LOG_TRACE("SURVIVAL: ClientConnect, player = ", player.netname);
+ LOG_TRACE("Survival: ClientConnect, player = ", player.netname);
player.surv_savedplayermodel = player.playermodel;
if (IS_REAL_CLIENT(player))
{
MUTATOR_HOOKFUNCTION(surv, PutClientInServer)
{
entity player = M_ARGV(0, entity);
- LOG_TRACE("SURVIVAL: PutClientInServer, player = ", player.netname);
+ LOG_TRACE("Survival: PutClientInServer, player = ", player.netname);
if (!Surv_CanPlayerSpawn(player) && IS_PLAYER(player))
{
TRANSMUTE(Observer, player);
MUTATOR_HOOKFUNCTION(surv, MakePlayerObserver)
{
- //DebugPrintToChatAll("MakePlayerObserver");
entity player = M_ARGV(0, entity);
- LOG_TRACE("SURVIVAL: MakePlayerObserver, player = ", player.netname);
+ LOG_TRACE("Survival: MakePlayerObserver, player = ", player.netname);
if (player.killindicator_teamchange == -2) // player wants to spectate
{
LOG_TRACE("killindicator_teamchange == -2");
MUTATOR_HOOKFUNCTION(surv, ForbidSpawn)
{
entity player = M_ARGV(0, entity);
- LOG_TRACE("SURVIVAL: ForbidSpawn, player = ", player.netname);
+ LOG_TRACE("Survival: ForbidSpawn, player = ", player.netname);
if (player.surv_state == SURVIVAL_STATE_NOT_PLAYING)
{
return false;
{
switch (player.surv_role)
{
- case SURVIVAL_ROLE_ATTACKER:
+ case SURVIVAL_ROLE_PLAYER:
{
FOREACH(Weapons, it != WEP_Null,
{
}
case surv_defenderteam:
{
- if (player.surv_role != SURVIVAL_ROLE_DEFENDER)
+ if (player.surv_role != SURVIVAL_ROLE_PLAYER)
{
LOG_TRACE("Survival: PlayerSpawn: ", player.netname,
" has invalid defender role.");
// Don't announce remaining frags
return false;
}
-
-//MUTATOR_HOOKFUNCTION(surv, MatchEnd)
-//{
-// surv_numattackers = 0;
-// surv_numdefenders = 0;
-// surv_numattackerhumans = 0;
-// surv_numdefenderhumans = 0;
-// surv_numattackersalive = 0;
-// surv_numdefendersalive = 0;
-// FOREACH_CLIENT(true,
-// {
-// it.surv_role = SURVIVAL_ROLE_NONE;
-// });
-//}