int CGERocket::OnTakeDamage( const CTakeDamageInfo &inputInfo ) { if ( m_takedamage == DAMAGE_NO ) return 0; // Manually apply vphysics because BaseCombatCharacter takedamage doesn't call back to CBaseEntity OnTakeDamage VPhysicsTakeDamage( inputInfo ); // Rockets take Blast AND Bullet damage, though blast damage requires more. if ((inputInfo.GetDamageType() & DMG_BLAST && inputInfo.GetDamage() > 80) || inputInfo.GetDamageType() & DMG_BULLET) { m_iHealth -= inputInfo.GetDamage(); if (m_iHealth <= 0) { if (inputInfo.GetAttacker()->IsPlayer()) { SetThrower(inputInfo.GetAttacker()->MyCombatCharacterPointer()); } else if (inputInfo.GetAttacker()->IsNPC()) { CNPC_GEBase *npc = (CNPC_GEBase*)inputInfo.GetAttacker(); if (npc->GetBotPlayer()) SetThrower(npc->GetBotPlayer()); } Explode(); } return inputInfo.GetDamage(); } return 0; }
void CStatueProp::Event_Killed( const CTakeDamageInfo &info ) { IPhysicsObject *pPhysics = VPhysicsGetObject(); if ( pPhysics && !pPhysics->IsMoveable() ) { pPhysics->EnableMotion( true ); VPhysicsTakeDamage( info ); } m_nShatterFlags = 0; // If you have some flags to network for the shatter effect, put them here! m_vShatterPosition = info.GetDamagePosition(); m_vShatterForce = info.GetDamageForce(); m_bShatter = true; // Skip over breaking code! //Break( info.GetInflictor(), info ); //BaseClass::Event_Killed( info ); // FIXME: Short delay before we actually remove so that the client statue gets a network update before we need it // This isn't a reliable way to do this and needs to be rethought. AddSolidFlags( FSOLID_NOT_SOLID ); SetNextThink( gpGlobals->curtime + 0.2f ); SetThink( &CBaseEntity::SUB_Remove ); }
int CGEGrenade::OnTakeDamage( const CTakeDamageInfo &inputInfo ) { if ( m_takedamage == DAMAGE_NO ) return 0; // Manually apply vphysics because BaseCombatCharacter takedamage doesn't call back to CBaseEntity OnTakeDamage VPhysicsTakeDamage( inputInfo ); // Grenades take Blast AND Bullet damage if ((inputInfo.GetDamage() > 160 && inputInfo.GetDamageType() & DMG_BLAST) || inputInfo.GetDamageType() & DMG_BULLET) { // Bullet damage transfers ownership to the attacker instead of the thrower m_iHealth -= inputInfo.GetDamage(); if ( m_iHealth <= 0 ) { if ( inputInfo.GetAttacker()->IsPlayer() ) { SetThrower( inputInfo.GetAttacker()->MyCombatCharacterPointer() ); } else if ( inputInfo.GetAttacker()->IsNPC() ) { CNPC_GEBase *npc = (CNPC_GEBase*) inputInfo.GetAttacker(); if ( npc->GetBotPlayer() ) SetThrower( npc->GetBotPlayer() ); } Explode(); } return inputInfo.GetDamage(); } return 0; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int CPhysBox::OnTakeDamage( const CTakeDamageInfo &info ) { // note: if motion is disabled, OnTakeDamage can't apply physics force int ret = BaseClass::OnTakeDamage( info ); // Check our health against the threshold: if( m_damageToEnableMotion > 0 && GetHealth() < m_damageToEnableMotion ) { // only do this once m_damageToEnableMotion = 0; IPhysicsObject *pPhysicsObject = VPhysicsGetObject(); if ( pPhysicsObject != NULL ) { pPhysicsObject->Wake(); pPhysicsObject->EnableMotion( true ); VPhysicsTakeDamage( info ); } } if ( info.GetInflictor() ) { m_OnDamaged.FireOutput( info.GetAttacker(), this ); } return ret; }
//--------------------------------------------------------- //--------------------------------------------------------- int CBounceBomb::OnTakeDamage( const CTakeDamageInfo &info ) { if( m_pConstraint || !VPhysicsGetObject()) { return false; } VPhysicsTakeDamage( info ); return true; }
//----------------------------------------------------------------------------- // Purpose: If we are shot after being stuck to the world, move a bit //----------------------------------------------------------------------------- int CTFGrenadePipebombProjectile::OnTakeDamage( const CTakeDamageInfo &info ) { if ( !info.GetAttacker() ) { Assert( !info.GetAttacker() ); return 0; } bool bSameTeam = ( info.GetAttacker()->GetTeamNumber() == GetTeamNumber() ); if ( m_bTouched && ( info.GetDamageType() & (DMG_BULLET|DMG_BUCKSHOT|DMG_BLAST) ) && bSameTeam == false ) { Vector vecForce = info.GetDamageForce(); if ( info.GetDamageType() & DMG_BULLET ) { vecForce *= tf_grenade_forcefrom_bullet.GetFloat(); } else if ( info.GetDamageType() & DMG_BUCKSHOT ) { vecForce *= tf_grenade_forcefrom_buckshot.GetFloat(); } else if ( info.GetDamageType() & DMG_BLAST ) { vecForce *= tf_grenade_forcefrom_blast.GetFloat(); } // If the force is sufficient, detach & move the pipebomb float flForce = tf_pipebomb_force_to_move.GetFloat(); if ( vecForce.LengthSqr() > (flForce*flForce) ) { if ( VPhysicsGetObject() ) { VPhysicsGetObject()->EnableMotion( true ); } CTakeDamageInfo newInfo = info; newInfo.SetDamageForce( vecForce ); VPhysicsTakeDamage( newInfo ); // The pipebomb will re-stick to the ground after this time expires m_flMinSleepTime = gpGlobals->curtime + tf_grenade_force_sleeptime.GetFloat(); m_bTouched = false; // It has moved the data is no longer valid. m_bUseImpactNormal = false; m_vecImpactNormal.Init(); return 1; } } return 0; }
int CGrenadeFrag::OnTakeDamage( const CTakeDamageInfo &inputInfo ) { // Manually apply vphysics because BaseCombatCharacter takedamage doesn't call back to CBaseEntity OnTakeDamage VPhysicsTakeDamage( inputInfo ); // Grenades only suffer blast damage and burn damage. if( !(inputInfo.GetDamageType() & (DMG_BLAST|DMG_BURN) ) ) return 0; return BaseClass::OnTakeDamage( inputInfo ); }
void CASW_Barrel_Explosive::Event_Killed( const CTakeDamageInfo &info ) { IPhysicsObject *pPhysics = VPhysicsGetObject(); if ( pPhysics && !pPhysics->IsMoveable() ) { pPhysics->EnableMotion( true ); VPhysicsTakeDamage( info ); } QueueForExplode( info ); // Break( info.GetInflictor(), info ); // DoExplosion(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int CPropJetski::OnTakeDamage( const CTakeDamageInfo &info ) { //Do scaled up physic damage to the car CTakeDamageInfo physDmg = info; physDmg.ScaleDamage( 25 ); VPhysicsTakeDamage( physDmg ); //Check to do damage to driver if ( m_hPlayer != NULL ) { //Take no damage from physics damages if ( info.GetDamageType() & DMG_CRUSH ) return 0; //Take the damage m_hPlayer->TakeDamage( info ); } return 0; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int CASW_PropJeep::OnTakeDamage( const CTakeDamageInfo &inputInfo ) { //Do scaled up physics damage to the car CTakeDamageInfo info = inputInfo; info.ScaleDamage( 25 ); // HACKHACK: Scale up grenades until we get a better explosion/pressure damage system if ( inputInfo.GetDamageType() & DMG_BLAST ) { info.SetDamageForce( inputInfo.GetDamageForce() * 10 ); } VPhysicsTakeDamage( info ); // reset the damage info.SetDamage( inputInfo.GetDamage() ); // small amounts of shock damage disrupt the car, but aren't transferred to the player if ( info.GetDamageType() == DMG_SHOCK ) { if ( info.GetDamage() <= 10 ) { // take 10% damage and make the engine stall info.ScaleDamage( 0.1 ); m_throttleDisableTime = gpGlobals->curtime + 2; } } //Check to do damage to driver if ( GetDriver() ) { //Take no damage from physics damages if ( info.GetDamageType() & DMG_CRUSH ) return 0; // Take the damage (strip out the DMG_BLAST) info.SetDamageType( info.GetDamageType() & (~DMG_BLAST) ); GetDriver()->TakeDamage( info ); } return 0; }
void CGEPropDynamic::Event_Killed(const CTakeDamageInfo &info) { // More or less just the kill event copied straight from prop_physics_respawnable, though it does not teleport as it cannot move on its own. IPhysicsObject *pPhysics = VPhysicsGetObject(); if (pPhysics && !pPhysics->IsMoveable()) { pPhysics->EnableMotion(true); VPhysicsTakeDamage(info); } Break(info.GetInflictor(), info); PhysCleanupFrictionSounds(this); VPhysicsDestroyObject(); CBaseEntity::PhysicsRemoveTouchedList(this); CBaseEntity::PhysicsRemoveGroundList(this); DestroyAllDataObjects(); AddEffects(EF_NODRAW); if (IsOnFire() || IsDissolving()) { UTIL_Remove(GetEffectEntity()); } SetContextThink(NULL, 0, "PROP_CLEARFLAGS"); if (m_flRespawnTime > 0) { SetThink(&CGEPropDynamic::Materialize); SetNextThink(gpGlobals->curtime + m_flRespawnTime); } }
//----------------------------------------------------------------------------- // Purpose: // // // Output : //----------------------------------------------------------------------------- int CNPC_Roller::OnTakeDamage_Alive( const CTakeDamageInfo &info ) { return VPhysicsTakeDamage( info ); }