]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move more ClientKill code to clientkill.qc
authorterencehill <piuntn@gmail.com>
Tue, 14 Aug 2018 21:25:41 +0000 (23:25 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 14 Aug 2018 21:25:41 +0000 (23:25 +0200)
qcsrc/common/gamemodes/gamemode/cts/cts.qc
qcsrc/server/clientkill.qc
qcsrc/server/clientkill.qh

index 6190289347279b30c5d47d08c5da06c851fc1fbb..d1aaa9632d26ffcfbe3584b021d6f6bb4bd9dc3d 100644 (file)
@@ -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)
index be020a77269eebbbdfce113f144bcf59ba3843ac..0bb761483b19bb8433c8bf968dad5fa3679b8f19 100644 (file)
@@ -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)
 {
index 33c4adb5ab94c7d7e879fffd4eff955999d2b60c..5b26adf9150f155caa4551c6a08e9b0fcdcb56e7 100644 (file)
@@ -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);