From 8355e166329453efd962910ebad1b225b48ef70a Mon Sep 17 00:00:00 2001 From: Lyberta Date: Sat, 5 Aug 2017 00:26:41 +0300 Subject: [PATCH] Added KillPlayerForTeamChange. --- qcsrc/server/teamplay.qc | 36 +++++++++++++++++------------------- qcsrc/server/teamplay.qh | 5 +++++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 1fce2694e..92cd8ebcc 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -183,6 +183,20 @@ void SetPlayerColors(entity player, float _color) } } +void KillPlayerForTeamChange(entity player) +{ + if (IS_DEAD(player)) + { + return; + } + if (MUTATOR_CALLHOOK(Player_ChangeTeamKill, player) == true) + { + return; + } + Damage(player, player, player, 100000, DEATH_TEAMCHANGE.m_id, player.origin, + '0 0 0'); +} + bool SetPlayerTeamSimple(entity player, int team_num) { if (player.team == team_num) @@ -887,11 +901,7 @@ int JoinBestTeam(entity this, bool only_return_best, bool force_best_team) { AutoBalanceBots(old_team, Team_TeamToNumber(best_team)); } - if (!IS_DEAD(this) && (MUTATOR_CALLHOOK(Player_ChangeTeamKill, this) == - false)) - { - Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0'); - } + KillPlayerForTeamChange(this); return best_team; } @@ -962,12 +972,7 @@ void SV_ChangeTeam(entity this, float _color) { return; } - // kill player when changing teams - if (IS_DEAD(this) || (MUTATOR_CALLHOOK(Player_ChangeTeamKill, this) == true)) - { - return; - } - Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0'); + KillPlayerForTeamChange(this); } void AutoBalanceBots(int source_team, int destination_team) @@ -1041,12 +1046,5 @@ void AutoBalanceBots(int source_team, int destination_team) } SetPlayerTeamSimple(lowest_bot_destination_team, Team_NumberToTeam(source_team)); - if (IS_DEAD(lowest_bot_destination_team) || (MUTATOR_CALLHOOK( - Player_ChangeTeamKill, lowest_bot_destination_team) == true)) - { - return; - } - Damage(lowest_bot_destination_team, lowest_bot_destination_team, - lowest_bot_destination_team, 100000, DEATH_TEAMCHANGE.m_id, - lowest_bot_destination_team.origin, '0 0 0'); + KillPlayerForTeamChange(lowest_bot_destination_team); } diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index a2cc6ca05..5311d4cb0 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -47,6 +47,11 @@ string getwelcomemessage(entity this); void SetPlayerColors(entity player, float _color); +/// \brief Kills player as a result of team change. +/// \param[in,out] player Player to kill. +/// \return No return. +void KillPlayerForTeamChange(entity player); + /// \brief Sets the team of the player. /// \param[in,out] player Player to adjust. /// \param[in] team_num Team number to set. See TEAM_NUM constants. -- 2.39.2