From: Lyberta Date: Sat, 3 Jun 2017 19:54:26 +0000 (+0300) Subject: Survival: Better team switching. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9f6f37772a518aff4e98e5eb916e59f558e3057f;p=xonotic%2Fxonotic-data.pk3dir.git Survival: Better team switching. --- diff --git a/qcsrc/server/mutators/mutator/gamemode_survival.qc b/qcsrc/server/mutators/mutator/gamemode_survival.qc index 8ec252f11..e4bdfd30c 100644 --- a/qcsrc/server/mutators/mutator/gamemode_survival.qc +++ b/qcsrc/server/mutators/mutator/gamemode_survival.qc @@ -1499,6 +1499,37 @@ MUTATOR_HOOKFUNCTION(surv, Player_ChangedTeam) } } +/// \brief Hook that is called when player is about to be killed when changing +/// teams. +MUTATOR_HOOKFUNCTION(surv, Player_ChangeTeamKill) +{ + entity player = M_ARGV(0, entity); + if (player.team != surv_defenderteam) + { + return false; + } + if (player.surv_savedplayerstate == NULL) + { + return false; + } + Surv_RestorePlayerState(player, player.surv_savedplayerstate); + delete(player.surv_savedplayerstate); + player.surv_savedplayerstate = NULL; + return true; +} + +/// \brief Hook that is called when player is about to be killed as a result of +/// the kill command or changing teams. +MUTATOR_HOOKFUNCTION(surv, ClientKill_Now) +{ + entity player = M_ARGV(0, entity); + if (player.team == surv_defenderteam) + { + // Deny suicide. + return true; + } +} + /// \brief Hook that is called when player connects to the server. MUTATOR_HOOKFUNCTION(surv, ClientConnect) {