Added new player animation types and applied more player animations to SP HL2 weapons

This commit is contained in:
Blixibon
2021-11-15 14:43:58 -06:00
parent 6755a4d3f6
commit 41d799bbdf
13 changed files with 118 additions and 6 deletions

View File

@@ -1581,6 +1581,10 @@ bool CBaseCombatWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, i
SetViewModel();
SendWeaponAnim( iActivity );
#ifdef MAPBASE
pOwner->SetAnimation( PLAYER_UNHOLSTER );
#endif
pOwner->SetNextAttack( gpGlobals->curtime + SequenceDuration() );
}
@@ -1652,6 +1656,11 @@ bool CBaseCombatWeapon::Holster( CBaseCombatWeapon *pSwitchingTo )
if (pOwner)
{
pOwner->SetNextAttack( gpGlobals->curtime + flSequenceDuration );
#ifdef MAPBASE
if (pOwner->IsPlayer())
static_cast<CBasePlayer*>(pOwner)->SetAnimation( PLAYER_HOLSTER );
#endif
}
// If we don't have a holster anim, hide immediately to avoid timing issues

View File

@@ -146,6 +146,16 @@ void CSinglePlayerAnimState::SetPlayerAnimation( PLAYER_ANIM playerAnim )
m_bFiring = m_iFireSequence != -1;
m_flFireCycle = 0;
}
else if ( playerAnim == PLAYER_ATTACK2 )
{
#ifdef EXPANDED_HL2DM_ACTIVITIES
m_iFireSequence = SelectWeightedSequence( TranslateActivity( ACT_HL2MP_GESTURE_RANGE_ATTACK2 ) );
#else
m_iFireSequence = SelectWeightedSequence( TranslateActivity( ACT_HL2MP_GESTURE_RANGE_ATTACK ) );
#endif
m_bFiring = m_iFireSequence != -1;
m_flFireCycle = 0;
}
else if ( playerAnim == PLAYER_JUMP )
{
// Play the jump animation.
@@ -168,6 +178,22 @@ void CSinglePlayerAnimState::SetPlayerAnimation( PLAYER_ANIM playerAnim )
m_flReloadCycle = 0;
}
}
else if ( playerAnim == PLAYER_UNHOLSTER || playerAnim == PLAYER_HOLSTER )
{
m_iWeaponSwitchSequence = SelectWeightedSequence( TranslateActivity( playerAnim == PLAYER_UNHOLSTER ? ACT_ARM : ACT_DISARM ) );
if (m_iWeaponSwitchSequence != -1)
{
// clear other events that might be playing in our layer
m_bPlayingMisc = false;
m_bReloading = false;
m_bWeaponSwitching = true;
m_flWeaponSwitchCycle = 0;
m_flMiscBlendOut = 0.1f;
m_flMiscBlendIn = 0.1f;
m_bMiscNoOverride = false;
}
}
}
//-----------------------------------------------------------------------------
@@ -226,6 +252,26 @@ void CSinglePlayerAnimState::ComputeSequences( CStudioHdr *pStudioHdr )
ComputeWeaponSwitchSequence();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CSinglePlayerAnimState::AddMiscSequence( int iSequence, float flBlendIn, float flBlendOut, float flPlaybackRate, bool bHoldAtEnd, bool bOnlyWhenStill )
{
Assert( iSequence != -1 );
m_iMiscSequence = iSequence;
m_flMiscBlendIn = flBlendIn;
m_flMiscBlendOut = flBlendOut;
m_bPlayingMisc = true;
m_bMiscHoldAtEnd = bHoldAtEnd;
m_bReloading = false;
m_flMiscCycle = 0;
m_bMiscOnlyWhenStill = bOnlyWhenStill;
m_bMiscNoOverride = true;
m_fMiscPlaybackRate = flPlaybackRate;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -386,9 +432,7 @@ void CSinglePlayerAnimState::ComputeWeaponSwitchSequence()
// does misc gestures if we're not firing
void CSinglePlayerAnimState::ComputeMiscSequence()
{
bool bHoldAtEnd = false;
UpdateLayerSequenceGeneric( RELOADSEQUENCE_LAYER, m_bPlayingMisc, m_flMiscCycle, m_iMiscSequence, bHoldAtEnd, m_flMiscBlendIn, m_flMiscBlendOut, m_bMiscOnlyWhenStill, m_fMiscPlaybackRate );
UpdateLayerSequenceGeneric( RELOADSEQUENCE_LAYER, m_bPlayingMisc, m_flMiscCycle, m_iMiscSequence, m_bMiscHoldAtEnd, m_flMiscBlendIn, m_flMiscBlendOut, m_bMiscOnlyWhenStill, m_fMiscPlaybackRate );
}
//-----------------------------------------------------------------------------

View File

@@ -48,6 +48,8 @@ public:
void ComputeSequences( CStudioHdr *pStudioHdr );
void AddMiscSequence( int iSequence, float flBlendIn = 0.0f, float flBlendOut = 0.0f, float flPlaybackRate = 1.0f, bool bHoldAtEnd = false, bool bOnlyWhenStill = false );
void ClearAnimationState();
void ClearAnimationLayers();
@@ -91,7 +93,7 @@ private:
bool m_bPlayingMisc;
float m_flMiscCycle, m_flMiscBlendOut, m_flMiscBlendIn;
int m_iMiscSequence;
bool m_bMiscOnlyWhenStill;
bool m_bMiscOnlyWhenStill, m_bMiscHoldAtEnd;
bool m_bMiscNoOverride;
float m_fMiscPlaybackRate;
bool m_bMiscCycleRewound;

View File

@@ -366,6 +366,14 @@ enum PLAYER_ANIM
PLAYER_RELOAD,
PLAYER_START_AIMING,
PLAYER_LEAVE_AIMING,
#ifdef MAPBASE
// New player animations from Mapbase
PLAYER_ATTACK2,
PLAYER_ATTACK3,
PLAYER_UNHOLSTER,
PLAYER_HOLSTER,
#endif
};
#ifdef HL2_DLL