Here's the whole new G_SetClient Frame function in p_view.c:
Code:
#define MAX_STEP_FRACTION 0.80
void G_SetClientFrame (edict_t *ent)
{
gclient_t *client;
qboolean duck, run;
// CDawg -- add here!
trace_t tr;
vec3_t end = {0, 0, -2};
qboolean floor = true;
if (ent->s.modelindex != MAX_MODELS-1)
return; // not in the player model
client = ent->client;
if (client->ps.pmove.pm_flags & PMF_DUCKED)
duck = true;
else
duck = false;
// Knightmare- don't always play running animation when in mud
if (ent->in_mud && xyspeed > 40)
run = true;
else if (!ent->in_mud && xyspeed)
run = true;
else
run = false;
// Lazarus: override run animations for vehicle drivers
if (ent->vehicle)
run = false;
// Knightmare- do the check here, to be sure not to skip over the frame increment
// also, always set to jump if jumping upward
VectorMA (ent->s.origin, 50, end, end);
tr = gi.trace (ent->s.origin, NULL, NULL, end, ent, MASK_ALL);
//Com_Printf("%f\n", tr.fraction);
if (tr.fraction >= MAX_STEP_FRACTION)
floor = false;
else if (ent->client->oldvelocity[2] > 0 || ent->velocity[2] > 0)
floor = false;
// CDawg -- end here!
// check for stand/duck and stop/go transitions
if (duck != client->anim_duck && client->anim_priority < ANIM_DEATH)
goto newanim;
if (run != client->anim_run && client->anim_priority == ANIM_BASIC)
goto newanim;
// Knightmare- only skip increment if greater than step or swimming
if (!ent->groundentity && client->anim_priority <= ANIM_WAVE && (!floor || ent->waterlevel > 2))
goto newanim;
if(client->anim_priority == ANIM_REVERSE)
{
if(ent->s.frame > client->anim_end)
{
ent->s.frame--;
return;
}
}
else if (ent->s.frame < client->anim_end)
{ // continue an animation
ent->s.frame++;
return;
}
if (client->anim_priority == ANIM_DEATH)
return; // stay there
if (client->anim_priority == ANIM_JUMP)
{
if (!ent->groundentity)
return; // stay there
ent->client->anim_priority = ANIM_WAVE;
ent->s.frame = FRAME_jump3;
ent->client->anim_end = FRAME_jump6;
return;
}
newanim:
// return to either a running or standing frame
client->anim_priority = ANIM_BASIC;
client->anim_duck = duck;
client->anim_run = run;
// Knightmare- added swimming check
if (!ent->groundentity && (!floor || ent->waterlevel > 2)) //CDawg modify this
{
//ZOID: if on grapple, don't go into jump frame, go into standing
//frame
if (client->ctf_grapple) {
ent->s.frame = FRAME_stand01;
client->anim_end = FRAME_stand40;
} else {
//ZOID
client->anim_priority = ANIM_JUMP;
if (ent->s.frame != FRAME_jump2)
ent->s.frame = FRAME_jump1;
client->anim_end = FRAME_jump2;
}
}
else if (run)
{ // running
if (duck)
{
ent->s.frame = FRAME_crwalk1;
client->anim_end = FRAME_crwalk6;
}
else
{ // CDawg - add here!
if (client->backpedaling)
{
client->anim_priority = ANIM_REVERSE;
ent->s.frame = FRAME_run6;
client->anim_end = FRAME_run1;
}
else
{
ent->s.frame = FRAME_run1;
client->anim_end = FRAME_run6;
} // CDawg end here!
}
}
else
{ // standing
if (duck)
{
ent->s.frame = FRAME_crstnd01;
client->anim_end = FRAME_crstnd19;
}
else
{
ent->s.frame = FRAME_stand01;
client->anim_end = FRAME_stand40;
}
}
}
Add this to the gclient_s struct in g_local.h after machinegun_shots:
Code:
qboolean backpedaling; //<- CDawg added this
And add this to ClientThink in p_client.c after ent->light_level is set:
Code:
// CDawg - add here!
if (ucmd->forwardmove < -1)
ent->client->backpedaling = true;
else
ent->client->backpedaling = false;
// CDawg end here!