From 1d2cdc2b55bbf1ee7b3da301ed8db70a3654f630 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 14 Aug 2018 23:25:41 +0200 Subject: [PATCH] Move more ClientKill code to clientkill.qc --- qcsrc/common/gamemodes/gamemode/cts/cts.qc | 27 ++-------------------- qcsrc/server/clientkill.qc | 18 +++++++++++++++ qcsrc/server/clientkill.qh | 1 + 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/cts/cts.qc b/qcsrc/common/gamemodes/gamemode/cts/cts.qc index 619028934..d1aaa9632 100644 --- a/qcsrc/common/gamemodes/gamemode/cts/cts.qc +++ b/qcsrc/common/gamemodes/gamemode/cts/cts.qc @@ -66,18 +66,6 @@ void cts_EventLog(string mode, entity actor) // use an alias for easy changing a GameLogEcho(strcat(":cts:", mode, ":", ((actor != NULL) ? (strcat(":", ftos(actor.playerid))) : ""))); } -void KillIndicator_Think(entity this); -void CTS_ClientKill(entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed -{ - e.killindicator = spawn(); - e.killindicator.owner = e; - setthink(e.killindicator, KillIndicator_Think); - e.killindicator.nextthink = time + (e.lip) * 0.05; - e.killindicator.cnt = ceil(autocvar_g_cts_finish_kill_delay); - e.killindicator.count = 1; // this is used to indicate that it should be silent - e.lip = 0; -} - MUTATOR_HOOKFUNCTION(cts, PlayerPhysics) { entity player = M_ARGV(0, entity); @@ -379,29 +367,18 @@ MUTATOR_HOOKFUNCTION(cts, GetRecords) M_ARGV(1, string) = ret_string; } -void ClientKill_Now(entity this); MUTATOR_HOOKFUNCTION(cts, ClientKill) { - entity player = M_ARGV(0, entity); - M_ARGV(1, float) = 0; // kill delay - - if(player.killindicator && player.killindicator.count == 1) // player.killindicator.count == 1 means that the kill indicator was spawned by CTS_ClientKill - { - delete(player.killindicator); - player.killindicator = NULL; - - ClientKill_Now(player); // allow instant kill in this case - return; - } } MUTATOR_HOOKFUNCTION(cts, Race_FinalCheckpoint) { entity player = M_ARGV(0, entity); + // useful to prevent cheating by running back to the start line and starting out with more speed if(autocvar_g_cts_finish_kill_delay) - CTS_ClientKill(player); + ClientKill_Silent(player, autocvar_g_cts_finish_kill_delay); } MUTATOR_HOOKFUNCTION(cts, HideTeamNagger) diff --git a/qcsrc/server/clientkill.qc b/qcsrc/server/clientkill.qc index be020a772..0bb761483 100644 --- a/qcsrc/server/clientkill.qc +++ b/qcsrc/server/clientkill.qc @@ -99,6 +99,13 @@ void ClientKill_TeamChange(entity this, float targetteam) // 0 = don't change, - this.killindicator_teamchange = targetteam; + // this.killindicator.count == 1 means that the kill indicator was spawned by ClientKill_Silent + if(killtime <= 0 && this.killindicator && this.killindicator.count == 1) + { + ClientKill_Now(this); // allow instant kill in this case + return; + } + if (!this.killindicator) { if (!IS_DEAD(this)) @@ -171,6 +178,17 @@ void ClientKill_TeamChange(entity this, float targetteam) // 0 = don't change, - } +void ClientKill_Silent(entity this, float _delay) +{ + this.killindicator = spawn(); + this.killindicator.owner = this; + setthink(this.killindicator, KillIndicator_Think); + this.killindicator.nextthink = time + (this.lip) * 0.05; + this.killindicator.cnt = ceil(_delay); + this.killindicator.count = 1; // this is used to indicate that it should be silent + this.lip = 0; +} + // Called when a client types 'kill' in the console void ClientKill(entity this) { diff --git a/qcsrc/server/clientkill.qh b/qcsrc/server/clientkill.qh index 33c4adb5a..5b26adf91 100644 --- a/qcsrc/server/clientkill.qh +++ b/qcsrc/server/clientkill.qh @@ -7,4 +7,5 @@ void ClientKill_Now_TeamChange(entity this); void ClientKill_Now(entity this); void KillIndicator_Think(entity this); void ClientKill_TeamChange(entity this, float targetteam); // 0 = don't change, -1 = auto, -2 = spec +void ClientKill_Silent(entity this, float _delay); void ClientKill(entity this); -- 2.39.2