Permalink
Browse files

Add side dodge on doubletap

Has a 1.5s cooldown.
  • Loading branch information...
DolceTriade committed Dec 19, 2015
1 parent 3b2623f commit 2cfbcf2212381d34bae48d4ba9cf3bb88810f1b7
Showing with 105 additions and 0 deletions.
  1. +4 −0 src/shared/bg_gameplay.h
  2. +101 −0 src/shared/bg_pmove.cpp
@@ -292,6 +292,10 @@ extern int REACTOR_ATTACK_DAMAGE;
#define HUMAN_BACK_MODIFIER 0.8f
#define HUMAN_SIDE_MODIFIER 0.9f
#define HUMAN_LAND_FRICTION 3.0f
#define HUMAN_DODGE_COOLDOWN 1500
#define HUMAN_DODGE_SIDE_MULTIPLIER 3.0f
#define HUMAN_DODGE_SLOW_MULTIPLIER 0.5f
#define HUMAN_DODGE_VERTICAL_MULTIPLIER 0.5f

#define STAMINA_MAX 30000
#define STAMINA_MEDISTAT_RESTORE 450 // 1/(100 ms). stacks.
@@ -1591,6 +1591,106 @@ static bool PM_CheckWaterJump()
return true;
}

/*
==================
PM_CheckDodge
Checks the dodge key and starts a human dodge
==================
*/
static bool PM_CheckDodge( void )
{
vec3_t right, velocity = { 0.0f, 0.0f, 0.0f };
float jump, sideModifier;
int cost = BG_Class( pm->ps->stats[ STAT_CLASS ] )->staminaJumpCost;

if ( pm->ps->persistant[ PERS_TEAM ] != TEAM_HUMANS )
{
return false;
}

// Landed a dodge
if ( ( pm->ps->pm_flags & PMF_CHARGE ) &&
pm->ps->groundEntityNum != ENTITYNUM_NONE )
{
pm->ps->pm_flags = ( pm->ps->pm_flags & ~PMF_CHARGE );
return false;
}

// Reasons why we can't start a dodge or sprint
if ( pm->ps->pm_type != PM_NORMAL || pm->ps->stats[ STAT_STAMINA ] < cost ||
( pm->ps->pm_flags & PMF_DUCKED ) || pm->ps->pm_time > 0 )
{
return false;
}

// Reasons why we can't start a dodge only
if ( pm->ps->pm_flags & ( PMF_CHARGE ) ||
pm->ps->groundEntityNum == ENTITYNUM_NONE ||
( pm->cmd.doubleTap != DT_MOVELEFT &&
pm->cmd.doubleTap != DT_MOVERIGHT ) )
{
return false;
}

// don't allow jump until all buttons are up (?)
if ( pm->ps->pm_flags & PMF_RESPAWNED )
{
return false;
}

// can't jump whilst grabbed
if ( pm->ps->pm_type == PM_GRABBED )
{
return false;
}

// must wait for jump to be released
if ( pm->ps->pm_flags & PMF_JUMP_HELD )
{
return false;
}

VectorCopy( pml.right, right );

// Dodge magnitude is based on the jump magnitude scaled by the modifiers
jump = BG_Class( pm->ps->stats[ STAT_CLASS ] )->jumpMagnitude;

// Weaken dodge if slowed
if ( ( pm->ps->stats[ STAT_STATE ] & SS_SLOWLOCKED ) ||
( pm->ps->stats[ STAT_STATE ] & SS_CREEPSLOWED ) )
{
sideModifier = HUMAN_DODGE_SLOW_MULTIPLIER;
}
else
{
sideModifier = HUMAN_DODGE_SIDE_MULTIPLIER;
}

// The dodge sets minimum velocity
if ( pm->cmd.doubleTap == DT_MOVELEFT )
{
VectorNegate( right, right );
}

VectorMA( velocity, jump * sideModifier, right, velocity );
velocity[ 2 ] = jump * HUMAN_DODGE_VERTICAL_MULTIPLIER;
VectorAdd( velocity, pm->ps->velocity, pm->ps->velocity );
pm->ps->stats[ STAT_STAMINA ] -= cost;

// Jumped away
pml.groundPlane = false;
pml.walking = false;
pm->ps->pm_flags |= PMF_JUMP_HELD;
pm->ps->pm_flags |= PMF_JUMPED;
pm->ps->pm_time = HUMAN_DODGE_COOLDOWN;
pm->ps->groundEntityNum = ENTITYNUM_NONE;
PM_AddEvent( EV_JUMP );
PM_PlayJumpingAnimation();

return true;
}

//============================================================================

/*
@@ -4879,6 +4979,7 @@ void PmoveSingle( pmove_t *pmove )
}

PM_DropTimers();
PM_CheckDodge();

if ( pm->ps->pm_flags & PMF_TIME_WATERJUMP )
{

0 comments on commit 2cfbcf2

Please sign in to comment.