Skip to content

Commit 4e3f58f

Browse files
authored
Merge pull request #272 from Blixibon/mapbase/feature/zombie-serverside-headcrab-ragdoll-fixes
Fix serverside zombie headcrab ragdoll not using correct origin
2 parents 4c2823e + 06b27ac commit 4e3f58f

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

sp/src/game/server/hl2/npc_BaseZombie.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,9 +2468,15 @@ bool CNPC_BaseZombie::ShouldPlayFootstepMoan( void )
24682468
#define CRAB_HULL_EXPAND 1.1f
24692469
//-----------------------------------------------------------------------------
24702470
//-----------------------------------------------------------------------------
2471-
bool CNPC_BaseZombie::HeadcrabFits( CBaseAnimating *pCrab )
2471+
bool CNPC_BaseZombie::HeadcrabFits( CBaseAnimating *pCrab, const Vector *vecOrigin )
24722472
{
2473-
Vector vecSpawnLoc = pCrab->GetAbsOrigin();
2473+
Vector vecSpawnLoc;
2474+
#ifdef MAPBASE
2475+
if (vecOrigin)
2476+
vecSpawnLoc = *vecOrigin;
2477+
else
2478+
#endif
2479+
vecSpawnLoc = pCrab->GetAbsOrigin();
24742480

24752481
CTraceFilterSimpleList traceFilter( COLLISION_GROUP_NONE );
24762482
traceFilter.AddEntityToIgnore( pCrab );
@@ -2553,7 +2559,12 @@ void CNPC_BaseZombie::ReleaseHeadcrab( const Vector &vecOrigin, const Vector &ve
25532559
SetHeadcrabSpawnLocation( iCrabAttachment, pAnimatingGib );
25542560
}
25552561

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

25712582
if( UTIL_ShouldShowBlood(BLOOD_COLOR_YELLOW) )
25722583
{
2573-
UTIL_BloodImpact( pGib->WorldSpaceCenter(), Vector(0,0,1), BLOOD_COLOR_YELLOW, 1 );
2584+
Vector vecGibCenter;
2585+
#ifdef MAPBASE
2586+
// Server ragdolls don't have a valid origin on spawn, so we have to use the origin originally passed
2587+
if (m_bForceServerRagdoll)
2588+
vecGibCenter = vecOrigin;
2589+
else
2590+
#endif
2591+
vecGibCenter = pGib->WorldSpaceCenter();
2592+
2593+
UTIL_BloodImpact( vecGibCenter, Vector(0,0,1), BLOOD_COLOR_YELLOW, 1 );
25742594

25752595
for ( int i = 0 ; i < 3 ; i++ )
25762596
{
2577-
Vector vecSpot = pGib->WorldSpaceCenter();
2597+
Vector vecSpot = vecGibCenter;
25782598

25792599
vecSpot.x += random->RandomFloat( -8, 8 );
25802600
vecSpot.y += random->RandomFloat( -8, 8 );

sp/src/game/server/hl2/npc_BaseZombie.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ abstract_class CNPC_BaseZombie : public CAI_BaseZombieBase
189189
virtual void SetModel( const char *szModelName );
190190
virtual void BecomeTorso( const Vector &vecTorsoForce, const Vector &vecLegsForce );
191191
virtual bool CanBecomeLiveTorso() { return false; }
192-
virtual bool HeadcrabFits( CBaseAnimating *pCrab );
192+
virtual bool HeadcrabFits( CBaseAnimating *pCrab, const Vector *vecOrigin = NULL );
193193
void ReleaseHeadcrab( const Vector &vecOrigin, const Vector &vecVelocity, bool fRemoveHead, bool fRagdollBody, bool fRagdollCrab = false );
194194
void SetHeadcrabSpawnLocation( int iCrabAttachment, CBaseAnimating *pCrab );
195195

0 commit comments

Comments
 (0)