]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_player.qc
Merge remote branch 'origin/terencehill/arena_and_ca_fixes'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_player.qc
index 2b3e4d4db1995400d26feaeeaa73af814b8c8e74..07dc0788b341ebf88d0750271f4e0214fcc92c70 100644 (file)
@@ -124,6 +124,22 @@ void WeaponStats_LogKill(float awep, float abot, float vwep, float vbot)
 .entity pusher;
 .float pushltime;
 
+.float CopyBody_nextthink;
+.void(void) CopyBody_think;
+void CopyBody_Think(void)
+{
+       if(self.CopyBody_nextthink && time > self.CopyBody_nextthink)
+       {
+               self.CopyBody_think();
+               if(wasfreed(self))
+                       return;
+               self.CopyBody_nextthink = self.nextthink;
+               self.CopyBody_think = self.think;
+               self.think = CopyBody_Think;
+       }
+       CSQCMODEL_AUTOUPDATE();
+       self.nextthink = time;
+}
 void CopyBody(float keepvelocity)
 {
        entity oldself;
@@ -134,7 +150,6 @@ void CopyBody(float keepvelocity)
        self.enemy = oldself;
        self.lip = oldself.lip;
        self.colormap = oldself.colormap;
-       self.glowmod = oldself.glowmod;
        self.iscreature = oldself.iscreature;
        self.damagedbycontents = oldself.damagedbycontents;
        self.angles = oldself.angles;
@@ -142,6 +157,7 @@ void CopyBody(float keepvelocity)
        self.classname = "body";
        self.damageforcescale = oldself.damageforcescale;
        self.effects = oldself.effects;
+       self.glowmod = oldself.glowmod;
        self.event_damage = oldself.event_damage;
        self.animstate_startframe = oldself.animstate_startframe;
        self.animstate_numframes = oldself.animstate_numframes;
@@ -150,32 +166,28 @@ void CopyBody(float keepvelocity)
        self.animstate_endtime = oldself.animstate_endtime;
        self.animstate_override = oldself.animstate_override;
        self.animstate_looping = oldself.animstate_looping;
+       self.dphitcontentsmask = oldself.dphitcontentsmask;
+       self.death_time = oldself.death_time;
        self.frame = oldself.frame;
-       self.dead_frame = oldself.dead_frame;
        self.pain_finished = oldself.pain_finished;
        self.health = oldself.health;
        self.armorvalue = oldself.armorvalue;
        self.armortype = oldself.armortype;
        self.model = oldself.model;
        self.modelindex = oldself.modelindex;
-       self.modelindex_lod0 = oldself.modelindex_lod0;
-       self.modelindex_lod0_from_xonotic = oldself.modelindex_lod0_from_xonotic;
-       self.modelindex_lod1 = oldself.modelindex_lod1;
-       self.modelindex_lod2 = oldself.modelindex_lod2;
-       self.skinindex = oldself.skinindex;
+       self.skin = oldself.skin;
        self.species = oldself.species;
        self.movetype = oldself.movetype;
-       self.nextthink = oldself.nextthink;
        self.solid = oldself.solid;
        self.ballistics_density = oldself.ballistics_density;
        self.takedamage = oldself.takedamage;
-       self.think = oldself.think;
        self.customizeentityforclient = oldself.customizeentityforclient;
        self.uncustomizeentityforclient = oldself.uncustomizeentityforclient;
        self.uncustomizeentityforclient_set = oldself.uncustomizeentityforclient_set;
        if (keepvelocity == 1)
                self.velocity = oldself.velocity;
        self.oldvelocity = self.velocity;
+       self.alpha = oldself.alpha;
        self.fade_time = oldself.fade_time;
        self.fade_rate = oldself.fade_rate;
        //self.weapon = oldself.weapon;
@@ -187,7 +199,13 @@ void CopyBody(float keepvelocity)
        Drag_MoveDrag(oldself, self);
 
        if(self.colormap <= maxclients && self.colormap > 0)
-               self.colormap = 1024 + self.clientcolors;
+               self.colormap = 1024 + oldself.clientcolors;
+
+       CSQCMODEL_AUTOINIT();
+       self.CopyBody_nextthink = oldself.nextthink;
+       self.CopyBody_think = oldself.think;
+       self.nextthink = time;
+       self.think = CopyBody_Think;
 
        self = oldself;
 }
@@ -195,7 +213,7 @@ void CopyBody(float keepvelocity)
 float player_getspecies()
 {
        float s;
-       get_model_parameters(self.model, self.skinindex);
+       get_model_parameters(self.model, self.skin);
        s = get_model_parameters_species;
        get_model_parameters(string_null, 0);
        if(s < 0)
@@ -223,20 +241,20 @@ void player_setupanimsformodel()
        self.anim_runbackwards = animfixfps(self, '14 1 1');
        self.anim_strafeleft = animfixfps(self, '15 1 1');
        self.anim_straferight = animfixfps(self, '16 1 1');
-       self.anim_dead1 = animfixfps(self, '17 1 1');
-       self.anim_dead2 = animfixfps(self, '18 1 1');
+       //self.anim_dead1 = animfixfps(self, '17 1 1');
+       //self.anim_dead2 = animfixfps(self, '18 1 1');
        self.anim_forwardright = animfixfps(self, '19 1 1');
        self.anim_forwardleft = animfixfps(self, '20 1 1');
        self.anim_backright = animfixfps(self, '21 1 1');
        self.anim_backleft  = animfixfps(self, '22 1 1');
-       self.anim_melee = animfixfps2(self, '23 1 1', '11 1 5');
-       self.anim_duckwalkbackwards = animfixfps2(self, '24 1 1', '4 1 1');
-       self.anim_duckwalkstrafeleft = animfixfps2(self, '25 1 1', '4 1 1');
-       self.anim_duckwalkstraferight = animfixfps2(self, '26 1 1', '4 1 1');
-       self.anim_duckwalkforwardright = animfixfps2(self, '27 1 1', '4 1 1');
-       self.anim_duckwalkforwardleft = animfixfps2(self, '28 1 1', '4 1 1');
-       self.anim_duckwalkbackright = animfixfps2(self, '29 1 1', '4 1 1');
-       self.anim_duckwalkbackleft  = animfixfps2(self, '30 1 1', '4 1 1');
+       self.anim_melee = animfixfps(self, '23 1 1');
+       self.anim_duckwalkbackwards = animfixfps(self, '24 1 1');
+       self.anim_duckwalkstrafeleft = animfixfps(self, '25 1 1');
+       self.anim_duckwalkstraferight = animfixfps(self, '26 1 1');
+       self.anim_duckwalkforwardright = animfixfps(self, '27 1 1');
+       self.anim_duckwalkforwardleft = animfixfps(self, '28 1 1');
+       self.anim_duckwalkbackright = animfixfps(self, '29 1 1');
+       self.anim_duckwalkbackleft  = animfixfps(self, '30 1 1');
        // TODO introspect models for finding right "fps" value (1/duration)
        // reset animstate now
        setanim(self, self.anim_idle, TRUE, FALSE, TRUE);
@@ -249,18 +267,7 @@ void player_anim (void)
                updateanim(self.weaponentity);
 
        if (self.deadflag != DEAD_NO)
-       {
-               if (time > self.animstate_endtime)
-               {
-                       if (self.maxs_z > 5)
-                       {
-                               self.maxs_z = 5;
-                               setsize(self, self.mins, self.maxs);
-                       }
-                       self.frame = self.dead_frame;
-               }
                return;
-       }
 
        if (!self.animstate_override)
        {
@@ -404,17 +411,17 @@ void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float
        self.dmg_take = self.dmg_take + take;//max(take - 10, 0);
        self.dmg_inflictor = inflictor;
 
-       if (self.health <= -autocvar_sv_gibhealth && self.modelindex != 0)
+       if (self.health <= -autocvar_sv_gibhealth && self.alpha >= 0)
        {
                // don't use any animations as a gib
                self.frame = 0;
-               self.dead_frame = 0;
                // view just above the floor
                self.view_ofs = '0 0 4';
 
                Violence_GibSplash(self, 1, 1, attacker);
-               self.modelindex = 0; // restore later
+               self.alpha = -1;
                self.solid = SOLID_NOT; // restore later
+               self.takedamage = DAMAGE_NO; // restore later
        }
 }
 
@@ -428,7 +435,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        float valid_damage_for_weaponstats;
        float excess;
 
-       if((g_arena && numspawned < 2) || (g_ca && !ca_teams_ok) && !inWarmupStage)
+       if((g_arena && numspawned < 2) || (g_ca && allowed_to_spawn) && !inWarmupStage)
                return;
 
        dh = max(self.health, 0);
@@ -653,7 +660,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                if(!g_freezetag)
                {
                        // become fully visible
-                       self.alpha = 1;
+                       self.alpha = default_player_alpha;
                        // throw a weapon
                        SpawnThrownWeapon (self.origin + (self.mins + self.maxs) * 0.5, self.switchweapon);
                }
@@ -667,8 +674,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
         float w;
         w = DEATH_WEAPONOF(deathtype);
         if(WEP_VALID(w))
-        if(self.classname == "player")
-        if(self != attacker)
+       if(accuracy_isgooddamage(attacker, self))
         attacker.accuracy.(accuracy_frags[w-1]) += 1;
 
                if(deathtype == DEATH_HURTTRIGGER && g_freezetag)
@@ -755,22 +761,22 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                if(!waves)
                        waves = autocvar_g_respawn_waves;
                if(waves)
-                       self.death_time = ceil((time + sdelay) / waves) * waves;
+                       self.respawn_time = ceil((time + sdelay) / waves) * waves;
                else
-                       self.death_time = time + sdelay;
-               if((sdelay + waves >= 5.0) && (self.death_time - time > 1.75))
+                       self.respawn_time = time + sdelay;
+               if((sdelay + waves >= 5.0) && (self.respawn_time - time > 1.75))
                        self.respawn_countdown = 10; // first number to count down from is 10
                else
                        self.respawn_countdown = -1; // do not count down
+               self.death_time = time;
                if (random() < 0.5)
-               {
                        setanim(self, self.anim_die1, FALSE, TRUE, TRUE);
-                       self.dead_frame = self.anim_dead1_x;
-               }
                else
-               {
                        setanim(self, self.anim_die2, FALSE, TRUE, TRUE);
-                       self.dead_frame = self.anim_dead2_x;
+               if (self.maxs_z > 5)
+               {
+                       self.maxs_z = 5;
+                       setsize(self, self.mins, self.maxs);
                }
                // set damage function to corpse damage
                self.event_damage = PlayerCorpseDamage;
@@ -947,7 +953,7 @@ float Say(entity source, float teamsay, entity privatesay, string msgin, float f
                                flood = 1;
                }
 
-               if (timeoutStatus == 2) //when game is paused, no flood protection
+               if (timeout_status == TIMEOUT_ACTIVE) // when game is paused, no flood protection
                        source.flood_field = flood = 0;
        }
 
@@ -974,8 +980,9 @@ float Say(entity source, float teamsay, entity privatesay, string msgin, float f
        if(!privatesay)
        if(source.classname != "player")
        {
-               if(teamsay || (autocvar_g_chat_nospectators == 1) || (autocvar_g_chat_nospectators == 2 && !inWarmupStage))
-                       teamsay = -1; // spectators
+               if not(intermission_running)
+                       if(teamsay || (autocvar_g_chat_nospectators == 1) || (autocvar_g_chat_nospectators == 2 && !inWarmupStage))
+                               teamsay = -1; // spectators
        }
 
        if(flood)
@@ -1007,22 +1014,23 @@ float Say(entity source, float teamsay, entity privatesay, string msgin, float f
 
        if(sourcemsgstr != "" && ret != 0)
        {
-               if(ret < 0) // fake
+               if(ret < 0) // faked message, because the player is muted
                {
                        sprint(source, sourcemsgstr);
                        if(sourcecmsgstr != "" && !privatesay)
                                centerprint(source, sourcecmsgstr);
                }
-               else if(privatesay)
+               else if(privatesay) // private message, between 2 people only, not sent to server console
                {
                        sprint(source, sourcemsgstr);
                        sprint(privatesay, msgstr);
                        if(cmsgstr != "")
                                centerprint(privatesay, cmsgstr);
                }
-               else if(teamsay > 0)
+               else if(teamsay > 0) // team message, only sent to team mates
                {
                        sprint(source, sourcemsgstr);
+                       //print(msgstr); // send to server console too
                        if(sourcecmsgstr != "")
                                centerprint(source, sourcecmsgstr);
                        FOR_EACH_REALPLAYER(head) if(head.team == source.team)
@@ -1033,22 +1041,24 @@ float Say(entity source, float teamsay, entity privatesay, string msgin, float f
                                                centerprint(head, cmsgstr);
                                }
                }
-               else if(teamsay < 0)
+               else if(teamsay < 0) // spectator message, only sent to spectators
                {
                        sprint(source, sourcemsgstr);
+                       //print(msgstr); // send to server console too
                        FOR_EACH_REALCLIENT(head) if(head.classname != "player")
                                if(head != source)
                                        sprint(head, msgstr);
                }
-               else if(sourcemsgstr != msgstr)
+               else if(sourcemsgstr != msgstr) // trimmed/server fixed message, sent to all players
                {
                        sprint(source, sourcemsgstr);
+                       //print(msgstr); // send to server console too
                        FOR_EACH_REALCLIENT(head)
                                if(head != source)
                                        sprint(head, msgstr);
                }
                else
-                       bprint(msgstr);
+                       bprint(msgstr); // entirely normal message, sent to all players -- bprint sends to server console too.
        }
 
        return ret;
@@ -1170,18 +1180,18 @@ float LoadPlayerSounds(string f, float first)
 }
 
 .float modelindex_for_playersound;
-.float skinindex_for_playersound;
+.float skin_for_playersound;
 void UpdatePlayerSounds()
 {
        if(self.modelindex == self.modelindex_for_playersound)
-       if(self.skinindex == self.skinindex_for_playersound)
+       if(self.skin == self.skin_for_playersound)
                return;
        self.modelindex_for_playersound = self.modelindex;
-       self.skinindex_for_playersound = self.skinindex;
+       self.skin_for_playersound = self.skin;
        ClearPlayerSounds();
        LoadPlayerSounds("sound/player/default.sounds", 1);
        if(!autocvar_g_debug_defaultsounds)
-               if(!LoadPlayerSounds(get_model_datafilename(self.model, self.skinindex, "sounds"), 0))
+               if(!LoadPlayerSounds(get_model_datafilename(self.model, self.skin, "sounds"), 0))
                        LoadPlayerSounds(get_model_datafilename(self.model, 0, "sounds"), 0);
 }