Skip to content
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

Fix "Fade Corpse" spawnflag on NPCs not applying to serverside ragdolls #299

Open
wants to merge 1 commit into
base: develop
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
21 changes: 15 additions & 6 deletions sp/src/game/server/basecombatcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,15 @@ void CBaseCombatCharacter::FixupBurningServerRagdoll( CBaseEntity *pRagdoll )
}
}

inline bool CBaseCombatCharacter::ShouldFadeServerRagdolls() const
{
#ifdef MAPBASE
return IsNPC() ? HasSpawnFlags( SF_NPC_FADE_CORPSE ) : true;
#else
return true;
#endif
}

bool CBaseCombatCharacter::BecomeRagdollBoogie( CBaseEntity *pKiller, const Vector &forceVector, float duration, int flags )
{
Assert( CanBecomeRagdoll() );
Expand All @@ -1616,7 +1625,7 @@ bool CBaseCombatCharacter::BecomeRagdollBoogie( CBaseEntity *pKiller, const Vect

info.SetDamageForce( forceVector );

CBaseEntity *pRagdoll = CreateServerRagdoll( this, 0, info, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
CBaseEntity *pRagdoll = CreateServerRagdoll( this, 0, info, COLLISION_GROUP_INTERACTIVE_DEBRIS, ShouldFadeServerRagdolls() );

pRagdoll->SetCollisionBounds( CollisionProp()->OBBMins(), CollisionProp()->OBBMaxs() );

Expand All @@ -1639,7 +1648,7 @@ CBaseEntity *CBaseCombatCharacter::BecomeRagdollBoogie( CBaseEntity *pKiller, co

info.SetDamageForce( forceVector );

CBaseEntity *pRagdoll = CreateServerRagdoll( this, 0, info, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
CBaseEntity *pRagdoll = CreateServerRagdoll( this, 0, info, COLLISION_GROUP_INTERACTIVE_DEBRIS, ShouldFadeServerRagdolls() );

pRagdoll->SetCollisionBounds( CollisionProp()->OBBMins(), CollisionProp()->OBBMaxs() );

Expand Down Expand Up @@ -1688,7 +1697,7 @@ bool CBaseCombatCharacter::BecomeRagdoll( const CTakeDamageInfo &info, const Vec
#endif
// in single player create ragdolls on the server when the player hits someone
// with their vehicle - for more dramatic death/collisions
CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, info2, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, info2, COLLISION_GROUP_INTERACTIVE_DEBRIS, ShouldFadeServerRagdolls() );
FixupBurningServerRagdoll( pRagdoll );
RemoveDeferred();
return true;
Expand All @@ -1702,7 +1711,7 @@ bool CBaseCombatCharacter::BecomeRagdoll( const CTakeDamageInfo &info, const Vec
// Burning corpses are server-side in episodic, if we're in darkness mode
if ( IsOnFire() && HL2GameRules()->IsAlyxInDarknessMode() )
{
CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_DEBRIS );
CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_DEBRIS, ShouldFadeServerRagdolls() );
FixupBurningServerRagdoll( pRagdoll );
RemoveDeferred();
return true;
Expand All @@ -1723,7 +1732,7 @@ bool CBaseCombatCharacter::BecomeRagdoll( const CTakeDamageInfo &info, const Vec
return false;

//FIXME: This is fairly leafy to be here, but time is short!
CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_INTERACTIVE_DEBRIS, ShouldFadeServerRagdolls() );
FixupBurningServerRagdoll( pRagdoll );
PhysSetEntityGameFlags( pRagdoll, FVPHYSICS_NO_SELF_COLLISIONS );
RemoveDeferred();
Expand All @@ -1733,7 +1742,7 @@ bool CBaseCombatCharacter::BecomeRagdoll( const CTakeDamageInfo &info, const Vec

if( hl2_episodic.GetBool() && Classify() == CLASS_PLAYER_ALLY_VITAL )
{
CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_INTERACTIVE_DEBRIS, ShouldFadeServerRagdolls() );
RemoveDeferred();
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/server/basecombatcharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ class CBaseCombatCharacter : public CBaseFlex
// A version of BecomeRagdollBoogie() that allows the color to change and returns the entity itself instead.
// In order to avoid breaking anything, it doesn't change the original function.
virtual CBaseEntity *BecomeRagdollBoogie( CBaseEntity *pKiller, const Vector &forceVector, float duration, int flags, const Vector *vecColor );

bool ShouldFadeServerRagdolls() const;
#endif

CBaseEntity *FindHealthItem( const Vector &vecPosition, const Vector &range );
Expand Down
Loading