diff --git a/src/game/server/swarm/asw_marine.cpp b/src/game/server/swarm/asw_marine.cpp index f2e08f443..5c379c1f9 100644 --- a/src/game/server/swarm/asw_marine.cpp +++ b/src/game/server/swarm/asw_marine.cpp @@ -504,6 +504,8 @@ void CASW_Marine::DoAnimationEvent( PlayerAnimEvent_t event ) { if (gpGlobals->maxClients > 1 && (event == PLAYERANIMEVENT_RELOAD || event == PLAYERANIMEVENT_JUMP || event == PLAYERANIMEVENT_WEAPON_SWITCH + || event == PLAYERANIMEVENT_RELOAD_SUCCEED + || event == PLAYERANIMEVENT_RELOAD_FAIL || event == PLAYERANIMEVENT_HEAL || event == PLAYERANIMEVENT_KICK || event == PLAYERANIMEVENT_THROW_GRENADE || event == PLAYERANIMEVENT_BAYONET || event == PLAYERANIMEVENT_PICKUP || ( event >= PLAYERANIMEVENT_MELEE && event <= PLAYERANIMEVENT_MELEE_LAST ) diff --git a/src/game/shared/swarm/asw_playeranimstate.cpp b/src/game/shared/swarm/asw_playeranimstate.cpp index eb78630ec..aa2601e67 100644 --- a/src/game/shared/swarm/asw_playeranimstate.cpp +++ b/src/game/shared/swarm/asw_playeranimstate.cpp @@ -191,6 +191,7 @@ class CASWPlayerAnimState : public CBasePlayerAnimState, public IASWPlayerAnimSt int m_iReloadSequence; float m_flReloadBlendOut, m_flReloadBlendIn; float m_fReloadPlaybackRate; + float m_fReloadAnimTime; bool m_bWeaponSwitching; float m_flWeaponSwitchCycle; @@ -340,20 +341,48 @@ void CASWPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event ) fReloadTime *= MarineSkills()->GetSkillBasedValueByMarine( pMarine, ASW_MARINE_SKILL_RELOADING, ASW_MARINE_SUBSKILL_RELOADING_SPEED_SCALE ); } - // calc playback rate needed to play the whole anim in this time + // calc playback time needed to play the whole anim // normal weapon reload anim is 48fps and 105 frames = 2.1875 seconds // normal weapon reload time in script is 2.2 seconds // pistol weapon reload anim is 38fps and 38 frames = 1 second // pistol weapon reload time in script is 1.0 seconds if (bShortReloadAnim) - m_fReloadPlaybackRate = 1.0f / fReloadTime; //38.0f / (fReloadTime * 38.0f); + m_fReloadAnimTime = 1.0f; // 38.0f / 38.0f; else - m_fReloadPlaybackRate = 105.6f / (fReloadTime * 48.0f); + m_fReloadAnimTime = 105.6f / 48.0f; + + m_fReloadPlaybackRate = m_fReloadAnimTime / fReloadTime; m_bReloading = true; m_flReloadCycle = 0; } } + else if ( event == PLAYERANIMEVENT_RELOAD_SUCCEED ) + { + if ( m_bReloading == true && m_flReloadCycle < 1.0f ) + { + // readjust animation speed to match new attack delay + const float fFastReloadTime = 0.5f; + + const float fRemainingCycle = 1.0f - m_flReloadCycle; + m_fReloadPlaybackRate = m_fReloadAnimTime * fRemainingCycle / fFastReloadTime; + } + } + else if ( event == PLAYERANIMEVENT_RELOAD_FAIL ) + { + if ( m_bReloading == true && m_flReloadCycle < 1.0f ) + { + // readjust animation speed to match new attack delay + const float fFailReloadMinDelay = 2.0f; + + CASW_Marine *pOuter = CASW_Marine::AsMarine( GetOuter() ); + CASW_Weapon *pWeapon = pOuter ? pOuter->GetActiveASWWeapon() : NULL; + const float fFailReloadTime = pWeapon ? pWeapon->GetReloadFailTime() : fFailReloadMinDelay; + + const float fRemainingCycle = 1.0f - m_flReloadCycle; + m_fReloadPlaybackRate = m_fReloadAnimTime * fRemainingCycle / fFailReloadTime; + } + } else if ( event == PLAYERANIMEVENT_DROP_MAGAZINE_GIB ) { #ifdef CLIENT_DLL diff --git a/src/game/shared/swarm/asw_playeranimstate.h b/src/game/shared/swarm/asw_playeranimstate.h index 1a45fd1cd..6c3275869 100644 --- a/src/game/shared/swarm/asw_playeranimstate.h +++ b/src/game/shared/swarm/asw_playeranimstate.h @@ -36,6 +36,8 @@ enum PlayerAnimEvent_t PLAYERANIMEVENT_THROW_GRENADE, PLAYERANIMEVENT_JUMP, PLAYERANIMEVENT_RELOAD, + PLAYERANIMEVENT_RELOAD_SUCCEED, + PLAYERANIMEVENT_RELOAD_FAIL, PLAYERANIMEVENT_WEAPON_SWITCH, PLAYERANIMEVENT_FLINCH, PLAYERANIMEVENT_GO, diff --git a/src/game/shared/swarm/asw_weapon_shared.cpp b/src/game/shared/swarm/asw_weapon_shared.cpp index 230915aa0..30d2c5030 100644 --- a/src/game/shared/swarm/asw_weapon_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_shared.cpp @@ -178,11 +178,9 @@ void CASW_Weapon::ItemBusyFrame( void ) pOwner->SetNextAttack( flSucceedDelay ); m_flNextPrimaryAttack = m_flNextSecondaryAttack = flSucceedDelay; - // TODO: hook up anim - //pMarine->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_SUCCEED ); + pMarine->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_SUCCEED ); DispatchParticleEffect( "fast_reload", PATTACH_POINT_FOLLOW, this, "muzzle" ); - pMarine->m_flPreventLaserSightTime = gpGlobals->curtime + 2.5f; #ifdef GAME_DLL pMarine->m_nFastReloadsInARow++; @@ -267,8 +265,7 @@ void CASW_Weapon::ItemBusyFrame( void ) m_flReloadFailTime = m_flNextPrimaryAttack - gpGlobals->curtime; } - // TODO: hook up anim - //pMarine->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_FAIL ); + pMarine->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_FAIL ); #ifdef GAME_DLL IGameEvent *event = gameeventmanager->CreateEvent( "fast_reload_fail" );