From f4a0bfb186b97a71382e048882ea03bf8f43a51e Mon Sep 17 00:00:00 2001 From: SuperCake Date: Sun, 26 Apr 2026 22:12:35 +0200 Subject: [PATCH 1/6] Extract reload animation time variable --- src/game/shared/swarm/asw_playeranimstate.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/game/shared/swarm/asw_playeranimstate.cpp b/src/game/shared/swarm/asw_playeranimstate.cpp index eb78630ec..707241a95 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,15 +341,17 @@ 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; From 3b8473ecfbb60a4ec89ce8d70018edae577ecb09 Mon Sep 17 00:00:00 2001 From: SuperCake Date: Mon, 27 Apr 2026 00:02:43 +0200 Subject: [PATCH 2/6] Add fast reload player animation events --- src/game/server/swarm/asw_marine.cpp | 2 ++ src/game/shared/swarm/asw_playeranimstate.cpp | 6 ++++++ src/game/shared/swarm/asw_playeranimstate.h | 2 ++ 3 files changed, 10 insertions(+) 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 707241a95..bc2df779d 100644 --- a/src/game/shared/swarm/asw_playeranimstate.cpp +++ b/src/game/shared/swarm/asw_playeranimstate.cpp @@ -357,6 +357,12 @@ void CASWPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event ) m_flReloadCycle = 0; } } + else if ( event == PLAYERANIMEVENT_RELOAD_SUCCEED ) + { + } + else if ( event == PLAYERANIMEVENT_RELOAD_FAIL ) + { + } 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, From 690a89d31e4f7f300be7c7eca494e34b2d50f95c Mon Sep 17 00:00:00 2001 From: SuperCake Date: Mon, 27 Apr 2026 00:03:47 +0200 Subject: [PATCH 3/6] Add fast reload player animation event emitters There was outcommented code, so it should be the right place for event emitter --- src/game/shared/swarm/asw_weapon_shared.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/game/shared/swarm/asw_weapon_shared.cpp b/src/game/shared/swarm/asw_weapon_shared.cpp index 230915aa0..8695dbc80 100644 --- a/src/game/shared/swarm/asw_weapon_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_shared.cpp @@ -178,8 +178,7 @@ 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; @@ -267,8 +266,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" ); From f5d8d486ca0b195396ea3b23bb388f1283307b3e Mon Sep 17 00:00:00 2001 From: SuperCake Date: Mon, 27 Apr 2026 00:06:54 +0200 Subject: [PATCH 4/6] Add succeed fast reload player animation event handling --- src/game/shared/swarm/asw_playeranimstate.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/game/shared/swarm/asw_playeranimstate.cpp b/src/game/shared/swarm/asw_playeranimstate.cpp index bc2df779d..a2238cdf8 100644 --- a/src/game/shared/swarm/asw_playeranimstate.cpp +++ b/src/game/shared/swarm/asw_playeranimstate.cpp @@ -359,6 +359,14 @@ void CASWPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event ) } 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 ) { From 659fe17d1c5bb73b216e1b66b0e052017a9c2881 Mon Sep 17 00:00:00 2001 From: SuperCake Date: Mon, 27 Apr 2026 00:07:18 +0200 Subject: [PATCH 5/6] Add failed fast reload player animation event handling --- src/game/shared/swarm/asw_playeranimstate.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/game/shared/swarm/asw_playeranimstate.cpp b/src/game/shared/swarm/asw_playeranimstate.cpp index a2238cdf8..aa2601e67 100644 --- a/src/game/shared/swarm/asw_playeranimstate.cpp +++ b/src/game/shared/swarm/asw_playeranimstate.cpp @@ -370,6 +370,18 @@ void CASWPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event ) } 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 ) { From 9a93af6b41d032bf84d5c9b4d7354bd98c036b27 Mon Sep 17 00:00:00 2001 From: SuperCake Date: Mon, 27 Apr 2026 19:02:55 +0200 Subject: [PATCH 6/6] Remove old fix for laser sight breaking animation after fast reload --- src/game/shared/swarm/asw_weapon_shared.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/game/shared/swarm/asw_weapon_shared.cpp b/src/game/shared/swarm/asw_weapon_shared.cpp index 8695dbc80..30d2c5030 100644 --- a/src/game/shared/swarm/asw_weapon_shared.cpp +++ b/src/game/shared/swarm/asw_weapon_shared.cpp @@ -181,7 +181,6 @@ void CASW_Weapon::ItemBusyFrame( void ) 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++;