]> 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 cd7c81d0c616d0cb1762a3aef893dff81dde214a..18817bdc6c48283d60eb0113b160f2125ccadcbe 100644 (file)
@@ -196,6 +196,7 @@ void player_setupanimsformodel()
        self.anim_backright = '21 1 1';
        self.anim_backleft  = '22 1 1';
        self.anim_melee = '23 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);
        animparseerror = FALSE;
        animfilename = strcat(self.model, ".animinfo");
        animfile = fopen(animfilename, FILE_READ);
@@ -223,6 +224,7 @@ void player_setupanimsformodel()
                self.anim_backright    = animparseline(animfile);
                self.anim_backleft     = animparseline(animfile);
                self.anim_melee        = 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
                fclose(animfile);
 
                // derived anims
@@ -260,13 +262,39 @@ void player_anim (void)
 
        if (!self.animstate_override)
        {
 
        if (!self.animstate_override)
        {
-               if (!(self.flags & FL_ONGROUND))
+               if (!(self.flags & FL_ONGROUND) || self.BUTTON_JUMP)
                {
                        if (self.crouch)
                {
                        if (self.crouch)
-                               setanim(self, self.anim_duckjump, FALSE, TRUE, self.restart_jump);
+                       {
+                               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_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
                        else
-                               setanim(self, self.anim_jump, FALSE, TRUE, self.restart_jump);
-                       self.restart_jump = FALSE;
+                       {
+                               // 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
+                               {
+                                       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 || (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;
+                                               }
+                                       }
+                               }
+                       }
                }
                else if (self.crouch)
                {
                }
                else if (self.crouch)
                {
@@ -489,10 +517,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(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))
                                        }
 
                                        if(sound_allowed(MSG_BROADCAST, attacker))