]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_player.qc
Merge remote branch 'origin/master' into fruitiex/animations
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_player.qc
index 382645810b47fec2719cfc1b8f74e56dbb973fd7..18817bdc6c48283d60eb0113b160f2125ccadcbe 100644 (file)
@@ -1,6 +1,5 @@
 .entity accuracy;
 .float accuracy_frags[WEP_MAXCOUNT];
-FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_frags);
 
 float weaponstats_buffer;
 
@@ -16,7 +15,7 @@ void WeaponStats_Init()
 
 void WeaponStats_Shutdown()
 {
-       float i, j, ibot, jbot, idx;
+       float i, j, n, ibot, jbot, idx;
        float fh;
        vector v;
        string prefix;
@@ -30,7 +29,11 @@ void WeaponStats_Shutdown()
                {
                        fputs(fh, "#begin statsfile\n");
                        fputs(fh, strcat("#date ", strftime(TRUE, "%a %b %e %H:%M:%S %Z %Y"), "\n"));
-                       fputs(fh, strcat("#config ", ftos(crc16(FALSE, cvar_changes)), "\n"));
+                       fputs(fh, strcat("#config ", ftos(crc16(FALSE, cvar_purechanges)), "\n"));
+                       fputs(fh, strcat("#cvar_purechanges ", ftos(cvar_purechanges_count), "\n"));
+                       n = tokenizebyseparator(cvar_purechanges, "\n");
+                       for(i = 0; i < n; ++i)
+                               fputs(fh, strcat("#cvar_purechange ", argv(i), "\n"));
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i) for(ibot = 0; ibot <= 1; ++ibot)
                                for(j = WEP_FIRST; j <= WEP_LAST; ++j) for(jbot = 0; jbot <= 1; ++jbot)
                                {
@@ -261,27 +264,34 @@ void player_anim (void)
        {
                if (!(self.flags & FL_ONGROUND) || self.BUTTON_JUMP)
                {
-                       if((self.animstate_startframe == self.anim_jump_x && time - self.animstate_starttime >= 21/25) || (self.animstate_startframe == self.anim_duckjump_x && time - self.animstate_starttime >= 21/25))
-                               setanim(self, self.anim_fly, TRUE, FALSE, FALSE);
-
-                       if(self.animstate_startframe != self.anim_fly_x) // no tracing if we're in the fly anim
+                       if (self.crouch)
                        {
-                               if (self.crouch && self.animstate_startframe != self.anim_duckjump_x) // don't perform another trace if already playing the crouch jump anim
+                               if (self.animstate_startframe != self.anim_duckjump_x) // don't perform another trace if already playing the crouch jump anim
                                {
                                        traceline(self.origin + '0 0 1' * PL_CROUCH_MIN_z, self.origin + '0 0 1' * (PL_CROUCH_MIN_z - autocvar_sv_player_jumpanim_minfall), TRUE, self);
-                                       if(!trace_startsolid && trace_fraction == 1 || self.animstate_startframe == self.anim_idle_x) // don't get stuck on idle animation in midair
+                                       if(!trace_startsolid && trace_fraction == 1 || !(self.animstate_startframe == self.anim_duckwalk_x || self.animstate_startframe == self.anim_duckidle_x)) // don't get stuck on non-crouch anims
                                        {
                                                setanim(self, self.anim_duckjump, FALSE, TRUE, self.restart_jump);
                                                self.restart_jump = FALSE;
                                        }
                                }
-                               else if (self.animstate_startframe != self.anim_jump_x) // don't perform another trace if already playing the jump anim
+                       }
+                       else
+                       {
+                               // 21/25 is the magic number here for how long the jump animation takes to play once (numframes/framerate)
+                               if((self.animstate_startframe == self.anim_jump_x && time - self.animstate_starttime >= 21/25))
+                                       setanim(self, self.anim_fly, TRUE, FALSE, FALSE);
+
+                               if(self.animstate_startframe != self.anim_fly_x) // no tracing if we're in the fly anim
                                {
-                                       traceline(self.origin + '0 0 1' * PL_MIN_z, self.origin + '0 0 1' * (PL_MIN_z - autocvar_sv_player_jumpanim_minfall), TRUE, self);
-                                       if(!trace_startsolid && trace_fraction == 1 || self.animstate_startframe == self.anim_idle_x) // don't get stuck on idle animation in midair
+                                       if (self.animstate_startframe != self.anim_jump_x) // don't perform another trace if already playing the jump anim
                                        {
-                                               setanim(self, self.anim_jump, FALSE, TRUE, self.restart_jump);
-                                               self.restart_jump = FALSE;
+                                               traceline(self.origin + '0 0 1' * PL_MIN_z, self.origin + '0 0 1' * (PL_MIN_z - autocvar_sv_player_jumpanim_minfall), TRUE, self);
+                                               if(!trace_startsolid && trace_fraction == 1 || self.animstate_startframe == self.anim_idle_x || (self.animstate_startframe == self.anim_melee_x && time - self.animstate_starttime >= 21/20)) // don't get stuck on idle animation in midair, nor melee after it finished
+                                               {
+                                                       setanim(self, self.anim_jump, FALSE, TRUE, self.restart_jump);
+                                                       self.restart_jump = FALSE;
+                                               }
                                        }
                                }
                        }
@@ -362,11 +372,11 @@ void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float
        if(sound_allowed(MSG_BROADCAST, attacker))
        {
                if (save > 10)
-                       sound (self, CHAN_PROJECTILE, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
                else if (take > 30)
-                       sound (self, CHAN_PROJECTILE, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
                else if (take > 10)
-                       sound (self, CHAN_PROJECTILE, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM);
        }
 
        if (take > 50)
@@ -479,11 +489,11 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        if(sound_allowed(MSG_BROADCAST, attacker))
        {
                if (save > 10)
-                       sound (self, CHAN_PROJECTILE, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/armorimpact.wav", VOL_BASE, ATTN_NORM);
                else if (take > 30)
-                       sound (self, CHAN_PROJECTILE, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_SHOTS, "misc/bodyimpact2.wav", VOL_BASE, ATTN_NORM);
                else if (take > 10)
-                       sound (self, CHAN_PROJECTILE, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM); // FIXME possibly remove them?
+                       sound (self, CH_SHOTS, "misc/bodyimpact1.wav", VOL_BASE, ATTN_NORM); // FIXME possibly remove them?
        }
 
        if (take > 50)
@@ -522,15 +532,15 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                                        // exclude pain sounds for laserjumps as long as you aren't REALLY low on health and would die of the next two
                                        {
                                                if(deathtype == DEATH_FALL)
-                                                       PlayerSound(playersound_fall, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND);
                                                else if(self.health > 75) // TODO make a "gentle" version?
-                                                       PlayerSound(playersound_pain100, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND);
                                                else if(self.health > 50)
-                                                       PlayerSound(playersound_pain75, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND);
                                                else if(self.health > 25)
-                                                       PlayerSound(playersound_pain50, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(playersound_pain50, CH_PAIN, VOICETYPE_PLAYERSOUND);
                                                else
-                                                       PlayerSound(playersound_pain25, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
+                                                       PlayerSound(playersound_pain25, CH_PAIN, VOICETYPE_PLAYERSOUND);
                                        }
                                }
 
@@ -554,7 +564,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                // escape a lava pit or similar
                //self.pushltime = 0;
        }
-       else if(attacker.classname == "player" || attacker.classname == "gib")
+       else if(attacker.classname == "player")
        {
                self.pusher = attacker;
                self.pushltime = time + autocvar_g_maxpushtime;
@@ -583,7 +593,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                        awep = DEATH_WEAPONOF(deathtype);
                valid_damage_for_weaponstats = 1;
        }
-       
+
        if(valid_damage_for_weaponstats)
        {
                dh = dh - max(self.health, 0);
@@ -609,9 +619,9 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                if(sound_allowed(MSG_BROADCAST, attacker))
                {
                        if(deathtype == DEATH_DROWN)
-                               PlayerSound(playersound_drown, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
+                               PlayerSound(playersound_drown, CH_PAIN, VOICETYPE_PLAYERSOUND);
                        else
-                               PlayerSound(playersound_death, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
+                               PlayerSound(playersound_death, CH_PAIN, VOICETYPE_PLAYERSOUND);
                }
 
                // get rid of kill indicator
@@ -667,7 +677,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
 
                if(self.flagcarried)
                {
-                       if(attacker.classname != "player" && attacker.classname != "gib")
+                       if(attacker.classname != "player")
                                DropFlag(self.flagcarried, self, attacker); // penalty for flag loss by suicide
                        else if(attacker.team == self.team)
                                DropFlag(self.flagcarried, attacker, attacker); // penalty for flag loss by suicide/teamkill
@@ -796,7 +806,7 @@ float Say(entity source, float teamsay, entity privatesay, string msgin, float f
 
        if(source.classname != "player")
                colorstr = "^0"; // black for spectators
-       else if(teams_matter)
+       else if(teamplay)
                colorstr = Team_ColorCode(source.team);
        else
                teamsay = FALSE;
@@ -1158,8 +1168,9 @@ void UpdatePlayerSounds()
        self.skinindex_for_playersound = self.skinindex;
        ClearPlayerSounds();
        LoadPlayerSounds("sound/player/default.sounds", 1);
-       if(!LoadPlayerSounds(get_model_datafilename(self.model, self.skinindex, "sounds"), 0))
-               LoadPlayerSounds(get_model_datafilename(self.model, 0, "sounds"), 0);
+       if(!autocvar_g_debug_defaultsounds)
+               if(!LoadPlayerSounds(get_model_datafilename(self.model, self.skinindex, "sounds"), 0))
+                       LoadPlayerSounds(get_model_datafilename(self.model, 0, "sounds"), 0);
 }
 
 void FakeGlobalSound(string sample, float chan, float voicetype)
@@ -1285,7 +1296,7 @@ void GlobalSound(string sample, float chan, float voicetype)
                        break;
                case VOICETYPE_TEAMRADIO:
                        FOR_EACH_REALCLIENT(msg_entity)
-                               if(!teams_matter || msg_entity.team == self.team)
+                               if(!teamplay || msg_entity.team == self.team)
                                {
                                        if(msg_entity.cvar_cl_voice_directional == 1)
                                                soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTN_MIN);
@@ -1359,9 +1370,9 @@ void VoiceMessage(string type, string msg)
        flood = Say(self, ownteam, world, msg, 1);
 
        if (flood > 0)
-               GlobalSound(self.sample, CHAN_VOICE, voicetype);
+               GlobalSound(self.sample, CH_VOICE, voicetype);
        else if (flood < 0)
-               FakeGlobalSound(self.sample, CHAN_VOICE, voicetype);
+               FakeGlobalSound(self.sample, CH_VOICE, voicetype);
 }
 
 void MoveToTeam(entity client, float team_colour, float type, float show_message)