diff --git a/mp/src/game/client/c_baseplayer.cpp b/mp/src/game/client/c_baseplayer.cpp index e95517699..d6bc27612 100644 --- a/mp/src/game/client/c_baseplayer.cpp +++ b/mp/src/game/client/c_baseplayer.cpp @@ -1854,6 +1854,13 @@ void C_BasePlayer::ThirdPersonSwitch( bool bThirdperson ) } } } + + //Notify weapon. + CBaseCombatWeapon *pWeapon = GetActiveWeapon(); + if ( pWeapon ) + { + pWeapon->ThirdPersonSwitch( bThirdperson ); + } } } diff --git a/mp/src/game/shared/basecombatweapon_shared.h b/mp/src/game/shared/basecombatweapon_shared.h index 701403a07..1b1ddbc25 100644 --- a/mp/src/game/shared/basecombatweapon_shared.h +++ b/mp/src/game/shared/basecombatweapon_shared.h @@ -512,6 +512,9 @@ public: bool WantsToOverrideViewmodelAttachments( void ) { return false; } #endif + //Tony; notifications of any third person switches. + virtual void ThirdPersonSwitch( bool bThirdPerson ) {}; + #endif // End client-only methods virtual bool CanLower( void ) { return false; } diff --git a/mp/src/game/shared/hl2mp/weapon_crossbow.cpp b/mp/src/game/shared/hl2mp/weapon_crossbow.cpp index 5bada600f..5d22003e8 100644 --- a/mp/src/game/shared/hl2mp/weapon_crossbow.cpp +++ b/mp/src/game/shared/hl2mp/weapon_crossbow.cpp @@ -792,29 +792,34 @@ void CWeaponCrossbow::DoLoadEffect( void ) if ( pOwner == NULL ) return; - CBaseViewModel *pViewModel = pOwner->GetViewModel(); - - if ( pViewModel == NULL ) - return; - + //Tony; change this up a bit; on the server, dispatch an effect but don't send it to the client who fires + //on the client, create an effect either in the view model, or on the world model if first person. CEffectData data; -#ifdef CLIENT_DLL - data.m_hEntity = pViewModel->GetRefEHandle(); -#else - data.m_nEntIndex = pViewModel->entindex(); -#endif data.m_nAttachmentIndex = 1; + data.m_vOrigin = pOwner->GetAbsOrigin(); - DispatchEffect( "CrossbowLoad", data ); + CPASFilter filter( data.m_vOrigin ); + +#ifdef GAME_DLL + filter.RemoveRecipient( pOwner ); + data.m_nEntIndex = entindex(); +#else + CBaseViewModel *pViewModel = pOwner->GetViewModel(); + if ( ShouldDrawUsingViewModel() && pViewModel != NULL ) + data.m_hEntity = pViewModel->GetRefEHandle(); + else + data.m_hEntity = GetRefEHandle(); +#endif + + DispatchEffect( "CrossbowLoad", data, filter ); #ifndef CLIENT_DLL - CSprite *pBlast = CSprite::SpriteCreate( CROSSBOW_GLOW_SPRITE2, GetAbsOrigin(), false ); if ( pBlast ) { - pBlast->SetAttachment( pOwner->GetViewModel(), 1 ); + pBlast->SetAttachment( this, 1 ); pBlast->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxNone ); pBlast->SetBrightness( 128 ); pBlast->SetScale( 0.2f ); diff --git a/mp/src/game/shared/hl2mp/weapon_physcannon.cpp b/mp/src/game/shared/hl2mp/weapon_physcannon.cpp index 4972a1ed6..a5537a85a 100644 --- a/mp/src/game/shared/hl2mp/weapon_physcannon.cpp +++ b/mp/src/game/shared/hl2mp/weapon_physcannon.cpp @@ -1224,7 +1224,9 @@ protected: bool m_bOldOpen; // Used for parity checks void NotifyShouldTransmit( ShouldTransmitState_t state ); - +private: + virtual void ThirdPersonSwitch( bool bThirdPerson ); +protected: #endif // CLIENT_DLL int m_nChangeState; // For delayed state change of elements @@ -2601,56 +2603,26 @@ void CWeaponPhysCannon::DoEffectIdle( void ) StartEffects(); - //if ( ShouldDrawUsingViewModel() ) + // Turn on the glow sprites + for ( int i = PHYSCANNON_GLOW1; i < (PHYSCANNON_GLOW1+NUM_GLOW_SPRITES); i++ ) { - // Turn on the glow sprites - for ( int i = PHYSCANNON_GLOW1; i < (PHYSCANNON_GLOW1+NUM_GLOW_SPRITES); i++ ) - { - m_Parameters[i].GetScale().SetAbsolute( random->RandomFloat( 0.075f, 0.05f ) * SPRITE_SCALE ); - m_Parameters[i].GetAlpha().SetAbsolute( random->RandomInt( 24, 32 ) ); - } - - // Turn on the glow sprites - for ( int i = PHYSCANNON_ENDCAP1; i < (PHYSCANNON_ENDCAP1+NUM_ENDCAP_SPRITES); i++ ) - { - m_Parameters[i].GetScale().SetAbsolute( random->RandomFloat( 3, 5 ) ); - m_Parameters[i].GetAlpha().SetAbsolute( random->RandomInt( 200, 255 ) ); - } - - if ( m_EffectState != EFFECT_HOLDING ) - { - // Turn beams off - m_Beams[0].SetVisible( false ); - m_Beams[1].SetVisible( false ); - m_Beams[2].SetVisible( false ); - } + m_Parameters[i].GetScale().SetAbsolute( random->RandomFloat( 0.075f, 0.05f ) * SPRITE_SCALE ); + m_Parameters[i].GetAlpha().SetAbsolute( random->RandomInt( 24, 32 ) ); } - /* - else + + // Turn on the glow sprites + for ( int i = PHYSCANNON_ENDCAP1; i < (PHYSCANNON_ENDCAP1+NUM_ENDCAP_SPRITES); i++ ) { - // Turn on the glow sprites - for ( int i = PHYSCANNON_GLOW1; i < (PHYSCANNON_GLOW1+NUM_GLOW_SPRITES); i++ ) - { - m_Parameters[i].GetScale().SetAbsolute( random->RandomFloat( 0.075f, 0.05f ) * SPRITE_SCALE ); - m_Parameters[i].GetAlpha().SetAbsolute( random->RandomInt( 24, 32 ) ); - } - - // Turn on the glow sprites - for ( i = PHYSCANNON_ENDCAP1; i < (PHYSCANNON_ENDCAP1+NUM_ENDCAP_SPRITES); i++ ) - { - m_Parameters[i].GetScale().SetAbsolute( random->RandomFloat( 3, 5 ) ); - m_Parameters[i].GetAlpha().SetAbsolute( random->RandomInt( 200, 255 ) ); - } - - if ( m_EffectState != EFFECT_HOLDING ) - { - // Turn beams off - m_Beams[0].SetVisible( false ); - m_Beams[1].SetVisible( false ); - m_Beams[2].SetVisible( false ); - } + m_Parameters[i].GetScale().SetAbsolute( random->RandomFloat( 3, 5 ) ); + m_Parameters[i].GetAlpha().SetAbsolute( random->RandomInt( 200, 255 ) ); + } + if ( m_EffectState != EFFECT_HOLDING ) + { + // Turn beams off + m_Beams[0].SetVisible( false ); + m_Beams[1].SetVisible( false ); + m_Beams[2].SetVisible( false ); } - */ #endif } @@ -2957,6 +2929,15 @@ void CWeaponPhysCannon::StopEffects( bool stopSound ) #endif // !CLIENT_DLL } +#ifdef CLIENT_DLL +void CWeaponPhysCannon::ThirdPersonSwitch( bool bThirdPerson ) +{ + //Tony; if we switch to first or third person or whatever, destroy and recreate the effects. + //Note: the sound only ever gets shut off on the server, so it's okay - as this is entirely client side. + DestroyEffects(); + StartEffects(); +} +#endif //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- diff --git a/mp/src/game/shared/hl2mp/weapon_rpg.cpp b/mp/src/game/shared/hl2mp/weapon_rpg.cpp index c74b12237..18785d861 100644 --- a/mp/src/game/shared/hl2mp/weapon_rpg.cpp +++ b/mp/src/game/shared/hl2mp/weapon_rpg.cpp @@ -1882,6 +1882,19 @@ void CWeaponRPG::GetWeaponAttachment( int attachmentId, Vector &outVector, Vecto } } +//Tony; added so when the rpg switches to third person, the beam etc is re-created. +void CWeaponRPG::ThirdPersonSwitch( bool bThirdPerson ) +{ + if ( m_pBeam != NULL ) + { + //Tell it to die right away and let the beam code free it. + m_pBeam->brightness = 0.0f; + m_pBeam->flags &= ~FBEAM_FOREVER; + m_pBeam->die = gpGlobals->curtime - 0.1; + m_pBeam = NULL; + } +} + //----------------------------------------------------------------------------- // Purpose: Setup our laser beam //----------------------------------------------------------------------------- @@ -2230,7 +2243,7 @@ int CLaserDot::DrawModel( int flags ) if ( pOwner != NULL && pOwner->IsDormant() == false ) { // Always draw the dot in front of our faces when in first-person - if ( pOwner->IsLocalPlayer() ) + if ( pOwner->IsLocalPlayer() && C_BasePlayer::LocalPlayerInFirstPersonView() ) //Tony; !!! { // Take our view position and orientation vecAttachment = CurrentViewOrigin(); diff --git a/mp/src/game/shared/hl2mp/weapon_rpg.h b/mp/src/game/shared/hl2mp/weapon_rpg.h index bbd6f2dd2..436433b50 100644 --- a/mp/src/game/shared/hl2mp/weapon_rpg.h +++ b/mp/src/game/shared/hl2mp/weapon_rpg.h @@ -238,6 +238,9 @@ public: CMaterialReference m_hBeamMaterial; // Used for the laser beam Beam_t *m_pBeam; // Laser beam temp entity + //Tony; third person check thing, to destroy/reinitialize the beam ( swapping first -> third or back, etc ) + virtual void ThirdPersonSwitch( bool bThirdPerson ); + #endif //CLIENT_DLL CBaseEntity *GetMissile( void ) { return m_hMissile; } diff --git a/mp/src/game/shared/hl2mp/weapon_stunstick.cpp b/mp/src/game/shared/hl2mp/weapon_stunstick.cpp index 9f7069833..ac9bef307 100644 --- a/mp/src/game/shared/hl2mp/weapon_stunstick.cpp +++ b/mp/src/game/shared/hl2mp/weapon_stunstick.cpp @@ -68,7 +68,7 @@ public: virtual void OnDataChanged( DataUpdateType_t updateType ); virtual RenderGroup_t GetRenderGroup( void ); virtual void ViewModelDrawn( C_BaseViewModel *pBaseViewModel ); - + virtual bool IsTransparent( void ); #endif virtual void Precache(); @@ -123,6 +123,9 @@ private: float m_flFadeTime; + //Tony; third person check thing, this has to be done for the local player if third person switches, so we can re-calc attachment points. + virtual void ThirdPersonSwitch( bool bThirdPerson ); + #endif CNetworkVar( bool, m_bActive ); @@ -447,6 +450,10 @@ void CWeaponStunStick::SetStunState( bool state ) bool CWeaponStunStick::Deploy( void ) { SetStunState( true ); +#ifdef CLIENT_DLL + //Tony; we need to just do this + SetupAttachmentPoints(); +#endif return BaseClass::Deploy(); } @@ -842,6 +849,10 @@ void C_WeaponStunStick::DrawFirstPersonEffects( void ) } } +void C_WeaponStunStick::ThirdPersonSwitch( bool bThirdPerson ) +{ + SetupAttachmentPoints(); +} //----------------------------------------------------------------------------- // Purpose: Draw our special effects //----------------------------------------------------------------------------- @@ -872,6 +883,13 @@ void C_WeaponStunStick::ViewModelDrawn( C_BaseViewModel *pBaseViewModel ) BaseClass::ViewModelDrawn( pBaseViewModel ); } +//----------------------------------------------------------------------------- +// Purpose: We are always considered transparent +//----------------------------------------------------------------------------- +bool C_WeaponStunStick::IsTransparent( void ) +{ + return true; +} //----------------------------------------------------------------------------- // Purpose: Draw a cheap glow quad at our impact point (with sparks) //-----------------------------------------------------------------------------