Skip to content

[TF2] Fix Bombinomicon & tf_birthday spawning ragdoll effects incorrectly #1224

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

Open
wants to merge 1 commit 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
93 changes: 53 additions & 40 deletions src/game/client/tf/c_tf_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -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 );
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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() );
}
Expand Down Expand Up @@ -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 )
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
}


Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -1396,7 +1400,6 @@ void C_TFRagdoll::ClientThink( void )
}

C_TFPlayer *pPlayer = GetPlayer();
bool bBombinomicon = ( pPlayer && pPlayer->HasBombinomiconEffectOnDeath() );

if ( !m_bGib )
{
Expand All @@ -1421,22 +1424,22 @@ 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 )
{
m_flTimeToDissolve -= gpGlobals->frametime;
if ( m_flTimeToDissolve <= 0 )
{
if ( bBombinomicon )
if ( m_bBombinomicon )
{
CreateTFGibs( true, true );
CreateTFGibs( true );
}
else
{
Expand All @@ -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;
}
}
Expand All @@ -1482,9 +1485,9 @@ void C_TFRagdoll::ClientThink( void )

if ( pPlayer )
{
if ( bBombinomicon )
if ( m_bBombinomicon )
{
CreateTFGibs( true, true );
CreateTFGibs( true );
}
else
{
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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).
Expand All @@ -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 );
}
Expand Down
5 changes: 3 additions & 2 deletions src/game/client/tf/c_tf_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 &params );

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down