HL2 snippets

From Valve Developer Community
Revision as of 15:57, 20 May 2007 by Lodle (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Remove Head Crab

How to Remove HeadCrab from zombie

in hl2_dll\npc_zombie.cpp look for void CZombie::Spawn( void ) then find this line.

m_fIsHeadless = false;

ans simply change it to read this

m_fIsHeadless = true;

Now open hl2_dll\npc_BaseZombie.cpp and change this section to look like this.

//-----------------------------------------------------------------------------
// Purpose: A zombie has taken damage. Determine whether he release his headcrab.
// Output : YES, IMMEDIATE, or SCHEDULED (see HeadcrabRelease_t)
//-----------------------------------------------------------------------------
HeadcrabRelease_t CNPC_BaseZombie::ShouldReleaseHeadcrab( const CTakeDamageInfo &info, float flDamageThreshold )
{
if ( m_iHealth <= 0 )
{
// If I was killed by a bullet...
if ( info.GetDamageType() & DMG_BULLET )
{
if( m_bHeadShot )
{
if( flDamageThreshold > 0.25 )
{
// Enough force to kill the crab.
//return RELEASE_RAGDOLL;
}
}
else
{
// Killed by a shot to body or something. Crab is ok!
//return RELEASE_IMMEDIATE;
}
}

// If I was killed by an explosion, release the crab.
if ( info.GetDamageType() & DMG_BLAST )
{
//return RELEASE_RAGDOLL;
}

if ( m_fIsTorso && IsChopped( info ) )
{
return RELEASE_RAGDOLL_SLICED_OFF;
}
}

return RELEASE_NO;
}