]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Survival: Better team switching.
authorLyberta <lyberta@lyberta.net>
Sat, 3 Jun 2017 19:54:26 +0000 (22:54 +0300)
committerLyberta <lyberta@lyberta.net>
Sat, 3 Jun 2017 19:54:26 +0000 (22:54 +0300)
qcsrc/server/mutators/mutator/gamemode_survival.qc

index 8ec252f11424b8a5d34967d1644743eaf1af42b2..e4bdfd30ccdb1105acdc4a889d02643325b35906 100644 (file)
@@ -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)
 {