{
string message = strcat(player.netname, " is now an attacker.");
LOG_TRACE(message);
- if (!IS_BOT_CLIENT(player))
+ if (IS_REAL_CLIENT(player))
{
PrintToChat(player, "You are now an attacker.");
}
{
string message = strcat(player.netname, " is now a defender.");
LOG_TRACE(message);
- if (!IS_BOT_CLIENT(player))
+ if (IS_REAL_CLIENT(player))
{
PrintToChat(player, "You are now a defender.");
}
string message = strcat("RemovePlayerFromTeam: ",
player.netname, " has invalid role.");
LOG_TRACE(message);
- FOREACH_CLIENT(true,
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
PrintToChat(it, message);
});
string message = strcat("RemovePlayerFromTeam: ",
player.netname, " has invalid role.");
LOG_TRACE(message);
- FOREACH_CLIENT(true,
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
PrintToChat(it, message);
});
if (player.surv_role == SURVIVAL_ROLE_ATTACKER)
{
++surv_numattackersalive;
- LOG_TRACE("SURVIVAL: Added alive attacker, total = ", ftos(
- surv_numattackersalive));
+ string message = strcat("Survival: Added alive attacker, total = ",
+ ftos(surv_numattackersalive));
+ LOG_TRACE(message);
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
+ {
+ PrintToChat(it, message);
+ });
}
break;
}
case surv_defenderteam:
{
++surv_numdefendersalive;
- LOG_TRACE("SURVIVAL: Added alive defender, total = ", ftos(
- surv_numdefendersalive));
+ string message = strcat("Survival: Added alive defender, total = ",
+ ftos(surv_numdefendersalive));
+ LOG_TRACE(message);
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
+ {
+ PrintToChat(it, message);
+ });
break;
}
}
/// \brief Removes player from alive list. Handles bookkeeping information.
/// \param[in] player Player to remove.
+/// \param[in] t Team of the player.
/// \return No return.
-void Surv_RemovePlayerFromAliveList(entity player)
+void Surv_RemovePlayerFromAliveList(entity player, int t)
{
- switch (player.team)
+ switch (t)
{
case surv_attackerteam:
{
if (player.surv_role == SURVIVAL_ROLE_ATTACKER)
{
--surv_numattackersalive;
- LOG_TRACE("SURVIVAL: Removed alive attacker, total = ", ftos(
- surv_numattackersalive));
+ string message = strcat("Survival: Removed alive attacker, total = ",
+ ftos(surv_numattackersalive));
+ LOG_TRACE(message);
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
+ {
+ PrintToChat(it, message);
+ });
}
break;
}
case surv_defenderteam:
{
+ if (player.surv_role == SURVIVAL_ROLE_CANNON_FODDER)
+ {
+ // This happens during team switch. We don't need to change
+ // anything.
+ return;
+ }
--surv_numdefendersalive;
- LOG_TRACE("SURVIVAL: Removed alive defender, total = ", ftos(
- surv_numdefendersalive));
+ string message = strcat("Survival: Removed alive defender, total = ",
+ ftos(surv_numdefendersalive));
+ LOG_TRACE(message);
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
+ {
+ PrintToChat(it, message);
+ });
switch (surv_numdefendersalive)
{
case 1:
eliminatedPlayers.SendFlags |= 1;
}
Surv_UpdateAliveStats();
- if (warmup_stage || (savednumdefenders == surv_numdefendersalive))
+ if (warmup_stage || (savednumdefenders <= surv_numdefendersalive))
{
return;
}
{
healthratio = totalhealth / maxhealth;
}
- FOREACH_CLIENT(true,
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
it.surv_defender_health_stat = healthratio;
});
string message = strcat("SwapTeams: ", it.netname,
" has invalid role.");
LOG_TRACE(message);
- FOREACH_CLIENT(true,
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
PrintToChat(it, message);
});
string message = strcat("SwapTeams: ", it.netname,
" has invalid role.");
LOG_TRACE(message);
- FOREACH_CLIENT(true,
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
PrintToChat(it, message);
});
if (surv_roundtype == SURVIVAL_ROUND_FIRST)
{
surv_timetobeat = time - surv_roundstarttime;
- FOREACH_CLIENT(true,
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
centerprint(it, "Defenders have survived.");
PrintToChat(it, "Defenders have survived.");
surv_timetobeat = time - surv_roundstarttime;
string message = strcat("Defenders were eliminated in ^2",
seconds_tostring(surv_timetobeat), "^7.");
- FOREACH_CLIENT(true,
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
centerprint(it, message);
PrintToChat(it, message);
{
case surv_attackerteam:
{
- if (it.surv_role == SURVIVAL_ROLE_ATTACKER)
+ if (IS_REAL_CLIENT(it) && (it.surv_role ==
+ SURVIVAL_ROLE_ATTACKER))
{
centerprint(it, attackmessage);
PrintToChat(it, attackmessage);
}
case surv_defenderteam:
{
- if (it.surv_role == SURVIVAL_ROLE_DEFENDER)
+ if (IS_REAL_CLIENT(it))
{
centerprint(it, defendmessage);
PrintToChat(it, defendmessage);
+ }
+ if (it.surv_role == SURVIVAL_ROLE_DEFENDER)
+ {
WaypointSprite_Spawn(WP_AssaultDestroy, 0, 0, it, '0 0 64',
NULL, surv_attackerteam, it, surv_attack_sprite, false,
RADARICON_OBJECTIVE);
break;
}
}
- FOREACH_CLIENT(true,
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
it.surv_round_time_stat = roundtime;
});
entity player = M_ARGV(0, entity);
int oldteam = M_ARGV(1, float);
int newteam = M_ARGV(2, float);
- LOG_TRACE("SURVIVAL: Player_ChangedTeam, ", player.netname, ", old team = ",
- ftos(oldteam), " new team = ", ftos(newteam));
- //FOREACH_CLIENT(true, { centerprint(it, "Player_ChangeTeam"); });
- //if (!IS_DEAD(player))
- //{
- // surv_RemovePlayerFromAliveList(player);
- //}
+ string message = strcat("Survival: Player_ChangedTeam, ", player.netname,
+ ", old team = ", ftos(oldteam), " new team = ", ftos(newteam));
+ LOG_TRACE(message);
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
+ {
+ PrintToChat(it, message);
+ });
+ if ((oldteam != -1) && IS_PLAYER(player) && !IS_DEAD(player))
+ {
+ Surv_RemovePlayerFromAliveList(player, oldteam);
+ }
Surv_RemovePlayerFromTeam(player, oldteam);
Surv_AddPlayerToTeam(player, newteam);
- Surv_CountAlivePlayers();
- //if (IS_PLAYER(player) && !IS_DEAD(player))
- //{
- // surv_AddPlayerToAliveList(player, newteam);
- //}
+ //Surv_CountAlivePlayers();
+ if ((oldteam != -1) && IS_PLAYER(player) && !IS_DEAD(player))
+ {
+ Surv_AddPlayerToAliveList(player, newteam);
+ }
}
/// \brief Hook that is called when player connects to the server.
entity player = M_ARGV(0, entity);
LOG_TRACE("SURVIVAL: ClientConnect, player = ", player.netname);
player.surv_savedplayermodel = player.playermodel;
- player.surv_defender_team_stat = Team_TeamToNumber(surv_defenderteam);
+ if (IS_REAL_CLIENT(player))
+ {
+ player.surv_defender_team_stat = Team_TeamToNumber(surv_defenderteam);
+ player.surv_defenders_alive_stat = surv_numdefendersalive;
+ player.redalive_stat = redalive;
+ player.bluealive_stat = bluealive;
+ player.yellowalive_stat = yellowalive;
+ player.pinkalive_stat = pinkalive;
+ }
if (player.surv_role == SURVIVAL_ROLE_NONE)
{
Surv_AddPlayerToTeam(player, player.team);
MUTATOR_HOOKFUNCTION(surv, ClientDisconnect)
{
entity player = M_ARGV(0, entity);
- Surv_CountAlivePlayers();
- //if (!IS_DEAD(player))
- //{
- // Surv_RemovePlayerFromAliveList(player);
- //}
+ if (!IS_DEAD(player))
+ {
+ Surv_RemovePlayerFromAliveList(player, player.team);
+ }
Surv_RemovePlayerFromTeam(player, player.team);
+ //Surv_CountAlivePlayers();
}
MUTATOR_HOOKFUNCTION(surv, PutClientInServer)
MUTATOR_HOOKFUNCTION(surv, MakePlayerObserver)
{
- //FOREACH_CLIENT(true, { centerprint(it, "MakePlayerObserver"); });
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), { PrintToChat(it, "MakePlayerObserver"); });
//backtrace("SURVIVAL: MakePlayerObserver");
entity player = M_ARGV(0, entity);
LOG_TRACE("SURVIVAL: MakePlayerObserver, player = ", player.netname);
if (player.killindicator_teamchange == -2) // player wants to spectate
{
LOG_TRACE("killindicator_teamchange == -2");
- //FOREACH_CLIENT(true, { centerprint(it, "Removing Observer from alive list"); });
- //Surv_CountAlivePlayers();
- //surv_RemovePlayerFromAliveList(player);
- //Surv_RemovePlayerFromTeam(player, player.team);
player.surv_state = SURVIVAL_STATE_NOT_PLAYING;
}
if (!warmup_stage)
LOG_TRACE("SURVIVAL: reset_map_players");
//FOREACH_CLIENT(true, { centerprint(it, "reset_map_players"); });
Surv_SwapTeams();
- FOREACH_CLIENT(true, {
+ FOREACH_CLIENT(true,
+ {
it.killcount = 0;
if ((it.surv_state == SURVIVAL_STATE_NOT_PLAYING) && IS_BOT_CLIENT(it))
{
/// \brief Hook that is called when player spawns.
MUTATOR_HOOKFUNCTION(surv, PlayerSpawn)
{
- //FOREACH_CLIENT(true, { centerprint(it, "PlayerSpawn"); });
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), { PrintToChat(it, "PlayerSpawn"); });
entity player = M_ARGV(0, entity);
LOG_TRACE("SURVIVAL: PlayerSpawn, player = ", player.netname);
player.surv_state = SURVIVAL_STATE_PLAYING;
- Surv_CountAlivePlayers();
- //surv_AddPlayerToAliveList(player, player.team);
+ //Surv_CountAlivePlayers();
+ Surv_AddPlayerToAliveList(player, player.team);
//W_GiveWeapon(player, WEP_HMG.m_id);
//W_GiveWeapon(player, WEP_RPC.m_id);
switch (player.team)
}
default:
{
- centerprint(player, "INVALID ROLE");
LOG_TRACE("Survival::PlayerSpawn: Invalid attacker role.");
break;
}
{
if (player.surv_role != SURVIVAL_ROLE_DEFENDER)
{
- centerprint(player, "INVALID ROLE");
LOG_TRACE("Survival::PlayerSpawn: Invalid defender role.");
}
switch (surv_defendercolor)
if (it.netname == weapon)
{
player.weapons |= it.m_wepset;
- //W_GiveWeapon(player, it.m_id);
break;
}
});
return MUT_ITEMTOUCH_RETURN;
}
}
- centerprint(player, item.classname);
+ PrintToChat(player, item.classname);
return MUT_ITEMTOUCH_RETURN;
}
}
/// \brief Hook which is called when the player dies.
MUTATOR_HOOKFUNCTION(surv, PlayerDies)
{
- //FOREACH_CLIENT(true, { centerprint(it, "PlayerDies"); });
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), { PrintToChat(it, "PlayerDies"); });
entity frag_target = M_ARGV(2, entity);
- //surv_RemovePlayerFromAliveList(frag_target);
if (!Surv_CanPlayerSpawn(frag_target))
{
frag_target.respawn_flags = RESPAWN_SILENT;
/// \brief Hook which is called after the player died.
MUTATOR_HOOKFUNCTION(surv, PlayerDied)
{
- Surv_CountAlivePlayers();
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), { PrintToChat(it, "PlayerDied"); });
+ entity player = M_ARGV(0, entity);
+ Surv_RemovePlayerFromAliveList(player, player.team);
+ //Surv_CountAlivePlayers();
}
/// \brief Hook which is called when player has scored a frag.