Merge remote-tracking branch 'origin/master' into fruitiex/animations
authorFruitieX <fruitiex@gmail.com>
Thu, 29 Sep 2011 19:09:10 +0000 (22:09 +0300)
committerFruitieX <fruitiex@gmail.com>
Thu, 29 Sep 2011 19:09:10 +0000 (22:09 +0300)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_physics.qc
qcsrc/server/cl_player.qc
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/defs.qh
qcsrc/server/t_jumppads.qc
qcsrc/server/w_shotgun.qc

index a0d50e3e7a996bf234d765d634097f23d5b2357e..3f1ca3f53b0066fe2e1d3461f6faeb3218ad12ce 100644 (file)
@@ -385,6 +385,7 @@ set sv_doublejump 0 "allow Quake 2-style double jumps"
 set sv_jumpspeedcap_min "" "lower bound on the baseline velocity of a jump; final velocity will be >= (jumpheight * min + jumpheight)"
 set sv_jumpspeedcap_max "" "upper bound on the baseline velocity of a jump; final velocity will be <= (jumpheight * max + jumpheight)"
 set sv_jumpspeedcap_max_disable_on_ramps 0 "disable upper baseline velocity bound on ramps to preserve the old rampjump style"
+set sv_player_jumpanim_minfall 48 "minimum distance player has to have below their feet before the jump animation will be activated (only when falling, +jump will play anim instantly)"
 
 seta sv_precacheplayermodels 1
 seta sv_precacheweapons 0
index e9d34ce17e8564ab7b9d683ab3e331a297992adf..6ccaf71d4c52053a96a6651bd6829f0d66754786 100644 (file)
@@ -1134,6 +1134,7 @@ string autocvar_sv_player_headsize;
 string autocvar_sv_player_maxs;
 string autocvar_sv_player_mins;
 string autocvar_sv_player_viewoffset;
+float autocvar_sv_player_jumpanim_minfall;
 float autocvar_sv_precacheplayermodels;
 float autocvar_sv_precacheweapons;
 float autocvar_sv_q3acompat_machineshotgunswap;
index bddb5933233ba91f7d422a85820852276344722e..58d25b0e73474761c2a3d53797a31903456bb44e 100644 (file)
@@ -2943,7 +2943,7 @@ void PlayerPreThink (void)
 
                self.prevorigin = self.origin;
 
-               if ((self.BUTTON_CROUCH && !self.hook.state) || self.health <= g_bloodloss)
+               if (((self.BUTTON_CROUCH && !self.hook.state) || self.health <= g_bloodloss) && self.animstate_startframe != self.anim_melee_x) // prevent crouching if using melee attack
                {
                        if (!self.crouch)
                        {
index b7e8bc22648b631647bf33898c4be713dc3d46f9..85d4cd00029c22160f8ab30f1fb36a155115e233 100644 (file)
@@ -171,7 +171,7 @@ void PlayerJump (void)
 
        if (self.crouch)
                setanim(self, self.anim_duckjump, FALSE, TRUE, TRUE);
-       else
+       else if (self.animstate_startframe != self.anim_melee_x || (self.animstate_startframe == self.anim_melee_x && time - self.animstate_starttime >= 21/20)) // jump animation shouldn't override melee until we have animation blending (or until the anim finished, 21/20 = numframes/fps)
                setanim(self, self.anim_jump, FALSE, TRUE, TRUE);
 
        if(g_jump_grunt)
index e5e2d377cf4981f7d9527d1a4ca7f927caf87bec..94f3221657b65845509ee1ca74d0de89af1f7374 100644 (file)
@@ -226,6 +226,7 @@ void player_setupanimsformodel()
        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);
@@ -253,6 +254,7 @@ void player_setupanimsformodel()
                self.anim_backright    = animparseline(animfile);
                self.anim_backleft     = animparseline(animfile);
                self.anim_melee        = animparseline(animfile);
+               self.anim_fly          = animparseline(animfile);
                fclose(animfile);
 
                // derived anims
@@ -290,13 +292,39 @@ 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);
+                       {
+                               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
-                               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)
                {
@@ -519,10 +547,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))
index af76117fec8f2ae7cdb50f539e9b7c31784decfa..21a9bc9428a71d6ec6d9bab9acc51a3db464a105 100644 (file)
@@ -1273,6 +1273,12 @@ void weapon_thinkf(float fr, float t, void() func)
                        anim_z = anim_y / (t + sys_frametime);
                        setanim(self, anim, FALSE, TRUE, TRUE);
                }
+               else if (self.animstate_startframe == self.anim_idle_x) // only allow shoot anim to override idle animation until we have animation blending
+               {
+                       anim = self.anim_shoot;
+                       anim_z = anim_y / (t + sys_frametime);
+                       setanim(self, anim, FALSE, TRUE, TRUE);
+               }
        }
 };
 
index bc05d1b04849b05ced40ef7b3ae1a20f0f7c36c8..7dfa8106b1726981171d7ff1ec72de54c01cf3a3 100644 (file)
@@ -149,6 +149,7 @@ float maxclients;
 .vector anim_backright; // player running backward and right
 .vector anim_backleft; // player running back and left
 .vector anim_melee; // player doing the melee action
+.vector anim_fly; // player animation played after jump, if player is still in air. Also if falling from a ledge
 
 // weapon animation vectors:
 .vector anim_fire1;
index 888b94456ff6496223698d7a2bce47054f7276d6..64dc74b9840b52524495488dd4a31685878ad7d3 100644 (file)
@@ -200,6 +200,14 @@ void trigger_push_touch()
                        }
                        else
                                other.lastteleporttime = time;
+
+                       if (!other.animstate_override)
+                       {
+                               if (other.crouch)
+                                       setanim(other, other.anim_duckjump, FALSE, TRUE, TRUE);
+                               else
+                                       setanim(other, other.anim_jump, FALSE, TRUE, TRUE);
+                       }
                }
                else
                        other.jumppadcount = TRUE;
index 2088073f9970e62a1836b96725ab231f85898638..a9d1ba056aca2f2691e731acccf9257161009425 100644 (file)
@@ -144,6 +144,7 @@ float w_shotgun(float req)
                        }
                }
                if (self.clip_load >= 0) // we are not currently reloading
+               if (!self.crouch) // we are not currently crouching; this fixes an exploit where your melee anim is not visible, and besides wouldn't make much sense
                if (self.BUTTON_ATCK2 && autocvar_g_balance_shotgun_secondary)
                if (weapon_prepareattack(1, autocvar_g_balance_shotgun_secondary_refire))
                {