]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_player.qc
Merge branch 'master' into terencehill/centerprint_stuff
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_player.qc
index 2945c6efb6a747b385b049b5981cdb4e65ccf222..6f82d9f1043c7b30d21d98a6a2c52830944737ca 100644 (file)
@@ -1,3 +1,6 @@
+.entity accuracy;
+.float accuracy_frags[WEP_MAXCOUNT];
+
 float weaponstats_buffer;
 
 void WeaponStats_Init()
@@ -188,6 +191,7 @@ void player_setupanimsformodel()
        self.anim_forwardleft = '20 1 1';
        self.anim_backright = '21 1 1';
        self.anim_backleft  = '22 1 1';
+       self.anim_melee = '23 1 1';
        animparseerror = FALSE;
        animfilename = strcat(self.model, ".animinfo");
        animfile = fopen(animfilename, FILE_READ);
@@ -214,6 +218,7 @@ void player_setupanimsformodel()
                self.anim_forwardleft  = animparseline(animfile);
                self.anim_backright    = animparseline(animfile);
                self.anim_backleft     = animparseline(animfile);
+               self.anim_melee        = animparseline(animfile);
                fclose(animfile);
 
                // derived anims
@@ -335,11 +340,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)
@@ -452,11 +457,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)
@@ -492,15 +497,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);
                                        }
                                }
 
@@ -524,7 +529,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;
@@ -553,7 +558,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);
@@ -579,9 +584,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
@@ -613,6 +618,14 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                race_PreDie();
                DropAllRunes(self);
 
+        // increment frag counter for used weapon type
+        float w;
+        w = DEATH_WEAPONOF(deathtype);
+        if(WEP_VALID(w))
+        if(self.classname == "player")
+        if(self != attacker)
+        attacker.accuracy.(accuracy_frags[w-1]) += 1;
+
                if(deathtype == DEATH_HURTTRIGGER && g_freezetag)
                {
                        PutClientInServer();
@@ -625,10 +638,11 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                frag_inflictor = inflictor;
                frag_target = self;
                MUTATOR_CALLHOOK(PlayerDies);
+               weapon_action(self.weapon, WR_PLAYERDEATH);
 
                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
@@ -720,7 +734,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
 
                if(sv_gentle > 0 || autocvar_ekg) {
                        // remove corpse
-                       PlayerCorpseDamage (inflictor, attacker, 100.0, deathtype, hitloc, force);
+                       PlayerCorpseDamage (inflictor, attacker, autocvar_sv_gibhealth+1.0, deathtype, hitloc, force);
                }
 
                // reset fields the weapons may use just in case
@@ -732,63 +746,6 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        }
 }
 
-void net_shownames(entity selected, float teammate)
-{
-    float teammate_health, teammate_armor;
-    if(teammate)
-    {
-        teammate_health = selected.health;
-        teammate_armor = selected.armorvalue;
-    }
-
-       WRITESPECTATABLE_MSG_ONE({
-               WriteByte(MSG_ONE, SVC_TEMPENTITY);
-               WriteByte(MSG_ONE, TE_CSQC_SHOWNAMES);
-               WriteString(MSG_ONE, playername(selected));
-        WriteByte(MSG_ONE, teammate_health);
-        WriteByte(MSG_ONE, teammate_armor);
-        });
-}
-
-void UpdateSelectedPlayer()
-{
-    entity selected;
-    selected = world;
-
-       if(!autocvar_sv_allow_shownames)
-               return;
-
-       if(clienttype(self) != CLIENTTYPE_REAL)
-               return;
-
-       if(self.cvar_cl_shownames == 0)
-               return;
-
-       makevectors(self.v_angle); // sets v_forward
-
-       // cursor trace
-       if(self.selected_player_display_timeout < time)
-    {
-        WarpZone_crosshair_trace(self);
-        if(trace_ent && trace_ent.classname == "player" && !trace_ent.deadflag)
-        {
-            selected = trace_ent;
-            self.last_selected_player = selected;
-            self.selected_player_display_timeout = time + 0.1; // update at 0.1s intervals
-        }
-    }
-
-       if(selected)
-       {
-        msg_entity = self;
-        if(teams_matter)
-            if(self.team == selected.team)
-                net_shownames(selected, 1);
-        else
-            net_shownames(selected, 0);
-    }
-}
-
 .float muted; // to be used by prvm_edictset server playernumber muted 1
 float Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol)
 // message "": do not say, just test flood control
@@ -814,7 +771,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;
@@ -1176,8 +1133,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)
@@ -1303,7 +1261,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);
@@ -1377,9 +1335,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)