]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge branch 'master' into mirceakitsune/per_character_sounds
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index f7be50277e62b0301c1f1fec5c93891537bcf25a..cf941e9e3c2ee269d7a3b171791a3a22a09ebed4 100644 (file)
@@ -13,10 +13,13 @@ void Announce(string snd) {
 }
 
 void AnnounceTo(entity e, string snd) {
-       msg_entity = e;
-       WriteByte(MSG_ONE, SVC_TEMPENTITY);
-       WriteByte(MSG_ONE, TE_CSQC_ANNOUNCE);
-       WriteString(MSG_ONE, snd);
+       if (clienttype(e) == CLIENTTYPE_REAL)
+       {
+               msg_entity = e;
+               WriteByte(MSG_ONE, SVC_TEMPENTITY);
+               WriteByte(MSG_ONE, TE_CSQC_ANNOUNCE);
+               WriteString(MSG_ONE, snd);
+       }
 }
 
 float ClientData_Send(entity to, float sf)
@@ -405,6 +408,7 @@ string CheckPlayerModel(string plyermodel) {
        {
                if(substring(plyermodel,-4,4) != ".zym")
                if(substring(plyermodel,-4,4) != ".dpm")
+               if(substring(plyermodel,-4,4) != ".iqm")
                if(substring(plyermodel,-4,4) != ".md3")
                if(substring(plyermodel,-4,4) != ".psk")
                        return FallbackPlayerModel;
@@ -504,7 +508,6 @@ float Client_customizeentityforclient()
        return TRUE;
 }
 
-void UpdatePlayerSounds();
 void setmodel_lod(entity e, string modelname)
 {
        string s;
@@ -552,7 +555,6 @@ void setmodel_lod(entity e, string modelname)
        self.modelindex_lod0_from_xonotic = ((s == "") || (substring(s, 0, 4) == "data"));
 
        player_setupanimsformodel();
-       UpdatePlayerSounds();
 }
 
 /*
@@ -899,9 +901,6 @@ void PutClientInServer (void)
                        self.weapons = randombits(self.weapons, g_weaponarena_random, FALSE);
 
                self.items = start_items;
-               self.switchweapon = w_getbestweapon(self);
-               self.cnt = self.switchweapon;
-               self.weapon = 0;
                self.jump_interval = time;
 
                self.spawnshieldtime = time + cvar("g_spawnshieldtime");
@@ -1039,6 +1038,10 @@ void PutClientInServer (void)
                self = oldself;
 
                MUTATOR_CALLHOOK(PlayerSpawn);
+
+               self.switchweapon = w_getbestweapon(self);
+               self.cnt = self.switchweapon;
+               self.weapon = 0;
        } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
                PutObserverInServer ();
        }
@@ -1059,14 +1062,50 @@ float ClientInit_SendEntity(entity to, float sf)
                WriteString(MSG_ENTITY, world.fog);
        else
                WriteString(MSG_ENTITY, "");
-       WriteByte(MSG_ENTITY, cvar("g_balance_armor_blockpercent") * 255.0);
-       WriteByte(MSG_ENTITY, cvar("g_balance_weaponswitchdelay") * 255.0);
+       WriteByte(MSG_ENTITY, self.count * 255.0); // g_balance_armor_blockpercent
+       WriteByte(MSG_ENTITY, self.cnt * 255.0); // g_balance_weaponswitchdelay
+       WriteCoord(MSG_ENTITY, self.bouncefactor); // g_balance_grenadelauncher_secondary_bouncefactor
+       WriteCoord(MSG_ENTITY, self.bouncestop); // g_balance_grenadelauncher_secondary_bouncestop
        return TRUE;
 }
 
+void ClientInit_CheckUpdate()
+{
+       self.nextthink = time;
+       if(self.count != cvar("g_balance_armor_blockpercent"))
+       {
+               self.count = cvar("g_balance_armor_blockpercent");
+               self.SendFlags |= 1;
+       }
+       if(self.cnt != cvar("g_balance_weaponswitchdelay"))
+       {
+               self.cnt = cvar("g_balance_weaponswitchdelay");
+               self.SendFlags |= 1;
+       }
+       if(self.bouncefactor != cvar("g_balance_grenadelauncher_secondary_bouncefactor"))
+       {
+               self.bouncefactor = cvar("g_balance_grenadelauncher_secondary_bouncefactor");
+               self.SendFlags |= 1;
+       }
+       if(self.bouncestop != cvar("g_balance_grenadelauncher_secondary_bouncestop"))
+       {
+               self.bouncestop = cvar("g_balance_grenadelauncher_secondary_bouncestop");
+               self.SendFlags |= 1;
+       }
+}
+
 void ClientInit_Spawn()
 {
-       Net_LinkEntity(spawn(), FALSE, 0, ClientInit_SendEntity);
+       entity o;
+       entity e;
+       e.classname = "clientinit";
+       e.think = ClientInit_CheckUpdate;
+       e.nextthink = time;
+       Net_LinkEntity(e, FALSE, 0, ClientInit_SendEntity);
+       o = self;
+       self = e;
+       ClientInit_CheckUpdate();
+       self = o;
 }
 
 /*
@@ -1743,10 +1782,31 @@ void UpdateTeamBubble()
        else self.colormod = '1 1 1';
 };*/
 
+.float oldcolormap;
 void respawn(void)
 {
+       if(self.modelindex != 0 && cvar("g_respawn_ghosts"))
+       {
+               self.solid = SOLID_NOT;
+               self.takedamage = DAMAGE_NO;
+               self.movetype = MOVETYPE_FLY;
+               self.velocity = '0 0 1' * cvar("g_respawn_ghosts_speed");
+               self.avelocity = randomvec() * cvar("g_respawn_ghosts_speed") * 3 - randomvec() * cvar("g_respawn_ghosts_speed") * 3;
+               self.effects |= EF_ADDITIVE;
+               self.oldcolormap = self.colormap;
+               self.colormap = 512;
+               pointparticles(particleeffectnum("respawn_ghost"), self.origin, '0 0 0', 1);
+               if(cvar("g_respawn_ghosts_maxtime"))
+                       SUB_SetFade (self, time + cvar("g_respawn_ghosts_maxtime") / 2 + random () * (cvar("g_respawn_ghosts_maxtime") - cvar("g_respawn_ghosts_maxtime") / 2), 1.5);
+       }
+
        CopyBody(1);
        self.effects |= EF_NODRAW; // prevent another CopyBody
+       if(self.oldcolormap)
+       {
+               self.colormap = self.oldcolormap;
+               self.oldcolormap = 0;
+       }
        PutClientInServer();
 }
 
@@ -2048,6 +2108,7 @@ void SetZoomState(float z)
 }
 
 void GetPressedKeys(void) {
+       MUTATOR_CALLHOOK(GetPressedKeys);
        if (self.movement_x > 0) // get if movement keys are pressed
        {       // forward key pressed
                self.pressedkeys |= KEY_FORWARD;
@@ -2490,6 +2551,8 @@ void PlayerPreThink (void)
                return;
 #endif
 
+       MUTATOR_CALLHOOK(PlayerPreThink);
+
        if(self.classname == "player") {
 //             if(self.netname == "Wazat")
 //                     bprint(self.classname, "\n");
@@ -2523,8 +2586,7 @@ void PlayerPreThink (void)
 
                if(frametime)
                {
-                       if(cvar("gameversion") >= 20600) // only do this for 2.6 and above FIXME remove this check when making 2.6
-                               self.glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2;
+                       self.glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2;
                        player_powerups();
                }
 
@@ -2844,7 +2906,6 @@ void PlayerPostThink (void)
                        ImpulseCommands();
                if (intermission_running)
                        return;         // intermission or finale
-
                GetPressedKeys();
        } else if (self.classname == "observer") {
                //do nothing