Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/game/server/swarm/asw_marine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
35 changes: 32 additions & 3 deletions src/game/shared/swarm/asw_playeranimstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/swarm/asw_playeranimstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions src/game/shared/swarm/asw_weapon_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -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" );
Expand Down
Loading