diff --git a/src/game/client/tf/c_tf_player.cpp b/src/game/client/tf/c_tf_player.cpp index 921236ff9e..bf083067ef 100644 --- a/src/game/client/tf/c_tf_player.cpp +++ b/src/game/client/tf/c_tf_player.cpp @@ -766,7 +766,7 @@ void C_TFRagdoll::CreateTFRagdoll() { // This is the local player, so set them in a default // pose and slam their velocity, angles and origin - SetAbsOrigin( /* m_vecRagdollOrigin : */ pPlayer->GetRenderOrigin() ); + SetAbsOrigin( pPlayer->GetRenderOrigin() ); SetAbsAngles( pPlayer->GetRenderAngles() ); SetAbsVelocity( m_vecRagdollVelocity ); @@ -793,13 +793,13 @@ void C_TFRagdoll::CreateTFRagdoll() { // Overwrite network origin so later interpolation will use this position. SetNetworkOrigin( m_vecRagdollOrigin ); - SetAbsOrigin( m_vecRagdollOrigin ); + SetAbsOrigin( pPlayer->GetRenderOrigin() ); SetAbsVelocity( m_vecRagdollVelocity ); Interp_Reset( GetVarMapping() ); } - if ( IsCloaked() ) + if ( m_bCloaked ) { AddEffects( EF_NOSHADOW ); } @@ -941,7 +941,7 @@ void C_TFRagdoll::CreateTFRagdoll() m_flTimeToDissolve = 0.5f; } - if ( pPlayer->HasBombinomiconEffectOnDeath() && !m_bGib && !m_bDissolving ) + if ( m_bBombinomicon && !m_bGib && !m_bDissolving ) { m_flTimeToDissolve = 1.2f; } @@ -950,7 +950,7 @@ void C_TFRagdoll::CreateTFRagdoll() if ( pPlayer && TFGameRules() && TFGameRules()->IsBirthday() ) { AngularImpulse angularImpulse( RandomFloat( 0.0f, 120.0f ), RandomFloat( 0.0f, 120.0f ), 0.0 ); - breakablepropparams_t breakParams( m_vecRagdollOrigin, GetRenderAngles(), m_vecRagdollVelocity, angularImpulse ); + breakablepropparams_t breakParams( pPlayer->GetRenderOrigin(), GetRenderAngles(), m_vecRagdollVelocity, angularImpulse ); breakParams.impactEnergyScale = 1.0f; pPlayer->DropPartyHat( breakParams, m_vecRagdollVelocity.GetForModify() ); } @@ -1064,12 +1064,12 @@ void C_TFRagdoll::CreateTFHeadGib( void ) { C_TFPlayer *pPlayer = GetPlayer(); - if ( pPlayer && ((pPlayer->m_hFirstGib == NULL) || m_bFeignDeath) ) + if ( pPlayer && pPlayer->m_hFirstGib == NULL ) { Vector vecVelocity = m_vecForce + m_vecRagdollVelocity; VectorNormalize( vecVelocity ); - pPlayer->CreatePlayerGibs( m_vecRagdollOrigin, vecVelocity, m_vecForce.Length(), m_bBurning, false, true ); + pPlayer->CreatePlayerGibs( pPlayer->GetRenderOrigin(), vecVelocity, m_vecForce.Length(), m_bBurning, m_bFeignDeath, false, true ); // Decap Death Camera is disorienting on range Decaps (aka bullets) // Use normal Deathcam if ( m_iDamageCustom == TF_DMG_CUSTOM_HEADSHOT_DECAPITATION ) @@ -1082,29 +1082,31 @@ void C_TFRagdoll::CreateTFHeadGib( void ) //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void C_TFRagdoll::CreateTFGibs( bool bDestroyRagdoll, bool bCurrentPosition ) +void C_TFRagdoll::CreateTFGibs( bool bDestroyRagdoll ) { C_TFPlayer *pPlayer = GetPlayer(); - if ( pPlayer && pPlayer->HasBombinomiconEffectOnDeath() ) + if ( pPlayer ) { - m_vecForce *= 2.0f; - m_vecForce.z *= 3.0f; - - DispatchParticleEffect( TFGameRules()->IsHolidayActive( kHoliday_Halloween ) ? "bombinomicon_burningdebris_halloween" : "bombinomicon_burningdebris", - bCurrentPosition ? GetAbsOrigin() : m_vecRagdollOrigin, GetAbsAngles() ); - EmitSound( "Bombinomicon.Explode" ); - } + Vector vecOrigin = m_bGib ? pPlayer->GetRenderOrigin() : GetRenderOrigin(); - if ( pPlayer && ((pPlayer->m_hFirstGib == NULL) || m_bFeignDeath) ) - { - Vector vecVelocity = m_vecForce + m_vecRagdollVelocity; - VectorNormalize( vecVelocity ); - pPlayer->CreatePlayerGibs( bCurrentPosition ? pPlayer->GetRenderOrigin() : m_vecRagdollOrigin, vecVelocity, m_vecForce.Length(), m_bBurning ); - } + if ( m_bBombinomicon ) + { + m_vecForce *= 2.0f; + m_vecForce.z *= 3.0f; - if ( pPlayer ) - { + DispatchParticleEffect( TFGameRules()->IsHolidayActive( kHoliday_Halloween ) ? "bombinomicon_burningdebris_halloween" : "bombinomicon_burningdebris", + vecOrigin, GetAbsAngles()); + EmitSound("Bombinomicon.Explode"); + } + + if ( pPlayer->m_hFirstGib == NULL ) + { + Vector vecVelocity = m_vecForce + m_vecRagdollVelocity; + VectorNormalize( vecVelocity ); + pPlayer->CreatePlayerGibs( vecOrigin, vecVelocity, m_vecForce.Length(), m_bBurning, m_bFeignDeath ); + } + if ( TFGameRules() && TFGameRules()->IsBirthdayOrPyroVision() ) { DispatchParticleEffect( "bday_confetti", pPlayer->GetAbsOrigin() + Vector(0,0,32), vec3_angle ); @@ -1143,7 +1145,7 @@ void C_TFRagdoll::CreateWearableGibs( bool bDisguiseWearables ) Vector vecVelocity = m_vecForce + m_vecRagdollVelocity; VectorNormalize( vecVelocity ); - pPlayer->CreatePlayerGibs( m_vecRagdollOrigin, vecVelocity, m_vecForce.Length(), m_bBurning, true, false, bDisguiseWearables ); + pPlayer->CreatePlayerGibs( pPlayer->GetRenderOrigin(), vecVelocity, m_vecForce.Length(), m_bBurning, m_bFeignDeath, true, false, bDisguiseWearables ); } @@ -1229,6 +1231,8 @@ void C_TFRagdoll::OnDataChanged( DataUpdateType_t type ) if ( bCreateRagdoll ) { + m_bBombinomicon = !m_bCloaked && pPlayer->HasBombinomiconEffectOnDeath(); + if ( m_bGib ) { CreateTFGibs( !m_bDissolving ); @@ -1396,7 +1400,6 @@ void C_TFRagdoll::ClientThink( void ) } C_TFPlayer *pPlayer = GetPlayer(); - bool bBombinomicon = ( pPlayer && pPlayer->HasBombinomiconEffectOnDeath() ); if ( !m_bGib ) { @@ -1421,12 +1424,12 @@ void C_TFRagdoll::ClientThink( void ) } } } - else if ( bBombinomicon && ( GetFlags() & FL_DISSOLVING ) ) + else if ( m_bBombinomicon && ( GetFlags() & FL_DISSOLVING ) ) { m_flTimeToDissolve -= gpGlobals->frametime; if ( m_flTimeToDissolve <= 0 ) { - CreateTFGibs( true, true ); + CreateTFGibs( true ); } } else if ( m_bBecomeAsh ) @@ -1434,9 +1437,9 @@ void C_TFRagdoll::ClientThink( void ) m_flTimeToDissolve -= gpGlobals->frametime; if ( m_flTimeToDissolve <= 0 ) { - if ( bBombinomicon ) + if ( m_bBombinomicon ) { - CreateTFGibs( true, true ); + CreateTFGibs( true ); } else { @@ -1460,12 +1463,12 @@ void C_TFRagdoll::ClientThink( void ) return; } } - else if ( bBombinomicon ) + else if ( m_bBombinomicon ) { m_flTimeToDissolve -= gpGlobals->frametime; if ( m_flTimeToDissolve <= 0 ) { - CreateTFGibs( true, true ); + CreateTFGibs( true ); return; } } @@ -1482,9 +1485,9 @@ void C_TFRagdoll::ClientThink( void ) if ( pPlayer ) { - if ( bBombinomicon ) + if ( m_bBombinomicon ) { - CreateTFGibs( true, true ); + CreateTFGibs( true ); } else { @@ -7317,7 +7320,7 @@ void C_TFPlayer::CheckAndUpdateGibType( void ) // &vecVelocity - // &vecImpactVelocity - //----------------------------------------------------------------------------- -void C_TFPlayer::CreatePlayerGibs( const Vector &vecOrigin, const Vector &vecVelocity, float flImpactScale, bool bBurning, bool bWearableGibs, bool bOnlyHead, bool bDisguiseGibs ) +void C_TFPlayer::CreatePlayerGibs( const Vector &vecOrigin, const Vector &vecVelocity, float flImpactScale, bool bBurning, bool bFeignDeath, bool bWearableGibs, bool bOnlyHead, bool bDisguiseGibs ) { // Make sure we have Gibs to create. if ( m_aGibs.Count() == 0 ) @@ -7382,11 +7385,16 @@ void C_TFPlayer::CreatePlayerGibs( const Vector &vecOrigin, const Vector &vecVel } } - m_hFirstGib = CreateGibsFromList( headGib, nModelIndex, NULL, breakParams, this, -1 , false, true, &m_hSpawnedGibs, bBurning ); - m_hHeadGib = m_hFirstGib; - if ( m_hFirstGib ) + EHANDLE hGib = CreateGibsFromList( headGib, nModelIndex, NULL, breakParams, this, -1, false, true, &m_hSpawnedGibs, bBurning ); + if ( !bFeignDeath ) { - IPhysicsObject *pPhysicsObject = m_hFirstGib->VPhysicsGetObject(); + m_hFirstGib = hGib; + m_hHeadGib = hGib; + } + + if ( hGib ) + { + IPhysicsObject *pPhysicsObject = hGib->VPhysicsGetObject(); if( pPhysicsObject ) { // Give the head some rotational damping so it doesn't roll so much (for the player's view). @@ -7400,7 +7408,12 @@ void C_TFPlayer::CreatePlayerGibs( const Vector &vecOrigin, const Vector &vecVel else { CheckAndUpdateGibType(); - m_hFirstGib = CreateGibsFromList( m_aGibs, nModelIndex, NULL, breakParams, this, -1 , false, true, &m_hSpawnedGibs, bBurning ); + + EHANDLE hGib = CreateGibsFromList( m_aGibs, nModelIndex, NULL, breakParams, this, -1, false, true, &m_hSpawnedGibs, bBurning ); + if ( !bFeignDeath ) + { + m_hFirstGib = hGib; + } } DropPartyHat( breakParams, vecBreakVelocity ); } diff --git a/src/game/client/tf/c_tf_player.h b/src/game/client/tf/c_tf_player.h index 0fcee37308..4482cc45cf 100644 --- a/src/game/client/tf/c_tf_player.h +++ b/src/game/client/tf/c_tf_player.h @@ -198,7 +198,7 @@ class C_TFPlayer : public C_BasePlayer, public IHasAttributes, public IInventory // Gibs. void InitPlayerGibs( void ); void CheckAndUpdateGibType( void ); - void CreatePlayerGibs( const Vector &vecOrigin, const Vector &vecVelocity, float flImpactScale, bool bBurning, bool bWearableGibs=false, bool bOnlyHead=false, bool bDisguiseGibs=false ); + void CreatePlayerGibs( const Vector &vecOrigin, const Vector &vecVelocity, float flImpactScale, bool bBurning, bool bFeignDeath=false, bool bWearableGibs=false, bool bOnlyHead=false, bool bDisguiseGibs=false ); void DropPartyHat( breakablepropparams_t &breakParams, Vector &vecBreakVelocity ); void DropWearable( C_TFWearable *pItem, const breakablepropparams_t ¶ms ); @@ -1073,7 +1073,7 @@ class C_TFRagdoll : public C_BaseFlex void Interp_Copy( C_BaseAnimatingOverlay *pSourceEntity ); void CreateTFRagdoll(); - void CreateTFGibs( bool bDestroyRagdoll = true, bool bCurrentPosition = false ); + void CreateTFGibs( bool bDestroyRagdoll = true ); void CreateWearableGibs( bool bDisguiseWearables ); void CreateTFHeadGib(); @@ -1117,6 +1117,7 @@ class C_TFRagdoll : public C_BaseFlex float m_flPercentInvisible; float m_flTimeToDissolve; bool m_bCritOnHardHit; // plays the red mist particle effect + bool m_bBombinomicon; float m_flHeadScale; float m_flTorsoScale; float m_flHandScale;