mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-28 22:57:55 +03:00
Added experimental singleplayer anim state
This commit is contained in:
parent
72e846ec27
commit
2ca681431b
@ -1367,6 +1367,10 @@ void C_BasePlayer::AddEntity( void )
|
|||||||
|
|
||||||
// Add in lighting effects
|
// Add in lighting effects
|
||||||
CreateLightEffects();
|
CreateLightEffects();
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
SetLocalAnglesDim( X_INDEX, 0 );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern float UTIL_WaterLevel( const Vector &position, float minz, float maxz );
|
extern float UTIL_WaterLevel( const Vector &position, float minz, float maxz );
|
||||||
|
@ -47,6 +47,8 @@ $Project
|
|||||||
$File "$SRCDIR\game\shared\mapbase\MapEdit.h"
|
$File "$SRCDIR\game\shared\mapbase\MapEdit.h"
|
||||||
$File "$SRCDIR\game\shared\mapbase\matchers.cpp"
|
$File "$SRCDIR\game\shared\mapbase\matchers.cpp"
|
||||||
$File "$SRCDIR\game\shared\mapbase\matchers.h"
|
$File "$SRCDIR\game\shared\mapbase\matchers.h"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\singleplayer_animstate.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\singleplayer_animstate.h"
|
||||||
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.cpp" [$MAPBASE_VSCRIPT]
|
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.cpp" [$MAPBASE_VSCRIPT]
|
||||||
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.h" [$MAPBASE_VSCRIPT]
|
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.h" [$MAPBASE_VSCRIPT]
|
||||||
$File "$SRCDIR\game\shared\mapbase\vscript_singletons.cpp" [$MAPBASE_VSCRIPT]
|
$File "$SRCDIR\game\shared\mapbase\vscript_singletons.cpp" [$MAPBASE_VSCRIPT]
|
||||||
|
@ -406,4 +406,8 @@ void CBaseHLBludgeonWeapon::Swing( int bIsSecondary )
|
|||||||
//Play swing sound
|
//Play swing sound
|
||||||
WeaponSound( SINGLE );
|
WeaponSound( SINGLE );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
pOwner->SetAnimation( PLAYER_ATTACK1 );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -621,6 +621,12 @@ END_SCRIPTDESC();
|
|||||||
|
|
||||||
CHL2_Player::CHL2_Player()
|
CHL2_Player::CHL2_Player()
|
||||||
{
|
{
|
||||||
|
#ifdef SP_ANIM_STATE
|
||||||
|
// Here we create and init the player animation state.
|
||||||
|
m_pPlayerAnimState = CreatePlayerAnimationState(this);
|
||||||
|
m_angEyeAngles.Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
m_nNumMissPositions = 0;
|
m_nNumMissPositions = 0;
|
||||||
m_pPlayerAISquad = 0;
|
m_pPlayerAISquad = 0;
|
||||||
m_bSprintEnabled = true;
|
m_bSprintEnabled = true;
|
||||||
@ -1144,6 +1150,16 @@ void CHL2_Player::PostThink( void )
|
|||||||
{
|
{
|
||||||
HandleAdmireGlovesAnimation();
|
HandleAdmireGlovesAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SP_ANIM_STATE
|
||||||
|
m_angEyeAngles = EyeAngles();
|
||||||
|
|
||||||
|
QAngle angles = GetLocalAngles();
|
||||||
|
angles[PITCH] = 0;
|
||||||
|
SetLocalAngles(angles);
|
||||||
|
|
||||||
|
m_pPlayerAnimState->Update(); // m_pPlayerAnimState->Update( m_angEyeAngles.y, m_angEyeAngles.x );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHL2_Player::StartAdmireGlovesAnimation( void )
|
void CHL2_Player::StartAdmireGlovesAnimation( void )
|
||||||
@ -1490,6 +1506,11 @@ void CHL2_Player::SetAnimation( PLAYER_ANIM playerAnim )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( IsInAVehicle() )
|
||||||
|
{
|
||||||
|
idealActivity = ACT_COVER_LOW;
|
||||||
|
}
|
||||||
|
|
||||||
if ( idealActivity == ACT_HL2MP_GESTURE_RANGE_ATTACK )
|
if ( idealActivity == ACT_HL2MP_GESTURE_RANGE_ATTACK )
|
||||||
{
|
{
|
||||||
@ -1835,6 +1856,14 @@ void CHL2_Player::InitVCollision( const Vector &vecAbsOrigin, const Vector &vecA
|
|||||||
|
|
||||||
CHL2_Player::~CHL2_Player( void )
|
CHL2_Player::~CHL2_Player( void )
|
||||||
{
|
{
|
||||||
|
#ifdef SP_ANIM_STATE
|
||||||
|
// Clears the animation state.
|
||||||
|
if ( m_pPlayerAnimState != NULL )
|
||||||
|
{
|
||||||
|
m_pPlayerAnimState->Release();
|
||||||
|
m_pPlayerAnimState = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
// In HL2MP we need to inherit from BaseMultiplayerPlayer!
|
// In HL2MP we need to inherit from BaseMultiplayerPlayer!
|
||||||
#if defined ( HL2MP )
|
#if defined ( HL2MP )
|
||||||
#include "basemultiplayerplayer.h"
|
#include "basemultiplayerplayer.h"
|
||||||
|
#elif defined ( MAPBASE )
|
||||||
|
#include "mapbase/singleplayer_animstate.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class CAI_Squad;
|
class CAI_Squad;
|
||||||
@ -432,6 +434,11 @@ private:
|
|||||||
float m_flTimeNextLadderHint; // Next time we're eligible to display a HUD hint about a ladder.
|
float m_flTimeNextLadderHint; // Next time we're eligible to display a HUD hint about a ladder.
|
||||||
|
|
||||||
friend class CHL2GameMovement;
|
friend class CHL2GameMovement;
|
||||||
|
|
||||||
|
#ifdef SP_ANIM_STATE
|
||||||
|
CSinglePlayerAnimState* m_pPlayerAnimState;
|
||||||
|
QAngle m_angEyeAngles;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,6 +198,17 @@ acttable_t CWeapon357::m_acttable[] =
|
|||||||
{ ACT_RANGE_AIM_MED, ACT_RANGE_AIM_REVOLVER_MED, false },
|
{ ACT_RANGE_AIM_MED, ACT_RANGE_AIM_REVOLVER_MED, false },
|
||||||
{ ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_REVOLVER_MED, false },
|
{ ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_REVOLVER_MED, false },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_PISTOL, false },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,6 +171,17 @@ acttable_t CWeaponAR2::m_acttable[] =
|
|||||||
{ ACT_COVER_WALL_LOW_R, ACT_COVER_WALL_LOW_R_RIFLE, false },
|
{ ACT_COVER_WALL_LOW_R, ACT_COVER_WALL_LOW_R_RIFLE, false },
|
||||||
{ ACT_COVER_WALL_LOW_L, ACT_COVER_WALL_LOW_L_RIFLE, false },
|
{ ACT_COVER_WALL_LOW_L, ACT_COVER_WALL_LOW_L_RIFLE, false },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_AR2, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_AR2, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_AR2, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_AR2, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_AR2, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SMG1, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_AR2, false },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_ACTTABLE(CWeaponAR2);
|
IMPLEMENT_ACTTABLE(CWeaponAR2);
|
||||||
|
@ -743,6 +743,17 @@ acttable_t CWeaponCrossbow::m_acttable[] =
|
|||||||
{ ACT_RANGE_AIM_MED, ACT_RANGE_AIM_CROSSBOW_MED, false },
|
{ ACT_RANGE_AIM_MED, ACT_RANGE_AIM_CROSSBOW_MED, false },
|
||||||
{ ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_CROSSBOW_MED, false },
|
{ ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_CROSSBOW_MED, false },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_CROSSBOW, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_CROSSBOW, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_CROSSBOW, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_CROSSBOW, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_CROSSBOW, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_CROSSBOW, false },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_ACTTABLE(CWeaponCrossbow);
|
IMPLEMENT_ACTTABLE(CWeaponCrossbow);
|
||||||
|
@ -49,6 +49,18 @@ acttable_t CWeaponCrowbar::m_acttable[] =
|
|||||||
{ ACT_ARM, ACT_ARM_MELEE, false },
|
{ ACT_ARM, ACT_ARM_MELEE, false },
|
||||||
{ ACT_DISARM, ACT_DISARM_MELEE, false },
|
{ ACT_DISARM, ACT_DISARM_MELEE, false },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SLAM, true },
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_MELEE, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_MELEE, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_MELEE, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_MELEE, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_MELEE, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_MELEE, false },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_ACTTABLE(CWeaponCrowbar);
|
IMPLEMENT_ACTTABLE(CWeaponCrowbar);
|
||||||
|
@ -82,6 +82,17 @@ END_DATADESC()
|
|||||||
acttable_t CWeaponFrag::m_acttable[] =
|
acttable_t CWeaponFrag::m_acttable[] =
|
||||||
{
|
{
|
||||||
{ ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SLAM, true },
|
{ ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SLAM, true },
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_GRENADE, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_GRENADE, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_GRENADE, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_GRENADE, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_GRENADE, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_GRENADE, false },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_ACTTABLE(CWeaponFrag);
|
IMPLEMENT_ACTTABLE(CWeaponFrag);
|
||||||
@ -404,6 +415,10 @@ void CWeaponFrag::ThrowGrenade( CBasePlayer *pPlayer )
|
|||||||
|
|
||||||
WeaponSound( SINGLE );
|
WeaponSound( SINGLE );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||||
|
#endif
|
||||||
|
|
||||||
m_iPrimaryAttacks++;
|
m_iPrimaryAttacks++;
|
||||||
gamestats->Event_WeaponFired( pPlayer, true, GetClassname() );
|
gamestats->Event_WeaponFired( pPlayer, true, GetClassname() );
|
||||||
}
|
}
|
||||||
@ -428,6 +443,10 @@ void CWeaponFrag::LobGrenade( CBasePlayer *pPlayer )
|
|||||||
|
|
||||||
WeaponSound( WPN_DOUBLE );
|
WeaponSound( WPN_DOUBLE );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||||
|
#endif
|
||||||
|
|
||||||
m_bRedraw = true;
|
m_bRedraw = true;
|
||||||
|
|
||||||
m_iPrimaryAttacks++;
|
m_iPrimaryAttacks++;
|
||||||
@ -472,6 +491,10 @@ void CWeaponFrag::RollGrenade( CBasePlayer *pPlayer )
|
|||||||
|
|
||||||
WeaponSound( SPECIAL1 );
|
WeaponSound( SPECIAL1 );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||||
|
#endif
|
||||||
|
|
||||||
m_bRedraw = true;
|
m_bRedraw = true;
|
||||||
|
|
||||||
m_iPrimaryAttacks++;
|
m_iPrimaryAttacks++;
|
||||||
|
@ -1238,6 +1238,9 @@ public:
|
|||||||
|
|
||||||
DECLARE_SERVERCLASS();
|
DECLARE_SERVERCLASS();
|
||||||
DECLARE_DATADESC();
|
DECLARE_DATADESC();
|
||||||
|
#ifdef MAPBASE
|
||||||
|
DECLARE_ACTTABLE();
|
||||||
|
#endif
|
||||||
|
|
||||||
CWeaponPhysCannon( void );
|
CWeaponPhysCannon( void );
|
||||||
|
|
||||||
@ -1455,6 +1458,23 @@ BEGIN_DATADESC( CWeaponPhysCannon )
|
|||||||
|
|
||||||
END_DATADESC()
|
END_DATADESC()
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
acttable_t CWeaponPhysCannon::m_acttable[] =
|
||||||
|
{
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_PHYSGUN, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_PHYSGUN, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_PHYSGUN, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_PHYSGUN, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_PHYSGUN, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_PHYSGUN, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_PHYSGUN, false },
|
||||||
|
{ ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SLAM, false },
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_ACTTABLE( CWeaponPhysCannon );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -257,6 +257,17 @@ acttable_t CWeaponPistol::m_acttable[] =
|
|||||||
{ ACT_COVER_WALL_LOW_R, ACT_COVER_WALL_LOW_R_PISTOL, false },
|
{ ACT_COVER_WALL_LOW_R, ACT_COVER_WALL_LOW_R_PISTOL, false },
|
||||||
{ ACT_COVER_WALL_LOW_L, ACT_COVER_WALL_LOW_L_PISTOL, false },
|
{ ACT_COVER_WALL_LOW_L, ACT_COVER_WALL_LOW_L_PISTOL, false },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_PISTOL, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_PISTOL, false },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1426,6 +1426,17 @@ acttable_t CWeaponRPG::m_acttable[] =
|
|||||||
{ ACT_RANGE_AIM_MED, ACT_RANGE_AIM_RPG_MED, false },
|
{ ACT_RANGE_AIM_MED, ACT_RANGE_AIM_RPG_MED, false },
|
||||||
{ ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_RPG_MED, false },
|
{ ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_RPG_MED, false },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_RPG, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_RPG, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_RPG, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_RPG, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_RPG, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_RPG, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_RPG, false },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_ACTTABLE(CWeaponRPG);
|
IMPLEMENT_ACTTABLE(CWeaponRPG);
|
||||||
|
@ -215,6 +215,17 @@ acttable_t CWeaponShotgun::m_acttable[] =
|
|||||||
{ ACT_RANGE_AIM_MED, ACT_RANGE_AIM_SHOTGUN_MED, false },
|
{ ACT_RANGE_AIM_MED, ACT_RANGE_AIM_SHOTGUN_MED, false },
|
||||||
{ ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_SHOTGUN_MED, false },
|
{ ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_SHOTGUN_MED, false },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_SHOTGUN, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_SHOTGUN, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_SHOTGUN, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_SHOTGUN, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_SHOTGUN, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_SHOTGUN, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_SHOTGUN, false },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_ACTTABLE(CWeaponShotgun);
|
IMPLEMENT_ACTTABLE(CWeaponShotgun);
|
||||||
@ -531,7 +542,11 @@ void CWeaponShotgun::PrimaryAttack( void )
|
|||||||
pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||||
|
|
||||||
// Don't fire again until fire animation has completed
|
// Don't fire again until fire animation has completed
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_flNextPrimaryAttack = gpGlobals->curtime + GetViewModelSequenceDuration();
|
||||||
|
#else
|
||||||
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
|
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
|
||||||
|
#endif
|
||||||
m_iClip1 -= 1;
|
m_iClip1 -= 1;
|
||||||
|
|
||||||
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
|
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
|
||||||
@ -589,7 +604,11 @@ void CWeaponShotgun::SecondaryAttack( void )
|
|||||||
pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||||
|
|
||||||
// Don't fire again until fire animation has completed
|
// Don't fire again until fire animation has completed
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_flNextPrimaryAttack = gpGlobals->curtime + GetViewModelSequenceDuration();
|
||||||
|
#else
|
||||||
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
|
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
|
||||||
|
#endif
|
||||||
m_iClip1 -= 2; // Shotgun uses same clip for primary and secondary attacks
|
m_iClip1 -= 2; // Shotgun uses same clip for primary and secondary attacks
|
||||||
|
|
||||||
Vector vecSrc = pPlayer->Weapon_ShootPosition();
|
Vector vecSrc = pPlayer->Weapon_ShootPosition();
|
||||||
|
@ -149,6 +149,17 @@ acttable_t CWeaponSMG1::m_acttable[] =
|
|||||||
{ ACT_COVER_WALL_LOW_R, ACT_COVER_WALL_LOW_R_RIFLE, false },
|
{ ACT_COVER_WALL_LOW_R, ACT_COVER_WALL_LOW_R_RIFLE, false },
|
||||||
{ ACT_COVER_WALL_LOW_L, ACT_COVER_WALL_LOW_L_RIFLE, false },
|
{ ACT_COVER_WALL_LOW_L, ACT_COVER_WALL_LOW_L_RIFLE, false },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HL2:DM activities (for third-person animations in SP)
|
||||||
|
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_SMG1, false },
|
||||||
|
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_SMG1, false },
|
||||||
|
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_SMG1, false },
|
||||||
|
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_SMG1, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_SMG1, false },
|
||||||
|
{ ACT_HL2MP_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SMG1, false },
|
||||||
|
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_SMG1, false },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_ACTTABLE(CWeaponSMG1);
|
IMPLEMENT_ACTTABLE(CWeaponSMG1);
|
||||||
|
@ -46,6 +46,8 @@ $Project
|
|||||||
$File "$SRCDIR\game\shared\mapbase\MapEdit.h"
|
$File "$SRCDIR\game\shared\mapbase\MapEdit.h"
|
||||||
$File "$SRCDIR\game\shared\mapbase\matchers.cpp"
|
$File "$SRCDIR\game\shared\mapbase\matchers.cpp"
|
||||||
$File "$SRCDIR\game\shared\mapbase\matchers.h"
|
$File "$SRCDIR\game\shared\mapbase\matchers.h"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\singleplayer_animstate.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\singleplayer_animstate.h"
|
||||||
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.cpp" [$MAPBASE_VSCRIPT]
|
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.cpp" [$MAPBASE_VSCRIPT]
|
||||||
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.h" [$MAPBASE_VSCRIPT]
|
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.h" [$MAPBASE_VSCRIPT]
|
||||||
$File "$SRCDIR\game\shared\mapbase\vscript_singletons.cpp" [$MAPBASE_VSCRIPT]
|
$File "$SRCDIR\game\shared\mapbase\vscript_singletons.cpp" [$MAPBASE_VSCRIPT]
|
||||||
|
504
sp/src/game/shared/mapbase/singleplayer_animstate.cpp
Normal file
504
sp/src/game/shared/mapbase/singleplayer_animstate.cpp
Normal file
@ -0,0 +1,504 @@
|
|||||||
|
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||||
|
//
|
||||||
|
// Purpose: Single Player animation state 'handler'. This utility is used
|
||||||
|
// to evaluate the pose parameter value based on the direction
|
||||||
|
// and speed of the player.
|
||||||
|
//
|
||||||
|
//====================================================================================//
|
||||||
|
|
||||||
|
#include "cbase.h"
|
||||||
|
#include "singleplayer_animstate.h"
|
||||||
|
#include "tier0/vprof.h"
|
||||||
|
#include "animation.h"
|
||||||
|
#include "studio.h"
|
||||||
|
#include "apparent_velocity_helper.h"
|
||||||
|
#include "utldict.h"
|
||||||
|
#include "filesystem.h"
|
||||||
|
#include "..\public\datacache\imdlcache.h"
|
||||||
|
|
||||||
|
extern ConVar mp_facefronttime, mp_feetyawrate, mp_ik;
|
||||||
|
|
||||||
|
#define MIN_TURN_ANGLE_REQUIRING_TURN_ANIMATION 15.0f
|
||||||
|
|
||||||
|
CSinglePlayerAnimState *CreatePlayerAnimationState( CBasePlayer *pPlayer )
|
||||||
|
{
|
||||||
|
MDLCACHE_CRITICAL_SECTION();
|
||||||
|
|
||||||
|
CSinglePlayerAnimState *pState = new CSinglePlayerAnimState( pPlayer );
|
||||||
|
pState->Init(pPlayer);
|
||||||
|
|
||||||
|
return pState;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Below this many degrees, slow down turning rate linearly
|
||||||
|
#define FADE_TURN_DEGREES 45.0f
|
||||||
|
// After this, need to start turning feet
|
||||||
|
#define MAX_TORSO_ANGLE 90.0f
|
||||||
|
// Below this amount, don't play a turning animation/perform IK
|
||||||
|
#define MIN_TURN_ANGLE_REQUIRING_TURN_ANIMATION 15.0f
|
||||||
|
|
||||||
|
//static ConVar tf2_feetyawrunscale( "tf2_feetyawrunscale", "2", FCVAR_REPLICATED, "Multiplier on tf2_feetyawrate to allow turning faster when running." );
|
||||||
|
extern ConVar sv_backspeed;
|
||||||
|
extern ConVar mp_feetyawrate;
|
||||||
|
extern ConVar mp_facefronttime;
|
||||||
|
extern ConVar mp_ik;
|
||||||
|
|
||||||
|
CSinglePlayerAnimState::CSinglePlayerAnimState( CBasePlayer *pPlayer ): m_pPlayer( pPlayer )
|
||||||
|
{
|
||||||
|
m_flGaitYaw = 0.0f;
|
||||||
|
m_flGoalFeetYaw = 0.0f;
|
||||||
|
m_flCurrentFeetYaw = 0.0f;
|
||||||
|
m_flCurrentTorsoYaw = 0.0f;
|
||||||
|
m_flLastYaw = 0.0f;
|
||||||
|
m_flLastTurnTime = 0.0f;
|
||||||
|
m_flTurnCorrectionTime = 0.0f;
|
||||||
|
|
||||||
|
m_pPlayer = NULL;
|
||||||
|
};
|
||||||
|
|
||||||
|
void CSinglePlayerAnimState::Init( CBasePlayer *pPlayer )
|
||||||
|
{
|
||||||
|
m_pPlayer = pPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CSinglePlayerAnimState::Update()
|
||||||
|
{
|
||||||
|
m_angRender = GetBasePlayer()->GetLocalAngles();
|
||||||
|
|
||||||
|
ComputePoseParam_BodyYaw();
|
||||||
|
ComputePoseParam_BodyPitch(GetBasePlayer()->GetModelPtr());
|
||||||
|
ComputePoseParam_BodyLookYaw();
|
||||||
|
ComputePoseParam_HeadPitch(GetBasePlayer()->GetModelPtr());
|
||||||
|
|
||||||
|
ComputePlaybackRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSinglePlayerAnimState::Release()
|
||||||
|
{
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CSinglePlayerAnimState::ComputePlaybackRate()
|
||||||
|
{
|
||||||
|
// Determine ideal playback rate
|
||||||
|
Vector vel;
|
||||||
|
GetOuterAbsVelocity( vel );
|
||||||
|
|
||||||
|
float speed = vel.Length2D();
|
||||||
|
|
||||||
|
bool isMoving = ( speed > 0.5f ) ? true : false;
|
||||||
|
|
||||||
|
float maxspeed = GetBasePlayer()->GetSequenceGroundSpeed( GetBasePlayer()->GetSequence() );
|
||||||
|
|
||||||
|
if ( isMoving && ( maxspeed > 0.0f ) )
|
||||||
|
{
|
||||||
|
float flFactor = 1.0f;
|
||||||
|
|
||||||
|
// Note this gets set back to 1.0 if sequence changes due to ResetSequenceInfo below
|
||||||
|
GetBasePlayer()->SetPlaybackRate( ( speed * flFactor ) / maxspeed );
|
||||||
|
|
||||||
|
// BUG BUG:
|
||||||
|
// This stuff really should be m_flPlaybackRate = speed / m_flGroundSpeed
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetBasePlayer()->SetPlaybackRate( 1.0f );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
// Output : CBasePlayer
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
CBasePlayer *CSinglePlayerAnimState::GetBasePlayer()
|
||||||
|
{
|
||||||
|
return m_pPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
// Input : dt -
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CSinglePlayerAnimState::EstimateYaw( void )
|
||||||
|
{
|
||||||
|
float dt = gpGlobals->frametime;
|
||||||
|
|
||||||
|
if ( !dt )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector est_velocity;
|
||||||
|
QAngle angles;
|
||||||
|
|
||||||
|
GetOuterAbsVelocity( est_velocity );
|
||||||
|
|
||||||
|
angles = GetBasePlayer()->GetLocalAngles();
|
||||||
|
|
||||||
|
if ( est_velocity[1] == 0 && est_velocity[0] == 0 )
|
||||||
|
{
|
||||||
|
float flYawDiff = angles[YAW] - m_flGaitYaw;
|
||||||
|
flYawDiff = flYawDiff - (int)(flYawDiff / 360) * 360;
|
||||||
|
if (flYawDiff > 180)
|
||||||
|
flYawDiff -= 360;
|
||||||
|
if (flYawDiff < -180)
|
||||||
|
flYawDiff += 360;
|
||||||
|
|
||||||
|
if (dt < 0.25)
|
||||||
|
flYawDiff *= dt * 4;
|
||||||
|
else
|
||||||
|
flYawDiff *= dt;
|
||||||
|
|
||||||
|
m_flGaitYaw += flYawDiff;
|
||||||
|
m_flGaitYaw = m_flGaitYaw - (int)(m_flGaitYaw / 360) * 360;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_flGaitYaw = (atan2(est_velocity[1], est_velocity[0]) * 180 / M_PI);
|
||||||
|
|
||||||
|
if (m_flGaitYaw > 180)
|
||||||
|
m_flGaitYaw = 180;
|
||||||
|
else if (m_flGaitYaw < -180)
|
||||||
|
m_flGaitYaw = -180;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Override for backpeddling
|
||||||
|
// Input : dt -
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CSinglePlayerAnimState::ComputePoseParam_BodyYaw( void )
|
||||||
|
{
|
||||||
|
int iYaw = GetBasePlayer()->LookupPoseParameter( "move_yaw" );
|
||||||
|
if ( iYaw < 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// view direction relative to movement
|
||||||
|
float flYaw;
|
||||||
|
|
||||||
|
EstimateYaw();
|
||||||
|
|
||||||
|
QAngle angles = GetBasePlayer()->GetLocalAngles();
|
||||||
|
float ang = angles[ YAW ];
|
||||||
|
if ( ang > 180.0f )
|
||||||
|
{
|
||||||
|
ang -= 360.0f;
|
||||||
|
}
|
||||||
|
else if ( ang < -180.0f )
|
||||||
|
{
|
||||||
|
ang += 360.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// calc side to side turning
|
||||||
|
flYaw = ang - m_flGaitYaw;
|
||||||
|
// Invert for mapping into 8way blend
|
||||||
|
flYaw = -flYaw;
|
||||||
|
flYaw = flYaw - (int)(flYaw / 360) * 360;
|
||||||
|
|
||||||
|
if (flYaw < -180)
|
||||||
|
{
|
||||||
|
flYaw = flYaw + 360;
|
||||||
|
}
|
||||||
|
else if (flYaw > 180)
|
||||||
|
{
|
||||||
|
flYaw = flYaw - 360;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetBasePlayer()->SetPoseParameter( iYaw, flYaw );
|
||||||
|
|
||||||
|
#ifndef CLIENT_DLL
|
||||||
|
//Adrian: Make the model's angle match the legs so the hitboxes match on both sides.
|
||||||
|
GetBasePlayer()->SetLocalAngles( QAngle( GetBasePlayer()->EyeAngles().x, m_flCurrentFeetYaw, 0 ) );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CSinglePlayerAnimState::ComputePoseParam_BodyPitch( CStudioHdr *pStudioHdr )
|
||||||
|
{
|
||||||
|
// Get pitch from v_angle
|
||||||
|
float flPitch = GetBasePlayer()->GetLocalAngles()[ PITCH ];
|
||||||
|
|
||||||
|
if ( flPitch > 180.0f )
|
||||||
|
{
|
||||||
|
flPitch -= 360.0f;
|
||||||
|
}
|
||||||
|
flPitch = clamp( flPitch, -90, 90 );
|
||||||
|
|
||||||
|
QAngle absangles = GetBasePlayer()->GetAbsAngles();
|
||||||
|
absangles.x = 0.0f;
|
||||||
|
m_angRender = absangles;
|
||||||
|
|
||||||
|
// See if we have a blender for pitch
|
||||||
|
GetBasePlayer()->SetPoseParameter( pStudioHdr, "aim_pitch", flPitch );
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
// Input : goal -
|
||||||
|
// maxrate -
|
||||||
|
// dt -
|
||||||
|
// current -
|
||||||
|
// Output : int
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
int CSinglePlayerAnimState::ConvergeAngles( float goal,float maxrate, float dt, float& current )
|
||||||
|
{
|
||||||
|
int direction = TURN_NONE;
|
||||||
|
|
||||||
|
float anglediff = goal - current;
|
||||||
|
float anglediffabs = fabs( anglediff );
|
||||||
|
|
||||||
|
anglediff = AngleNormalize( anglediff );
|
||||||
|
|
||||||
|
float scale = 1.0f;
|
||||||
|
if ( anglediffabs <= FADE_TURN_DEGREES )
|
||||||
|
{
|
||||||
|
scale = anglediffabs / FADE_TURN_DEGREES;
|
||||||
|
// Always do at least a bit of the turn ( 1% )
|
||||||
|
scale = clamp( scale, 0.01f, 1.0f );
|
||||||
|
}
|
||||||
|
|
||||||
|
float maxmove = maxrate * dt * scale;
|
||||||
|
|
||||||
|
if ( fabs( anglediff ) < maxmove )
|
||||||
|
{
|
||||||
|
current = goal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( anglediff > 0 )
|
||||||
|
{
|
||||||
|
current += maxmove;
|
||||||
|
direction = TURN_LEFT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current -= maxmove;
|
||||||
|
direction = TURN_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
current = AngleNormalize( current );
|
||||||
|
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSinglePlayerAnimState::ComputePoseParam_BodyLookYaw( void )
|
||||||
|
{
|
||||||
|
QAngle absangles = GetBasePlayer()->GetAbsAngles();
|
||||||
|
absangles.y = AngleNormalize( absangles.y );
|
||||||
|
m_angRender = absangles;
|
||||||
|
|
||||||
|
// See if we even have a blender for pitch
|
||||||
|
int upper_body_yaw = GetBasePlayer()->LookupPoseParameter( "aim_yaw" );
|
||||||
|
if ( upper_body_yaw < 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume upper and lower bodies are aligned and that we're not turning
|
||||||
|
float flGoalTorsoYaw = 0.0f;
|
||||||
|
int turning = TURN_NONE;
|
||||||
|
float turnrate = 360.0f;
|
||||||
|
|
||||||
|
Vector vel;
|
||||||
|
|
||||||
|
GetOuterAbsVelocity( vel );
|
||||||
|
|
||||||
|
bool isMoving = ( vel.Length() > 1.0f ) ? true : false;
|
||||||
|
|
||||||
|
if ( !isMoving )
|
||||||
|
{
|
||||||
|
// Just stopped moving, try and clamp feet
|
||||||
|
if ( m_flLastTurnTime <= 0.0f )
|
||||||
|
{
|
||||||
|
m_flLastTurnTime = gpGlobals->curtime;
|
||||||
|
m_flLastYaw = GetBasePlayer()->EyeAngles().y;
|
||||||
|
// Snap feet to be perfectly aligned with torso/eyes
|
||||||
|
m_flGoalFeetYaw = GetBasePlayer()->EyeAngles().y;
|
||||||
|
m_flCurrentFeetYaw = m_flGoalFeetYaw;
|
||||||
|
m_nTurningInPlace = TURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If rotating in place, update stasis timer
|
||||||
|
|
||||||
|
if ( m_flLastYaw != GetBasePlayer()->EyeAngles().y )
|
||||||
|
{
|
||||||
|
m_flLastTurnTime = gpGlobals->curtime;
|
||||||
|
m_flLastYaw = GetBasePlayer()->EyeAngles().y;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_flGoalFeetYaw != m_flCurrentFeetYaw )
|
||||||
|
{
|
||||||
|
m_flLastTurnTime = gpGlobals->curtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
turning = ConvergeAngles( m_flGoalFeetYaw, turnrate, gpGlobals->frametime, m_flCurrentFeetYaw );
|
||||||
|
|
||||||
|
QAngle eyeAngles = GetBasePlayer()->EyeAngles();
|
||||||
|
QAngle vAngle = GetBasePlayer()->GetLocalAngles();
|
||||||
|
|
||||||
|
// See how far off current feetyaw is from true yaw
|
||||||
|
float yawdelta = GetBasePlayer()->EyeAngles().y - m_flCurrentFeetYaw;
|
||||||
|
yawdelta = AngleNormalize( yawdelta );
|
||||||
|
|
||||||
|
bool rotated_too_far = false;
|
||||||
|
|
||||||
|
float yawmagnitude = fabs( yawdelta );
|
||||||
|
|
||||||
|
// If too far, then need to turn in place
|
||||||
|
if ( yawmagnitude > 45 )
|
||||||
|
{
|
||||||
|
rotated_too_far = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standing still for a while, rotate feet around to face forward
|
||||||
|
// Or rotated too far
|
||||||
|
// FIXME: Play an in place turning animation
|
||||||
|
if ( rotated_too_far ||
|
||||||
|
( gpGlobals->curtime > m_flLastTurnTime + mp_facefronttime.GetFloat() ) )
|
||||||
|
{
|
||||||
|
m_flGoalFeetYaw = GetBasePlayer()->EyeAngles().y;
|
||||||
|
m_flLastTurnTime = gpGlobals->curtime;
|
||||||
|
|
||||||
|
/* float yd = m_flCurrentFeetYaw - m_flGoalFeetYaw;
|
||||||
|
if ( yd > 0 )
|
||||||
|
{
|
||||||
|
m_nTurningInPlace = TURN_RIGHT;
|
||||||
|
}
|
||||||
|
else if ( yd < 0 )
|
||||||
|
{
|
||||||
|
m_nTurningInPlace = TURN_LEFT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_nTurningInPlace = TURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
turning = ConvergeAngles( m_flGoalFeetYaw, turnrate, gpGlobals->frametime, m_flCurrentFeetYaw );
|
||||||
|
yawdelta = GetBasePlayer()->EyeAngles().y - m_flCurrentFeetYaw;*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Snap upper body into position since the delta is already smoothed for the feet
|
||||||
|
flGoalTorsoYaw = yawdelta;
|
||||||
|
m_flCurrentTorsoYaw = flGoalTorsoYaw;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_flLastTurnTime = 0.0f;
|
||||||
|
m_nTurningInPlace = TURN_NONE;
|
||||||
|
m_flCurrentFeetYaw = m_flGoalFeetYaw = GetBasePlayer()->EyeAngles().y;
|
||||||
|
flGoalTorsoYaw = 0.0f;
|
||||||
|
m_flCurrentTorsoYaw = GetBasePlayer()->EyeAngles().y - m_flCurrentFeetYaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( turning == TURN_NONE )
|
||||||
|
{
|
||||||
|
m_nTurningInPlace = turning;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_nTurningInPlace != TURN_NONE )
|
||||||
|
{
|
||||||
|
// If we're close to finishing the turn, then turn off the turning animation
|
||||||
|
if ( fabs( m_flCurrentFeetYaw - m_flGoalFeetYaw ) < MIN_TURN_ANGLE_REQUIRING_TURN_ANIMATION )
|
||||||
|
{
|
||||||
|
m_nTurningInPlace = TURN_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rotate entire body into position
|
||||||
|
absangles = GetBasePlayer()->GetAbsAngles();
|
||||||
|
absangles.y = m_flCurrentFeetYaw;
|
||||||
|
m_angRender = absangles;
|
||||||
|
|
||||||
|
GetBasePlayer()->SetPoseParameter( upper_body_yaw, clamp( m_flCurrentTorsoYaw, -60.0f, 60.0f ) );
|
||||||
|
|
||||||
|
/*
|
||||||
|
// FIXME: Adrian, what is this?
|
||||||
|
int body_yaw = GetBasePlayer()->LookupPoseParameter( "body_yaw" );
|
||||||
|
|
||||||
|
if ( body_yaw >= 0 )
|
||||||
|
{
|
||||||
|
GetBasePlayer()->SetPoseParameter( body_yaw, 30 );
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CSinglePlayerAnimState::ComputePoseParam_HeadPitch( CStudioHdr *pStudioHdr )
|
||||||
|
{
|
||||||
|
// Get pitch from v_angle
|
||||||
|
int iHeadPitch = GetBasePlayer()->LookupPoseParameter("head_pitch");
|
||||||
|
|
||||||
|
float flPitch = GetBasePlayer()->EyeAngles()[PITCH];
|
||||||
|
|
||||||
|
if ( flPitch > 180.0f )
|
||||||
|
{
|
||||||
|
flPitch -= 360.0f;
|
||||||
|
}
|
||||||
|
flPitch = clamp( flPitch, -90, 90 );
|
||||||
|
|
||||||
|
QAngle absangles = GetBasePlayer()->GetAbsAngles();
|
||||||
|
absangles.x = 0.0f;
|
||||||
|
m_angRender = absangles;
|
||||||
|
|
||||||
|
GetBasePlayer()->SetPoseParameter( pStudioHdr, iHeadPitch, flPitch );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
// Input : activity -
|
||||||
|
// Output : Activity
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
Activity CSinglePlayerAnimState::BodyYawTranslateActivity( Activity activity )
|
||||||
|
{
|
||||||
|
// Not even standing still, sigh
|
||||||
|
if ( activity != ACT_IDLE )
|
||||||
|
return activity;
|
||||||
|
|
||||||
|
// Not turning
|
||||||
|
switch ( m_nTurningInPlace )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case TURN_NONE:
|
||||||
|
return activity;
|
||||||
|
/*
|
||||||
|
case TURN_RIGHT:
|
||||||
|
return ACT_TURNRIGHT45;
|
||||||
|
case TURN_LEFT:
|
||||||
|
return ACT_TURNLEFT45;
|
||||||
|
*/
|
||||||
|
case TURN_RIGHT:
|
||||||
|
case TURN_LEFT:
|
||||||
|
return mp_ik.GetBool() ? ACT_TURN : activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert( 0 );
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QAngle& CSinglePlayerAnimState::GetRenderAngles()
|
||||||
|
{
|
||||||
|
return m_angRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSinglePlayerAnimState::GetOuterAbsVelocity( Vector& vel )
|
||||||
|
{
|
||||||
|
#if defined( CLIENT_DLL )
|
||||||
|
GetBasePlayer()->EstimateAbsVelocity( vel );
|
||||||
|
#else
|
||||||
|
vel = GetBasePlayer()->GetAbsVelocity();
|
||||||
|
#endif
|
||||||
|
}
|
88
sp/src/game/shared/mapbase/singleplayer_animstate.h
Normal file
88
sp/src/game/shared/mapbase/singleplayer_animstate.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||||
|
//
|
||||||
|
// Purpose: Single Player animation state 'handler'. This utility is used
|
||||||
|
// to evaluate the pose parameter value based on the direction
|
||||||
|
// and speed of the player.
|
||||||
|
//
|
||||||
|
//====================================================================================//
|
||||||
|
|
||||||
|
#ifndef SINGLEPLAYER_ANIMSTATE_H
|
||||||
|
#define SINGLEPLAYER_ANIMSTATE_H
|
||||||
|
#ifdef _WIN32
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cbase.h"
|
||||||
|
|
||||||
|
#ifdef CLIENT_DLL
|
||||||
|
#include "c_baseplayer.h"
|
||||||
|
#else
|
||||||
|
#include "player.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Special definition for differentiating between SP and HL2:DM anim states
|
||||||
|
#define SP_ANIM_STATE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CSinglePlayerAnimState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TURN_NONE = 0,
|
||||||
|
TURN_LEFT,
|
||||||
|
TURN_RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
|
CSinglePlayerAnimState( CBasePlayer *pPlayer );
|
||||||
|
|
||||||
|
void Init( CBasePlayer *pPlayer );
|
||||||
|
|
||||||
|
Activity BodyYawTranslateActivity( Activity activity );
|
||||||
|
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
const QAngle& GetRenderAngles();
|
||||||
|
|
||||||
|
void GetPoseParameters( CStudioHdr *pStudioHdr, float poseParameter[MAXSTUDIOPOSEPARAM] );
|
||||||
|
|
||||||
|
CBasePlayer *GetBasePlayer();
|
||||||
|
|
||||||
|
void Release();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void GetOuterAbsVelocity( Vector& vel );
|
||||||
|
|
||||||
|
int ConvergeAngles( float goal,float maxrate, float dt, float& current );
|
||||||
|
|
||||||
|
void EstimateYaw( void );
|
||||||
|
void ComputePoseParam_BodyYaw( void );
|
||||||
|
void ComputePoseParam_BodyPitch( CStudioHdr *pStudioHdr );
|
||||||
|
void ComputePoseParam_BodyLookYaw( void );
|
||||||
|
void ComputePoseParam_HeadPitch( CStudioHdr *pStudioHdr );
|
||||||
|
void ComputePlaybackRate();
|
||||||
|
|
||||||
|
CBasePlayer *m_pPlayer;
|
||||||
|
|
||||||
|
float m_flGaitYaw;
|
||||||
|
float m_flStoredCycle;
|
||||||
|
|
||||||
|
float m_flGoalFeetYaw;
|
||||||
|
float m_flCurrentFeetYaw;
|
||||||
|
|
||||||
|
float m_flCurrentTorsoYaw;
|
||||||
|
|
||||||
|
float m_flLastYaw;
|
||||||
|
float m_flLastTurnTime;
|
||||||
|
|
||||||
|
int m_nTurningInPlace;
|
||||||
|
|
||||||
|
QAngle m_angRender;
|
||||||
|
|
||||||
|
float m_flTurnCorrectionTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
CSinglePlayerAnimState *CreatePlayerAnimationState( CBasePlayer *pPlayer );
|
||||||
|
|
||||||
|
#endif // SINGLEPLAYER_ANIMSTATE_H
|
Loading…
x
Reference in New Issue
Block a user