int CNPC_BaseTurret::OnTakeDamage( const CTakeDamageInfo &info ) { int retVal = 0; if (!m_takedamage) return 0; switch( m_lifeState ) { case LIFE_ALIVE: retVal = OnTakeDamage_Alive( info ); if ( m_iHealth <= 0 ) { IPhysicsObject *pPhysics = VPhysicsGetObject(); if ( pPhysics ) { pPhysics->EnableCollisions( false ); } Event_Killed( info ); Event_Dying(); } return retVal; break; case LIFE_DYING: return OnTakeDamage_Dying( info ); default: case LIFE_DEAD: return OnTakeDamage_Dead( info ); } }
int CTripmineGrenade::OnTakeDamage_Alive( const CTakeDamageInfo &info ) { if (gpGlobals->curtime < m_flPowerUp && info.GetDamage() < m_iHealth) { // disable // Create( "weapon_tripmine", GetLocalOrigin() + m_vecDir * 24, GetAngles() ); SetThink( &CTripmineGrenade::SUB_Remove ); SetNextThink( gpGlobals->curtime + 0.1f ); KillBeam(); if (m_pConstraint) m_pConstraint->Deactivate(); return FALSE; } return OnTakeDamage_Alive( info ); }