Fixed zombie serverside ragdoll gibs crashing when one of the models isn't valid

This commit is contained in:
Blixibon 2022-05-04 20:52:21 -05:00
parent ad4adf90ca
commit 39ec4ee704

View File

@ -2354,11 +2354,14 @@ void CNPC_BaseZombie::BecomeTorso( const Vector &vecTorsoForce, const Vector &ve
if ( m_bForceServerRagdoll ) if ( m_bForceServerRagdoll )
{ {
pGib = CreateServerRagdollSubmodel( this, GetLegsModel(), GetAbsOrigin() - Vector(0, 0, 40), GetAbsAngles(), COLLISION_GROUP_INTERACTIVE_DEBRIS ); pGib = CreateServerRagdollSubmodel( this, GetLegsModel(), GetAbsOrigin() - Vector(0, 0, 40), GetAbsAngles(), COLLISION_GROUP_INTERACTIVE_DEBRIS );
pGib->VPhysicsGetObject()->AddVelocity( &vecLegsForce, NULL ); if (pGib && pGib->VPhysicsGetObject())
if (flFadeTime > 0.0)
{ {
pGib->SUB_StartFadeOut( flFadeTime, false ); pGib->VPhysicsGetObject()->AddVelocity( &vecLegsForce, NULL );
if (flFadeTime > 0.0)
{
pGib->SUB_StartFadeOut( flFadeTime, false );
}
} }
} }
else else
@ -2506,11 +2509,14 @@ void CNPC_BaseZombie::ReleaseHeadcrab( const Vector &vecOrigin, const Vector &ve
if ( m_bForceServerRagdoll ) if ( m_bForceServerRagdoll )
{ {
pGib = CreateServerRagdollSubmodel( this, GetHeadcrabModel(), vecOrigin, GetLocalAngles(), COLLISION_GROUP_INTERACTIVE_DEBRIS ); pGib = CreateServerRagdollSubmodel( this, GetHeadcrabModel(), vecOrigin, GetLocalAngles(), COLLISION_GROUP_INTERACTIVE_DEBRIS );
pGib->VPhysicsGetObject()->AddVelocity(&vecVelocity, NULL); if (pGib && pGib->VPhysicsGetObject())
if (ShouldIgniteZombieGib()) {
static_cast<CBaseAnimating*>(pGib)->Ignite( random->RandomFloat( 8.0, 12.0 ), false ); pGib->VPhysicsGetObject()->AddVelocity(&vecVelocity, NULL);
if (ShouldIgniteZombieGib())
static_cast<CBaseAnimating*>(pGib)->Ignite( random->RandomFloat( 8.0, 12.0 ), false );
pGib->SUB_StartFadeOut( 15, false ); pGib->SUB_StartFadeOut( 15, false );
}
} }
else else
pGib = CreateRagGib( GetHeadcrabModel(), vecOrigin, GetLocalAngles(), vecVelocity, 15, ShouldIgniteZombieGib() ); pGib = CreateRagGib( GetHeadcrabModel(), vecOrigin, GetLocalAngles(), vecVelocity, 15, ShouldIgniteZombieGib() );