Skip to content
Closed
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
40 changes: 39 additions & 1 deletion src/game/shared/tf/tf_weapon_pistol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifdef CLIENT_DLL
#include "c_tf_player.h"
#include "c_tf_gamestats.h"
#include "prediction.h"
// Server specific.
#else
#include "tf_player.h"
Expand Down Expand Up @@ -110,7 +111,44 @@ void CTFPistol_ScoutPrimary::SecondaryAttack( void )
m_flNextSecondaryAttack = gpGlobals->curtime + 1.5f;
m_flPushTime = gpGlobals->curtime + 0.2f; // Anim delay

EmitSound( "Weapon_Hands.Push" );
#ifdef CLIENT_DLL
if ( !prediction->InPrediction() || prediction->IsFirstTimePredicted() )
#endif
{
EmitSound( "Weapon_Hands.Push" );
}
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFPistol_ScoutPrimary::Reload( void )
{
// allow reloading 0.5 secs early, since the full 1.5-sec delay looks awkward
if ( ( m_flNextSecondaryAttack - 0.5f ) > gpGlobals->curtime )
return false;

return BaseClass::Reload();
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFPistol_ScoutPrimary::ShouldAbortReload()
{
if ( BaseClass::ShouldAbortReload() )
return true;

// allow aborting reloads with alt-fire

if ( m_flNextSecondaryAttack > gpGlobals->curtime )
return false;

CBasePlayer *pOwner = GetPlayerOwner();
if ( !pOwner )
return false;

return pOwner->m_nButtons & IN_ATTACK2;
}

//-----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/tf/tf_weapon_pistol.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class CTFPistol_ScoutPrimary : public CTFPistol_Scout
virtual int GetWeaponID( void ) const { return TF_WEAPON_HANDGUN_SCOUT_PRIMARY; }
virtual void PlayWeaponShootSound( void );
virtual void SecondaryAttack( void );
virtual bool Reload( void );
virtual bool ShouldAbortReload();
virtual void ItemPostFrame();
virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );
virtual void Precache( void );
Expand Down
11 changes: 10 additions & 1 deletion src/game/shared/tf/tf_weaponbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,15 @@ bool CTFWeaponBase::IsReloading() const
return m_iReloadMode != TF_RELOAD_START;
}

bool CTFWeaponBase::ShouldAbortReload() //const
{
CBasePlayer *pOwner = GetPlayerOwner();
if ( !pOwner )
return false;

return ( pOwner->m_nButtons & IN_ATTACK ) && Clip1() > 0;
}

bool CTFWeaponBase::UsesCenterFireProjectile( void ) const
{
int nCenterFireProjectile = 0;
Expand Down Expand Up @@ -2377,7 +2386,7 @@ void CTFWeaponBase::ItemBusyFrame( void )
}

// Interrupt a reload on reload singly weapons.
if ( ( pOwner->m_nButtons & IN_ATTACK ) && Clip1() > 0 )
if ( ShouldAbortReload() )
{
bool bAbortReload = false;
if ( m_bReloadsSingly )
Expand Down
1 change: 1 addition & 0 deletions src/game/shared/tf/tf_weaponbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ class CTFWeaponBase : public CBaseCombatWeapon, public IHasOwner, public IHasGen
void SendReloadEvents();
virtual bool IsReloading() const; // is the weapon reloading right now?
virtual float GetReloadSpeedScale() const { return 1.f; }
virtual bool ShouldAbortReload();// const;

virtual bool AutoFiresFullClip( void ) const OVERRIDE;
bool AutoFiresFullClipAllAtOnce( void ) const;
Expand Down