Implemented crossbow worldmodel bolt disappearance on player reload

This commit is contained in:
Blixibon 2021-11-15 16:21:52 -06:00
parent f975e7d10d
commit 450e6a2ff2

View File

@ -591,6 +591,7 @@ private:
void CheckZoomToggle( void ); void CheckZoomToggle( void );
void FireBolt( void ); void FireBolt( void );
#ifdef MAPBASE #ifdef MAPBASE
void SetBolt( int iSetting );
void FireNPCBolt( CAI_BaseNPC *pOwner, Vector &vecShootOrigin, Vector &vecShootDir ); void FireNPCBolt( CAI_BaseNPC *pOwner, Vector &vecShootOrigin, Vector &vecShootDir );
#endif #endif
void ToggleZoom( void ); void ToggleZoom( void );
@ -861,11 +862,7 @@ void CWeaponCrossbow::Reload_NPC( bool bPlaySound )
{ {
BaseClass::Reload_NPC( bPlaySound ); BaseClass::Reload_NPC( bPlaySound );
int iBody = FindBodygroupByName( "bolt" ); SetBolt( 0 );
if (iBody != -1)
SetBodygroup( iBody, 0 );
else
m_nSkin = 0;
} }
#endif #endif
@ -970,6 +967,10 @@ void CWeaponCrossbow::FireBolt( void )
m_iClip1--; m_iClip1--;
#ifdef MAPBASE
SetBolt( 1 );
#endif
pOwner->ViewPunch( QAngle( -2, 0, 0 ) ); pOwner->ViewPunch( QAngle( -2, 0, 0 ) );
WeaponSound( SINGLE ); WeaponSound( SINGLE );
@ -992,6 +993,18 @@ void CWeaponCrossbow::FireBolt( void )
} }
#ifdef MAPBASE #ifdef MAPBASE
//-----------------------------------------------------------------------------
// Purpose: Sets whether or not the bolt is visible
//-----------------------------------------------------------------------------
inline void CWeaponCrossbow::SetBolt( int iSetting )
{
int iBody = FindBodygroupByName( "bolt" );
if (iBody != -1 || (GetOwner() && GetOwner()->IsPlayer())) // HACKHACK: Player models check the viewmodel instead of the worldmodel, so we have to do this manually
SetBodygroup( iBody, iSetting );
else
m_nSkin = iSetting;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: // Purpose:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1015,11 +1028,7 @@ void CWeaponCrossbow::FireNPCBolt( CAI_BaseNPC *pOwner, Vector &vecShootOrigin,
m_iClip1--; m_iClip1--;
int iBody = FindBodygroupByName( "bolt" ); SetBolt( 1 );
if (iBody != -1)
SetBodygroup( iBody, 1 );
else
m_nSkin = 1;
WeaponSound( SINGLE_NPC ); WeaponSound( SINGLE_NPC );
WeaponSound( SPECIAL2 ); WeaponSound( SPECIAL2 );
@ -1041,11 +1050,18 @@ bool CWeaponCrossbow::Deploy( void )
{ {
if ( m_iClip1 <= 0 ) if ( m_iClip1 <= 0 )
{ {
#ifdef MAPBASE
SetBolt( 1 );
#endif
return DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), ACT_CROSSBOW_DRAW_UNLOADED, (char*)GetAnimPrefix() ); return DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), ACT_CROSSBOW_DRAW_UNLOADED, (char*)GetAnimPrefix() );
} }
SetSkin( BOLT_SKIN_GLOW ); SetSkin( BOLT_SKIN_GLOW );
#ifdef MAPBASE
SetBolt( 0 );
#endif
return BaseClass::Deploy(); return BaseClass::Deploy();
} }
@ -1193,6 +1209,10 @@ void CWeaponCrossbow::SetChargerState( ChargerState_t state )
// Shoot some sparks and draw a beam between the two outer points // Shoot some sparks and draw a beam between the two outer points
DoLoadEffect(); DoLoadEffect();
#ifdef MAPBASE
SetBolt( 0 );
#endif
break; break;
case CHARGER_STATE_START_CHARGE: case CHARGER_STATE_START_CHARGE: