]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_player.qc
replace numbers by self.anim_*_x
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_player.qc
index 131d0a69bfab04d63c40e6c0bd80f778a0561120..382645810b47fec2719cfc1b8f74e56dbb973fd7 100644 (file)
@@ -1,3 +1,7 @@
+.entity accuracy;
+.float accuracy_frags[WEP_MAXCOUNT];
+FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_frags);
+
 float weaponstats_buffer;
 
 void WeaponStats_Init()
@@ -188,6 +192,8 @@ 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';
+       self.anim_fly = '24 1 1';
        animparseerror = FALSE;
        animfilename = strcat(self.model, ".animinfo");
        animfile = fopen(animfilename, FILE_READ);
@@ -214,6 +220,8 @@ void player_setupanimsformodel()
                self.anim_forwardleft  = animparseline(animfile);
                self.anim_backright    = animparseline(animfile);
                self.anim_backleft     = animparseline(animfile);
+               self.anim_melee        = animparseline(animfile);
+               self.anim_fly          = animparseline(animfile);
                fclose(animfile);
 
                // derived anims
@@ -251,13 +259,32 @@ void player_anim (void)
 
        if (!self.animstate_override)
        {
-               if (!(self.flags & FL_ONGROUND))
+               if (!(self.flags & FL_ONGROUND) || self.BUTTON_JUMP)
                {
-                       if (self.crouch)
-                               setanim(self, self.anim_duckjump, FALSE, TRUE, self.restart_jump);
-                       else
-                               setanim(self, self.anim_jump, FALSE, TRUE, self.restart_jump);
-                       self.restart_jump = FALSE;
+                       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 && 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
+                                       {
+                                               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
+                               {
+                                       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
+                                       {
+                                               setanim(self, self.anim_jump, FALSE, TRUE, self.restart_jump);
+                                               self.restart_jump = FALSE;
+                                       }
+                               }
+                       }
                }
                else if (self.crouch)
                {
@@ -480,10 +507,13 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                                if(sv_gentle < 1) {
                                        if(self.classname != "body") // pain anim is BORKED on our ZYMs, FIXME remove this once we have good models
                                        {
-                                               if (random() > 0.5)
-                                                       setanim(self, self.anim_pain1, FALSE, TRUE, TRUE);
-                                               else
-                                                       setanim(self, self.anim_pain2, FALSE, TRUE, TRUE);
+                                               if (!self.animstate_override)
+                                               {
+                                                       if (random() > 0.5)
+                                                               setanim(self, self.anim_pain1, FALSE, TRUE, TRUE);
+                                                       else
+                                                               setanim(self, self.anim_pain2, FALSE, TRUE, TRUE);
+                                               }
                                        }
 
                                        if(sound_allowed(MSG_BROADCAST, attacker))
@@ -613,6 +643,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,6 +663,7 @@ 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)
                {
@@ -732,59 +771,6 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        }
 }
 
-// sendflags use: 1 = origin, 2 = health/armor, 0x80 = same team (includes health), 4 = entity out of range/culled
-float SendEntity_ShowNames(entity to, float sendflags)
-{
-    WriteByte(MSG_ENTITY, ENT_CLIENT_SHOWNAMES);
-    WriteByte(MSG_ENTITY, num_for_edict(self.owner));
-
-    sendflags = sendflags & 127;
-    if(teams_matter && self.owner.team == to.team)
-        sendflags |= 128;
-    else
-        sendflags &~= 2;
-    WriteByte(MSG_ENTITY, sendflags);
-    if(sendflags & 1)
-    {
-        WriteShort(MSG_ENTITY, rint(self.origin_x));
-        WriteShort(MSG_ENTITY, rint(self.origin_y));
-        WriteShort(MSG_ENTITY, rint(self.origin_z));
-    }
-    if(sendflags & 2)
-    {
-        WriteByte(MSG_ENTITY, self.health);
-        WriteByte(MSG_ENTITY, self.armorvalue);
-    }
-    return TRUE;
-}
-
-void shownames_think()
-{
-    if(self.origin != self.owner.origin)
-    {
-        setorigin(self, self.owner.origin);
-        self.SendFlags |= 1;
-    }
-    if(self.health != floor(self.owner.health) || self.armorvalue != floor(self.owner.armorvalue))
-    {
-        self.health = floor(self.owner.health);
-        self.armorvalue = floor(self.owner.armorvalue);
-        self.SendFlags |= 2;
-    }
-    self.nextthink = time;
-}
-
-float shownames_customize()
-{
-    return TRUE;
-    if(vlen(other.origin - self.origin) < autocvar_sv_shownames_cull_distance)
-    if(self.owner != other) // no need to spam own coordinates
-    if(self.owner.team == other.team || (self.owner.team != other.team && checkpvs(self.origin, other)))
-        return TRUE;
-
-    return FALSE;
-}
-
 .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