/// \return True if player is eliminated, false otherwise.
bool Surv_IsEliminated(entity player);
+/// \brief Updates stats of team count on HUD.
+/// \return No return.
+void Surv_UpdateTeamStats();
+
/// \brief Updates stats of alive players on HUD.
/// \return No return.
void Surv_UpdateAliveStats();
surv_autobalance = true;
surv_allowed_to_spawn = true;
precache_all_playermodels("models/ok_player/*.dpm");
- WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
- WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
ScoreRules_basics(SURVIVAL_TEAM_BITS, SFL_SORT_PRIO_PRIMARY, 0, true);
ScoreInfo_SetLabel_TeamScore(1, "rounds", SFL_SORT_PRIO_PRIMARY);
ScoreRules_basics_end();
autocvar_timelimit_override, -1);
}
+/// \brief Changes the number of players in a team.
+/// \param[in] teamnum Team to adjust.
+/// \param[in] delta Amount to adjust by.
+/// \return No return.
+void Surv_ChangeNumberOfPlayers(int teamnum, int delta)
+{
+ switch (teamnum)
+ {
+ case surv_attackerteam:
+ {
+ surv_numattackers += delta;
+ LOG_TRACE("Number of attackers = ", ftos(surv_numattackers));
+ Surv_UpdateTeamStats();
+ return;
+ }
+ case surv_defenderteam:
+ {
+ surv_numdefenders += delta;
+ LOG_TRACE("Number of defenders = ", ftos(surv_numdefenders));
+ Surv_UpdateTeamStats();
+ return;
+ }
+ }
+}
+
+/// \brief Changes the number of alive players in a team.
+/// \param[in] teamnum Team to adjust.
+/// \param[in] delta Amount to adjust by.
+/// \return No return.
+void Surv_ChangeNumberOfAlivePlayers(int teamnum, int delta)
+{
+ switch (teamnum)
+ {
+ case surv_attackerteam:
+ {
+ surv_numattackersalive += delta;
+ LOG_TRACE("Number of alive attackers = ", ftos(
+ surv_numattackersalive));
+ Surv_UpdateAliveStats();
+ return;
+ }
+ case surv_defenderteam:
+ {
+ surv_numdefendersalive += delta;
+ LOG_TRACE("Number of alive defenders = ", ftos(
+ surv_numdefendersalive));
+ Surv_UpdateAliveStats();
+ return;
+ }
+ }
+}
+
/// \brief Sets the player role.
/// \param[in,out] player Player to adjust.
/// \param[in] role Role to set.
{
case SURVIVAL_ROLE_NONE:
{
- string message = strcat(player.netname, " now has no role.");
- LOG_TRACE(message);
+ LOG_TRACE(player.netname, " now has no role.");
break;
}
case SURVIVAL_ROLE_ATTACKER:
{
- string message = strcat(player.netname, " is now an attacker.");
- LOG_TRACE(message);
+ LOG_TRACE(player.netname, " is now an attacker.");
break;
}
case SURVIVAL_ROLE_DEFENDER:
{
- string message = strcat(player.netname, " is now a defender.");
- LOG_TRACE(message);
+ LOG_TRACE(player.netname, " is now a defender.");
break;
}
case SURVIVAL_ROLE_CANNON_FODDER:
{
- string message = strcat(player.netname, " is now a cannon fodder.");
- LOG_TRACE(message);
+ LOG_TRACE(player.netname, " is now a cannon fodder.");
break;
}
}
if (surv_numattackers < autocvar_g_surv_team_size)
{
Surv_SetPlayerRole(player, SURVIVAL_ROLE_ATTACKER);
- ++surv_numattackers;
- LOG_TRACE("Numattackers = ", ftos(surv_numattackers));
+ Surv_ChangeNumberOfPlayers(teamnum, +1);
return true;
}
Surv_SetPlayerRole(player, SURVIVAL_ROLE_CANNON_FODDER);
IS_BOT_CLIENT(it))
{
Surv_SetPlayerRole(it, SURVIVAL_ROLE_CANNON_FODDER);
- --surv_numattackers;
+ Surv_ChangeNumberOfPlayers(teamnum, -1);
if (!IS_DEAD(it))
{
- --surv_numattackersalive;
+ Surv_ChangeNumberOfAlivePlayers(teamnum, -1);
}
removedbot = true;
break;
LOG_TRACE("Removed bot");
}
Surv_SetPlayerRole(player, SURVIVAL_ROLE_ATTACKER);
- ++surv_numattackers;
+ Surv_ChangeNumberOfPlayers(teamnum, +1);
++surv_numattackerhumans;
- LOG_TRACE("Numattackers = ", ftos(surv_numattackers),
- " human attackers = ", ftos(surv_numattackerhumans));
+ LOG_TRACE("Human attackers = ", ftos(surv_numattackerhumans));
return true;
}
case surv_defenderteam:
if (surv_numdefenders < autocvar_g_surv_team_size)
{
Surv_SetPlayerRole(player, SURVIVAL_ROLE_DEFENDER);
- ++surv_numdefenders;
- LOG_TRACE("Numdefenders = ", ftos(surv_numdefenders));
+ Surv_ChangeNumberOfPlayers(teamnum, +1);
return true;
}
LOG_TRACE("No space for defender, switching to attacker");
LOG_TRACE("Removed bot");
}
Surv_SetPlayerRole(player, SURVIVAL_ROLE_DEFENDER);
- ++surv_numdefenders;
+ Surv_ChangeNumberOfPlayers(teamnum, +1);
++surv_numdefenderhumans;
- LOG_TRACE("Numdefenders = ", ftos(surv_numdefenders),
- " human defenders = ", ftos(surv_numdefenderhumans));
+ LOG_TRACE("Human defenders = ", ftos(surv_numdefenderhumans));
return true;
}
}
return;
}
Surv_SetPlayerRole(player, SURVIVAL_ROLE_NONE);
- --surv_numattackers;
- LOG_TRACE("Removed attacker. Attackers = ",
- ftos(surv_numattackers));
+ Surv_ChangeNumberOfPlayers(teamnum, -1);
if (!IS_BOT_CLIENT(player))
{
--surv_numattackerhumans;
if (it.surv_role == SURVIVAL_ROLE_CANNON_FODDER)
{
Surv_SetPlayerRole(it, SURVIVAL_ROLE_ATTACKER);
- ++surv_numattackers;
+ Surv_ChangeNumberOfPlayers(teamnum, +1);
if (!IS_DEAD(it))
{
- ++surv_numattackersalive;
+ Surv_ChangeNumberOfAlivePlayers(teamnum, +1);
}
return;
}
return;
}
Surv_SetPlayerRole(player, SURVIVAL_ROLE_NONE);
- --surv_numdefenders;
- LOG_TRACE("Removed defender. Defenders = ",
- ftos(surv_numdefenders));
+ Surv_ChangeNumberOfPlayers(teamnum, -1);
if (!IS_BOT_CLIENT(player))
{
--surv_numdefenderhumans;
}
}
+/// \brief Updates stats of team count on HUD.
+/// \return No return.
+void Surv_UpdateTeamStats()
+{
+ // Debug stuff
+ if (surv_attackercolor == SURVIVAL_COLOR_RED)
+ {
+ yellowalive = surv_numattackers;
+ pinkalive = surv_numdefenders;
+ }
+ else
+ {
+ pinkalive = surv_numattackers;
+ yellowalive = surv_numdefenders;
+ }
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
+ {
+ it.yellowalive_stat = yellowalive;
+ it.pinkalive_stat = pinkalive;
+ });
+}
+
/// \brief Adds player to alive list. Handles bookkeeping information.
/// \param[in] player Player to add.
-/// \param[in] t Team of the player.
+/// \param[in] teamnum Team of the player.
/// \return No return.
-void Surv_AddPlayerToAliveList(entity player, int t)
+void Surv_AddPlayerToAliveList(entity player, int teamnum)
{
- switch (t)
+ switch (teamnum)
{
case surv_attackerteam:
{
if (player.surv_role == SURVIVAL_ROLE_ATTACKER)
{
- ++surv_numattackersalive;
- string message = strcat("Survival: Added alive attacker, total = ",
- ftos(surv_numattackersalive));
- LOG_TRACE(message);
- DebugPrintToChatAll(message);
+ Surv_ChangeNumberOfAlivePlayers(teamnum, +1);
}
- break;
+ return;
}
case surv_defenderteam:
{
- ++surv_numdefendersalive;
- string message = strcat("Survival: Added alive defender, total = ",
- ftos(surv_numdefendersalive));
- LOG_TRACE(message);
- DebugPrintToChatAll(message);
- break;
+ Surv_ChangeNumberOfAlivePlayers(teamnum, +1);
+ return;
}
}
- Surv_UpdateAliveStats();
}
/// \brief Removes player from alive list. Handles bookkeeping information.
/// \param[in] player Player to remove.
-/// \param[in] t Team of the player.
+/// \param[in] teamnum Team of the player.
/// \return No return.
-void Surv_RemovePlayerFromAliveList(entity player, int t)
+void Surv_RemovePlayerFromAliveList(entity player, int teamnum)
{
if (player.surv_attack_sprite)
{
WaypointSprite_Kill(player.surv_attack_sprite);
}
- switch (t)
+ switch (teamnum)
{
case surv_attackerteam:
{
if (player.surv_role == SURVIVAL_ROLE_ATTACKER)
{
- --surv_numattackersalive;
- string message = strcat("Survival: Removed alive attacker, total = ",
- ftos(surv_numattackersalive));
- LOG_TRACE(message);
- DebugPrintToChatAll(message);
+ Surv_ChangeNumberOfAlivePlayers(teamnum, -1);
}
- break;
+ return;
}
case surv_defenderteam:
{
// anything.
return;
}
- --surv_numdefendersalive;
- string message = strcat("Survival: Removed alive defender, total = ",
- ftos(surv_numdefendersalive));
- LOG_TRACE(message);
- DebugPrintToChatAll(message);
+ Surv_ChangeNumberOfAlivePlayers(teamnum, -1);
if (warmup_stage || surv_allowed_to_spawn)
{
- break;
+ return;
}
switch (surv_numdefendersalive)
{
{
sound(NULL, CH_TRIGGER, SND_SURV_1_FRAG_LEFT,
VOL_BASE, ATTEN_NONE);
- break;
+ return;
}
case 2:
{
sound(NULL, CH_TRIGGER, SND_SURV_2_FRAGS_LEFT,
VOL_BASE, ATTEN_NONE);
- break;
+ return;
}
case 3:
{
sound(NULL, CH_TRIGGER, SND_SURV_3_FRAGS_LEFT,
VOL_BASE, ATTEN_NONE);
- break;
+ return;
}
}
- break;
+ return;
}
}
- Surv_UpdateAliveStats();
}
/// \brief Counts alive players.
{
redalive = surv_numattackersalive;
bluealive = surv_numdefendersalive;
- yellowalive = surv_numattackers;
- pinkalive = surv_numdefenders;
}
else
{
bluealive = surv_numattackersalive;
redalive = surv_numdefendersalive;
- pinkalive = surv_numattackers;
- yellowalive = surv_numdefenders;
}
FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
it.surv_defenders_alive_stat = surv_numdefendersalive;
it.redalive_stat = redalive;
it.bluealive_stat = bluealive;
- it.yellowalive_stat = yellowalive;
- it.pinkalive_stat = pinkalive;
});
Surv_UpdateDefenderHealthStat();
}
player.surv_state = SURVIVAL_STATE_PLAYING;
//Surv_CountAlivePlayers();
Surv_AddPlayerToAliveList(player, player.team);
- //W_GiveWeapon(player, WEP_HMG.m_id);
- //W_GiveWeapon(player, WEP_RPC.m_id);
switch (player.team)
{
case surv_attackerteam:
case "item_strength":
{
W_GiveWeapon(player, WEP_HMG.m_id);
+ player.superweapons_finished = max(
+ player.superweapons_finished, time) +
+ autocvar_g_balance_superweapons_time;
Item_ScheduleRespawn(item);
sound(player, CH_TRIGGER, SND_Strength, VOL_BASE,
ATTEN_NORM);
case "item_invincible":
{
W_GiveWeapon(player, WEP_RPC.m_id);
+ player.superweapons_finished = max(
+ player.superweapons_finished, time) +
+ autocvar_g_balance_superweapons_time;
Item_ScheduleRespawn(item);
sound(player, CH_TRIGGER, SND_Shield, VOL_BASE, ATTEN_NORM);
return MUT_ITEMTOUCH_RETURN;