Difference between revisions of "Lowering your weapon on sprint"
ICrazyBlaze (talk | contribs) m |
ICrazyBlaze (talk | contribs) m |
||
Line 1: | Line 1: | ||
This article will deal with lowering your weapon while sprinting and disable the ability to shoot at the same time. | This article will deal with lowering your weapon while sprinting and disable the ability to shoot at the same time. | ||
− | This was based on a [http://forums.steampowered.com/forums/showthread.php?t=829259&highlight=lowering topic on the Steam Forums] | + | This was based on a [http://forums.steampowered.com/forums/showthread.php?t=829259&highlight=lowering topic on the Steam Forums] (no longer available) |
{{note|1=This has only been tested with the latest HL2MP OB engine code.}} | {{note|1=This has only been tested with the latest HL2MP OB engine code.}} |
Revision as of 05:09, 11 November 2017
This article will deal with lowering your weapon while sprinting and disable the ability to shoot at the same time. This was based on a topic on the Steam Forums (no longer available)




The Code

BASECOMBATWEAPON_SHARED.CPP
Hit CTRL+F and search for this code:
void CBaseCombatWeapon::ItemPostFrame( void )
Then copy and paste this above it:
void CBaseCombatWeapon::ProcessAnimationEvents(void)
{
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if (!pOwner)
return;
if ( !m_bWeaponIsLowered && (pOwner->m_nButtons & IN_SPEED ) )
{
m_bWeaponIsLowered = true;
SendWeaponAnim( ACT_VM_IDLE_LOWERED );
m_flNextPrimaryAttack = gpGlobals->curtime + GetViewModelSequenceDuration();
m_flNextSecondaryAttack = m_flNextPrimaryAttack;
}
else if ( m_bWeaponIsLowered && !(pOwner->m_nButtons & IN_SPEED ) )
{
m_bWeaponIsLowered = false;
SendWeaponAnim( ACT_VM_IDLE );
m_flNextPrimaryAttack = gpGlobals->curtime + GetViewModelSequenceDuration();
m_flNextSecondaryAttack = m_flNextPrimaryAttack;
}
if ( m_bWeaponIsLowered )
{
if ( gpGlobals->curtime > m_flNextPrimaryAttack )
{
SendWeaponAnim( ACT_VM_IDLE_LOWERED );
m_flNextPrimaryAttack = gpGlobals->curtime + GetViewModelSequenceDuration();
m_flNextSecondaryAttack = m_flNextPrimaryAttack;
}
}
}
Now to make sure our code gets called we add ProcessAnimationEvents(); here:
void CBaseCombatWeapon::ItemPostFrame( void )
{
//Add this underneath the pOwner accessor check.
ProcessAnimationEvents();
}
BASECOMBATWEAPON_SHARED.H
Add these declarations under public at line 211 below bool IsViewModelSequenceFinished( void ); // Returns if the viewmodel's current animation is finished:

virtual void ProcessAnimationEvents(void);
bool m_bWeaponIsLowered;
Finish
Now your weapon should be lowered when you hit the sprint button and you will not be able to shoot until you release the button!