]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/clientkill.qc
mapinfo: fix and rename noautomaplist flag to donotwant
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / clientkill.qc
index aec5387c3eba0ed36274499cd774c7d13dcc6f9d..296a95bfe5f384c9d8428626f0a1cbd0282fff2f 100644 (file)
@@ -1,13 +1,19 @@
 #include "clientkill.qh"
 
-#include <server/defs.qh>
-
-#include "g_damage.qh"
-#include "teamplay.qh"
-
-#include <common/vehicles/sv_vehicles.qh>
+#include <common/csqcmodel_settings.qh>
+#include <common/deathtypes/all.qh>
+#include <common/mapobjects/triggers.qh>
 #include <common/notifications/all.qh>
 #include <common/stats.qh>
+#include <common/stats.qh>
+#include <common/vehicles/sv_vehicles.qh>
+#include <common/weapons/_all.qh>
+#include <server/client.qh>
+#include <server/damage.qh>
+#include <server/mutators/_mod.qh>
+#include <server/player.qh>
+#include <server/round_handler.qh>
+#include <server/teamplay.qh>
 
 void ClientKill_Now_TeamChange(entity this)
 {
@@ -19,10 +25,13 @@ void ClientKill_Now_TeamChange(entity this)
        {
                if (blockSpectators)
                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
-               PutObserverInServer(this);
+               PutObserverInServer(this, false, true);
        }
        else
-               SV_ChangeTeam(this, this.killindicator_teamchange - 1);
+       {
+               Player_SetTeamIndexChecked(this, Team_TeamToIndex(
+                       this.killindicator_teamchange));
+       }
        this.killindicator_teamchange = 0;
 }
 
@@ -55,14 +64,7 @@ void ClientKill_Now(entity this)
 }
 void KillIndicator_Think(entity this)
 {
-       if (game_stopped)
-       {
-               this.owner.killindicator = NULL;
-               delete(this);
-               return;
-       }
-
-       if (this.owner.alpha < 0 && !this.owner.vehicle)
+       if (game_stopped || (this.owner.alpha < 0 && !this.owner.vehicle))
        {
                this.owner.killindicator = NULL;
                delete(this);
@@ -74,12 +76,9 @@ void KillIndicator_Think(entity this)
                ClientKill_Now(this.owner);
                return;
        }
-       else if (this.count == 1) // count == 1 means that it's silent
-       {
-               this.nextthink = time + 1;
-               this.cnt -= 1;
-       }
-       else
+
+       // count == 1 means that it's silent
+       if (this.count != 1)
        {
                if (this.cnt <= 10)
                        setmodel(this, MDL_NUM(this.cnt));
@@ -88,9 +87,9 @@ void KillIndicator_Think(entity this)
                        if (this.cnt <= 10)
                                Send_Notification(NOTIF_ONE, this.owner, MSG_ANNCE, Announcer_PickNumber(CNT_KILL, this.cnt));
                }
-               this.nextthink = time + 1;
-               this.cnt -= 1;
        }
+       this.nextthink = time + 1;
+       this.cnt -= 1;
 }
 
 .float lip;
@@ -107,14 +106,27 @@ void ClientKill_TeamChange(entity this, float targetteam) // 0 = don't change, -
                return;
        killtime = M_ARGV(1, float);
 
+       if(round_handler_IsActive() && !round_handler_IsRoundStarted())
+               killtime = min(killtime, 1);
+
        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))
                {
                        killtime = max(killtime, this.clientkill_nexttime - time);
-                       this.clientkill_nexttime = time + killtime + autocvar_g_balance_kill_antispam;
+                       float antispam_delay = autocvar_g_balance_kill_antispam;
+                       if(round_handler_IsActive() && !round_handler_IsRoundStarted())
+                               antispam_delay = min(antispam_delay, 2);
+                       this.clientkill_nexttime = time + killtime + antispam_delay;
                }
 
                if (killtime <= 0 || !IS_PLAYER(this) || IS_DEAD(this))
@@ -125,7 +137,7 @@ void ClientKill_TeamChange(entity this, float targetteam) // 0 = don't change, -
                {
                        float starttime = max(time, clientkilltime);
 
-                       this.killindicator = spawn();
+                       this.killindicator = new(killindicator);
                        this.killindicator.owner = this;
                        this.killindicator.scale = 0.5;
                        setattachment(this.killindicator, this, "");
@@ -137,9 +149,9 @@ void ClientKill_TeamChange(entity this, float targetteam) // 0 = don't change, -
                        this.killindicator.count = bound(0, ceil(killtime), 10);
                        //sprint(this, strcat("^1You'll be dead in ", ftos(this.killindicator.cnt), " seconds\n"));
 
-                       IL_EACH(g_clones, it.enemy == this && !(it.effects & CSQCMODEL_EF_RESPAWNGHOST),
+                       IL_EACH(g_clones, it.enemy == this && !(it.effects & CSQCMODEL_EF_RESPAWNGHOST) && !it.killindicator,
                        {
-                               it.killindicator = spawn();
+                               it.killindicator = new(killindicator);
                                it.killindicator.owner = it;
                                it.killindicator.scale = 0.5;
                                setattachment(it.killindicator, it, "");
@@ -154,43 +166,47 @@ void ClientKill_TeamChange(entity this, float targetteam) // 0 = don't change, -
        }
        if (this.killindicator)
        {
+               Notification notif;
                if (targetteam == 0) // just die
                {
                        this.killindicator.colormod = '0 0 0';
-                       if(IS_REAL_CLIENT(this))
-                       if(this.killindicator.cnt > 0)
-                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_TEAMCHANGE_SUICIDE, this.killindicator.cnt);
+                       notif = CENTER_TEAMCHANGE_SUICIDE;
                }
                else if (targetteam == -1) // auto
                {
                        this.killindicator.colormod = '0 1 0';
-                       if(IS_REAL_CLIENT(this))
-                       if(this.killindicator.cnt > 0)
-                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_TEAMCHANGE_AUTO, this.killindicator.cnt);
+                       notif = CENTER_TEAMCHANGE_AUTO;
                }
                else if (targetteam == -2) // spectate
                {
                        this.killindicator.colormod = '0.5 0.5 0.5';
-                       if(IS_REAL_CLIENT(this))
-                       if(this.killindicator.cnt > 0)
-                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_TEAMCHANGE_SPECTATE, this.killindicator.cnt);
+                       notif = CENTER_TEAMCHANGE_SPECTATE;
                }
                else
                {
                        this.killindicator.colormod = Team_ColorRGB(targetteam);
-                       if(IS_REAL_CLIENT(this))
-                       if(this.killindicator.cnt > 0)
-                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, APP_TEAM_NUM(targetteam, CENTER_TEAMCHANGE), this.killindicator.cnt);
+                       notif = APP_TEAM_NUM(targetteam, CENTER_TEAMCHANGE);
                }
+               if (IS_REAL_CLIENT(this) && this.killindicator.cnt > 0)
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, notif, this.killindicator.cnt);
        }
 
 }
 
+void ClientKill_Silent(entity this, float _delay)
+{
+       this.killindicator = new(killindicator);
+       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)
 {
-       // TODO: once .health is removed, will need to check it here for the "already dead" message!
-
        if (game_stopped || this.player_blocked || STAT(FROZEN, this))
                return;