]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
try renaming charge_pool to chargepool to make the cvar name a bit shorter
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 7c1d6bd97f168a9d2a9820b3332de417d569bcb4..a13f4afbc2d7939142d7999c7daa23377c3742a7 100644 (file)
@@ -603,10 +603,16 @@ void PutObserverInServer (void)
 
        Portal_ClearAll(self);
 
+       if(self.alivetime)
+       {
+               PlayerStats_Event(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
+               self.alivetime = 0;
+       }
+
        if(self.flagcarried)
                DropFlag(self.flagcarried, world, world);
 
-       if(self.ballcarried)
+       if(self.ballcarried && g_nexball)
                DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
 
        WaypointSprite_PlayerDead();
@@ -796,8 +802,8 @@ void FixPlayermodel()
 
        if(!teams_matter)
                if(strlen(cvar_string("sv_defaultplayercolors")))
-                       if(self.clientcolors != cvar("sv_defaultplayercolors"))
-                               setcolor(self, cvar("sv_defaultplayercolors"));
+                       if(self.clientcolors != stof(cvar_string("sv_defaultplayercolors")))
+                               setcolor(self, stof(cvar_string("sv_defaultplayercolors")));
 }
 
 void PlayerTouchExplode(entity p1, entity p2)
@@ -894,8 +900,8 @@ void PutClientInServer (void)
                self.dmg = 2;
                if(cvar("g_balance_nex_charge"))
                {
-                       if(cvar("g_balance_nex_secondary_charge_pool"))
-                               self.nex_charge_pool_ammo = 1;
+                       if(cvar("g_balance_nex_secondary_chargepool"))
+                               self.nex_chargepool_ammo = 1;
                        self.nex_charge = cvar("g_balance_nex_charge_start");
                }
 
@@ -1074,6 +1080,9 @@ void PutClientInServer (void)
                self.switchweapon = w_getbestweapon(self);
                self.cnt = self.switchweapon;
                self.weapon = 0;
+
+               if(!self.alivetime)
+                       self.alivetime = time;
        } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
                PutObserverInServer ();
        }
@@ -1338,6 +1347,10 @@ void ClientKill (void)
        {
                // do nothing
        }
+    else if(g_freezetag && self.freezetag_frozen == 1)
+    {
+        // do nothing
+    }
        else
                ClientKill_TeamChange(0);
 }
@@ -1500,7 +1513,7 @@ void ClientConnect (void)
 
        PlayerScore_Attach(self);
        ClientData_Attach();
-       accuracy_init();
+       accuracy_init(self);
 
        bot_clientconnect();
 
@@ -1701,6 +1714,8 @@ void ClientConnect (void)
        send_CSQC_cr_maxbullets(self);
 
        CheatInitClient();
+
+       PlayerStats_AddPlayer(self);
 }
 
 /*
@@ -1721,6 +1736,8 @@ void ClientDisconnect (void)
                return;
        }
 
+       PlayerStats_AddGlobalInfo(self);
+
        CheatShutdownClient();
 
        if(self.hitplotfh >= 0)
@@ -1753,7 +1770,7 @@ void ClientDisconnect (void)
 
        if(self.flagcarried)
                DropFlag(self.flagcarried, world, world);
-       if(self.ballcarried)
+       if(self.ballcarried && g_nexball)
                DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
 
        // Here, everything has been done that requires this player to be a client.
@@ -1779,7 +1796,7 @@ void ClientDisconnect (void)
                Spawnqueue_Remove(self);
        }
 
-       accuracy_free();
+       accuracy_free(self);
        ClientData_Detach();
        PlayerScore_Detach(self);
 
@@ -1987,6 +2004,9 @@ string getTimeoutText(float addOneSecond) {
 
 void player_powerups (void)
 {
+       // add a way to see what the items were BEFORE all of these checks for the mutator hook
+       olditems = self.items;
+       
        if((self.items & IT_USING_JETPACK) && !self.deadflag)
        {
                SoundEntity_StartSound(self, CHAN_PLAYER, "misc/jetpack_fly.wav", VOL_BASE, cvar("g_jetpack_attenuation"));
@@ -2049,64 +2069,67 @@ void player_powerups (void)
                                sprint(self, "^3You are on speed\n");
                        }
                }
-               return;
        }
-
-       if (self.items & IT_STRENGTH)
+       else // if we're not in minstagib, continue. I added this else to replace the "return" which was here that broke the callhook for this function -- This code is nasty.
        {
-               play_countdown(self.strength_finished, "misc/poweroff.wav");
-               self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
-               if (time > self.strength_finished && cvar("g_balance_powerup_timer"))
+               if (self.items & IT_STRENGTH)
                {
-                       self.items = self.items - (self.items & IT_STRENGTH);
-                       sprint(self, "^3Strength has worn off\n");
+                       play_countdown(self.strength_finished, "misc/poweroff.wav");
+                       self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
+                       if (time > self.strength_finished && cvar("g_balance_powerup_timer"))
+                       {
+                               self.items = self.items - (self.items & IT_STRENGTH);
+                               sprint(self, "^3Strength has worn off\n");
+                       }
                }
-       }
-       else
-       {
-               if (time < self.strength_finished)
+               else
                {
-                       self.items = self.items | IT_STRENGTH;
-                       sprint(self, "^3Strength infuses your weapons with devastating power\n");
+                       if (time < self.strength_finished)
+                       {
+                               self.items = self.items | IT_STRENGTH;
+                               sprint(self, "^3Strength infuses your weapons with devastating power\n");
+                       }
                }
-       }
-       if (self.items & IT_INVINCIBLE)
-       {
-               play_countdown(self.invincible_finished, "misc/poweroff.wav");
-               self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
-               if (time > self.invincible_finished && cvar("g_balance_powerup_timer"))
+               if (self.items & IT_INVINCIBLE)
                {
-                       self.items = self.items - (self.items & IT_INVINCIBLE);
-                       sprint(self, "^3Shield has worn off\n");
+                       play_countdown(self.invincible_finished, "misc/poweroff.wav");
+                       self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
+                       if (time > self.invincible_finished && cvar("g_balance_powerup_timer"))
+                       {
+                               self.items = self.items - (self.items & IT_INVINCIBLE);
+                               sprint(self, "^3Shield has worn off\n");
+                       }
                }
-       }
-       else
-       {
-               if (time < self.invincible_finished)
+               else
                {
-                       self.items = self.items | IT_INVINCIBLE;
-                       sprint(self, "^3Shield surrounds you\n");
+                       if (time < self.invincible_finished)
+                       {
+                               self.items = self.items | IT_INVINCIBLE;
+                               sprint(self, "^3Shield surrounds you\n");
+                       }
                }
-       }
 
-       if(cvar("g_nodepthtestplayers"))
-               self.effects = self.effects | EF_NODEPTHTEST;
+               if(cvar("g_nodepthtestplayers"))
+                       self.effects = self.effects | EF_NODEPTHTEST;
 
-       if(cvar("g_fullbrightplayers"))
-               self.effects = self.effects | EF_FULLBRIGHT;
+               if(cvar("g_fullbrightplayers"))
+                       self.effects = self.effects | EF_FULLBRIGHT;
 
-       // midair gamemode: damage only while in the air
-       // if in midair mode, being on ground grants temporary invulnerability
-       // (this is so that multishot weapon don't clear the ground flag on the
-       // first damage in the frame, leaving the player vulnerable to the
-       // remaining hits in the same frame)
-       if (self.flags & FL_ONGROUND)
-       if (g_midair)
-               self.spawnshieldtime = max(self.spawnshieldtime, time + cvar("g_midair_shieldtime"));
+               // midair gamemode: damage only while in the air
+               // if in midair mode, being on ground grants temporary invulnerability
+               // (this is so that multishot weapon don't clear the ground flag on the
+               // first damage in the frame, leaving the player vulnerable to the
+               // remaining hits in the same frame)
+               if (self.flags & FL_ONGROUND)
+               if (g_midair)
+                       self.spawnshieldtime = max(self.spawnshieldtime, time + cvar("g_midair_shieldtime"));
 
-       if (time >= game_starttime)
-       if (time < self.spawnshieldtime)
-               self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
+               if (time >= game_starttime)
+               if (time < self.spawnshieldtime)
+                       self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
+       }
+       
+       MUTATOR_CALLHOOK(PlayerPowerups);
 }
 
 float CalcRegen(float current, float stable, float regenfactor, float regenframetime)
@@ -3042,7 +3065,7 @@ void PlayerPostThink (void)
 
        playerdemo_write();
 
-       if((g_cts || g_race) && self.cvar_cl_allow_uid2name)
+       if((g_cts || g_race) && self.cvar_cl_allow_uid2name == 1)
        {
                if(!self.stored_netname)
                        self.stored_netname = strzone(uid2name(self.crypto_idfp));