Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TF2] Prevent inspecting weapons in more scenarios #1130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
8 changes: 8 additions & 0 deletions src/game/shared/tf/tf_weapon_buff_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ bool CTFBuffItem::Holster( CBaseCombatWeapon *pSwitchingTo )
}
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFBuffItem::CanInspect() const
{
return BaseClass::CanInspect() && !m_bPlayingHorn;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/tf/tf_weapon_buff_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class CTFBuffItem : public CTFWeaponBaseMelee
void RaiseFlag( void );

virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );

virtual bool CanInspect() const OVERRIDE;

virtual bool CanReload( void );

Expand Down
5 changes: 5 additions & 0 deletions src/game/shared/tf/tf_weapon_dragons_fury.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ bool CTFWeaponFlameBall::HasFullCharge() const
return pOwner->m_Shared.GetItemChargeMeter( LOADOUT_POSITION_PRIMARY) >= 100.f;
}

bool CTFWeaponFlameBall::CanInspect() const
{
return BaseClass::CanInspect() && HasFullCharge();
}

void CTFWeaponFlameBall::ItemPostFrame( void )
{
CTFPlayer *pOwner = ToTFPlayer( GetPlayerOwner() );
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/tf/tf_weapon_dragons_fury.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class CTFWeaponFlameBall : public CTFFlameThrower

virtual void OnResourceMeterFilled() OVERRIDE;
virtual float GetMeterMultiplier() const OVERRIDE;

virtual bool CanInspect() const OVERRIDE;

#ifdef GAME_DLL
virtual float GetInitialAfterburnDuration() const OVERRIDE { return 0.f; }
Expand Down
8 changes: 8 additions & 0 deletions src/game/shared/tf/tf_weapon_flamethrower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,14 @@ void CTFFlameThrower::UpdateOnRemove( void )
BaseClass::UpdateOnRemove();
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFFlameThrower::CanInspect() const
{
return BaseClass::CanInspect() && !IsFiring();
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/tf/tf_weapon_flamethrower.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class CTFFlameThrower : public CTFWeaponBaseGun
bool EffectMeterShouldFlash( void );

virtual bool Deploy( void ) OVERRIDE;

virtual bool CanInspect() const OVERRIDE;

#if defined( CLIENT_DLL )

Expand Down
10 changes: 10 additions & 0 deletions src/game/shared/tf/tf_weapon_grenadelauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@ float CTFGrenadeLauncher::GetChargeMaxTime( void )
return GetMortarDetonateTimeLength();
}

bool CTFGrenadeLauncher::CanInspect() const
{
// we are charging a ball, so don't inspect
if ( m_flDetonateTime > gpGlobals->curtime )
{
return false;
}

return BaseClass::CanInspect();
}

void CTFGrenadeLauncher::ResetDetonateTime()
{
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/tf/tf_weapon_grenadelauncher.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class CTFGrenadeLauncher : public CTFWeaponBaseGun, public ITFChargeUpWeapon
virtual bool CanCharge( void );
virtual float GetChargeBeginTime( void );
virtual float GetChargeMaxTime( void );

virtual bool CanInspect() const OVERRIDE;

void LaunchGrenade( void );

Expand Down
19 changes: 19 additions & 0 deletions src/game/shared/tf/tf_weaponbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,7 @@ bool CTFWeaponBase::ReloadSingly( void )
{
if ( SendWeaponAnim( ACT_RELOAD_FINISH ) )
{
m_flTimeFinishReloadSingly = gpGlobals->curtime + SequenceDuration();
// We're done, allow primary attack as soon as we like unless we're an energy weapon.
// if ( IsEnergyWeapon() )
// {
Expand Down Expand Up @@ -2549,6 +2550,24 @@ void CTFWeaponBase::HandleInspect()
// first time pressing inspecting key
if ( !m_bInspecting && pPlayer->IsInspecting() )
{
// Don't inspect while reloading or zooming. TF_COND_ZOOMED for the Classic
if ( IsReloading() || pPlayer->m_Shared.InCond( TF_COND_AIMING ) || pPlayer->m_Shared.InCond( TF_COND_ZOOMED ) )
{
return;
}

// Don't inspect if the player has just fired
if ( gpGlobals->curtime < m_flNextPrimaryAttack )
{
return;
}

// Don't inspect if the weapon isn't idle after reloading last bullet
if ( gpGlobals->curtime < m_flTimeFinishReloadSingly )
{
return;
}

m_nInspectStage = INSPECT_INVALID;
m_flInspectAnimEndTime = -1.f;
if ( SendWeaponAnim( GetInspectActivity( INSPECT_START ) ) )
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/tf/tf_weaponbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,8 @@ class CTFWeaponBase : public CBaseCombatWeapon, public IHasOwner, public IHasGen
int m_iLastCritCheckFrame;
int m_iCurrentSeed;
float m_flLastRapidFireCritCheckTime;

float m_flTimeFinishReloadSingly;

float m_flLastDeployTime;

Expand Down