Skip to content

Commit

Permalink
Merge pull request entropy-zero#272 from Blixibon/mapbase/feature/zom…
Browse files Browse the repository at this point in the history
…bie-serverside-headcrab-ragdoll-fixes

Fix serverside zombie headcrab ragdoll not using correct origin
  • Loading branch information
Blixibon authored Feb 4, 2024
2 parents 4c2823e + 06b27ac commit 4e3f58f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
28 changes: 24 additions & 4 deletions sp/src/game/server/hl2/npc_BaseZombie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2468,9 +2468,15 @@ bool CNPC_BaseZombie::ShouldPlayFootstepMoan( void )
#define CRAB_HULL_EXPAND 1.1f
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CNPC_BaseZombie::HeadcrabFits( CBaseAnimating *pCrab )
bool CNPC_BaseZombie::HeadcrabFits( CBaseAnimating *pCrab, const Vector *vecOrigin )
{
Vector vecSpawnLoc = pCrab->GetAbsOrigin();
Vector vecSpawnLoc;
#ifdef MAPBASE
if (vecOrigin)
vecSpawnLoc = *vecOrigin;
else
#endif
vecSpawnLoc = pCrab->GetAbsOrigin();

CTraceFilterSimpleList traceFilter( COLLISION_GROUP_NONE );
traceFilter.AddEntityToIgnore( pCrab );
Expand Down Expand Up @@ -2553,7 +2559,12 @@ void CNPC_BaseZombie::ReleaseHeadcrab( const Vector &vecOrigin, const Vector &ve
SetHeadcrabSpawnLocation( iCrabAttachment, pAnimatingGib );
}

#ifdef MAPBASE
// Server ragdolls don't have a valid origin on spawn, so we have to use the origin originally passed
if( !HeadcrabFits( pAnimatingGib, m_bForceServerRagdoll ? &vecOrigin : NULL ) )
#else
if( !HeadcrabFits(pAnimatingGib) )
#endif
{
UTIL_Remove(pGib);
return;
Expand All @@ -2570,11 +2581,20 @@ void CNPC_BaseZombie::ReleaseHeadcrab( const Vector &vecOrigin, const Vector &ve

if( UTIL_ShouldShowBlood(BLOOD_COLOR_YELLOW) )
{
UTIL_BloodImpact( pGib->WorldSpaceCenter(), Vector(0,0,1), BLOOD_COLOR_YELLOW, 1 );
Vector vecGibCenter;
#ifdef MAPBASE
// Server ragdolls don't have a valid origin on spawn, so we have to use the origin originally passed
if (m_bForceServerRagdoll)
vecGibCenter = vecOrigin;
else
#endif
vecGibCenter = pGib->WorldSpaceCenter();

UTIL_BloodImpact( vecGibCenter, Vector(0,0,1), BLOOD_COLOR_YELLOW, 1 );

for ( int i = 0 ; i < 3 ; i++ )
{
Vector vecSpot = pGib->WorldSpaceCenter();
Vector vecSpot = vecGibCenter;

vecSpot.x += random->RandomFloat( -8, 8 );
vecSpot.y += random->RandomFloat( -8, 8 );
Expand Down
2 changes: 1 addition & 1 deletion sp/src/game/server/hl2/npc_BaseZombie.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ abstract_class CNPC_BaseZombie : public CAI_BaseZombieBase
virtual void SetModel( const char *szModelName );
virtual void BecomeTorso( const Vector &vecTorsoForce, const Vector &vecLegsForce );
virtual bool CanBecomeLiveTorso() { return false; }
virtual bool HeadcrabFits( CBaseAnimating *pCrab );
virtual bool HeadcrabFits( CBaseAnimating *pCrab, const Vector *vecOrigin = NULL );
void ReleaseHeadcrab( const Vector &vecOrigin, const Vector &vecVelocity, bool fRemoveHead, bool fRagdollBody, bool fRagdollCrab = false );
void SetHeadcrabSpawnLocation( int iCrabAttachment, CBaseAnimating *pCrab );

Expand Down

0 comments on commit 4e3f58f

Please sign in to comment.