//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponCombatLaserRifle::PrimaryAttack( void ) { CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner(); if (!pPlayer) return; WeaponSound(SINGLE); // Fire the bullets Vector vecSrc = pPlayer->Weapon_ShootPosition( ); Vector vecAiming; pPlayer->EyeVectors( &vecAiming ); PlayAttackAnimation( GetPrimaryAttackActivity() ); // Reduce the spread if the player's ducking Vector vecSpread = GetBulletSpread(); vecSpread *= m_flInaccuracy; TFGameRules()->FireBullets( CTakeDamageInfo( this, pPlayer, weapon_combat_laserrifle_damage.GetFloat(), DMG_PLASMA), 1, vecSrc, vecAiming, vecSpread, weapon_combat_laserrifle_range.GetFloat(), m_iPrimaryAmmoType, 0, entindex(), 0 ); m_flInaccuracy += 0.3; m_flInaccuracy = clamp(m_flInaccuracy, 0, 1); m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate(); m_iClip1 = m_iClip1 - 1; }
//----------------------------------------------------------------------------- // Purpose: // Input : index - // *pEvent - //----------------------------------------------------------------------------- void CGrubNugget::VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ) { int damageType; float damage = CalculateDefaultPhysicsDamage( index, pEvent, 1.0f, true, damageType ); if ( damage > 5.0f ) { CBaseEntity *pHitEntity = pEvent->pEntities[!index]; if ( pHitEntity == NULL ) { // hit world pHitEntity = GetContainingEntity( INDEXENT(0) ); } Vector damagePos; pEvent->pInternalData->GetContactPoint( damagePos ); Vector damageForce = pEvent->postVelocity[index] * pEvent->pObjects[index]->GetMass(); if ( damageForce == vec3_origin ) { // This can happen if this entity is motion disabled, and can't move. // Use the velocity of the entity that hit us instead. damageForce = pEvent->postVelocity[!index] * pEvent->pObjects[!index]->GetMass(); } // FIXME: this doesn't pass in who is responsible if some other entity "caused" this collision PhysCallbackDamage( this, CTakeDamageInfo( pHitEntity, pHitEntity, damageForce, damagePos, damage, damageType ), *pEvent, index ); } BaseClass::VPhysicsCollision( index, pEvent ); }
//----------------------------------------------------------------------------- // Purpose: An entity has blocked the brush. // Input : pOther - //----------------------------------------------------------------------------- void CFuncRotating::Blocked( CBaseEntity *pOther ) { #ifdef HL1_DLL if( m_flBlockDamage > 0 ) #endif pOther->TakeDamage( CTakeDamageInfo( this, this, m_flBlockDamage, DMG_CRUSH ) ); }
void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) { if( pOther->pev->takedamage ) { TraceResult tr = UTIL_GetGlobalTrace(); CBaseEntity* pOwner; if( m_hOwner != nullptr ) { pOwner = m_hOwner; } else { pOwner = this; } g_MultiDamage.Clear(); pOther->TraceAttack( CTakeDamageInfo( pOwner, gSkillData.GetControllerDmgBall(), DMG_ENERGYBEAM ), pev->velocity.Normalize(), &tr ); g_MultiDamage.ApplyMultiDamage( pOwner, pOwner ); UTIL_EmitAmbientSound( this, tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) ); } UTIL_Remove( this ); }
void CGrenadeSpit::GrenadeSpitTouch( CBaseEntity *pOther ) { if (m_fSpitDeathTime != 0) { return; } if ( pOther->GetCollisionGroup() == HL2COLLISION_GROUP_SPIT) { return; } if ( !pOther->m_takedamage ) { // make a splat on the wall trace_t tr; UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + GetAbsVelocity() * 10, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); UTIL_DecalTrace(&tr, "BeerSplash" ); // make some flecks // CPVSFilter filter( tr.endpos ); //te->SpriteSpray( filter, 0.0, // tr.endpos, tr.plane.normal, m_nSquidSpitSprite, 30, 0.8, 5 ); } else { RadiusDamage ( CTakeDamageInfo( this, GetThrower(), m_flDamage, DMG_BLAST ), GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL ); } Detonate(); }
//------------------------------------------------------------------------------ // Purpose: Implement impact function //------------------------------------------------------------------------------ void CWeaponCrowbar::Hit( void ) { //Make sound for the AI #ifndef CLIENT_DLL CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); CSoundEnt::InsertSound( SOUND_BULLET_IMPACT, m_traceHit.endpos, 400, 0.2f, pPlayer ); CBaseEntity *pHitEntity = m_traceHit.m_pEnt; //Apply damage to a hit target if ( pHitEntity != NULL ) { Vector hitDirection; pPlayer->EyeVectors( &hitDirection, NULL, NULL ); VectorNormalize( hitDirection ); ClearMultiDamage(); CTakeDamageInfo info( GetOwner(), GetOwner(), sk_plr_dmg_crowbar.GetFloat(), DMG_CLUB ); CalculateMeleeDamageForce( &info, hitDirection, m_traceHit.endpos ); pHitEntity->DispatchTraceAttack( info, hitDirection, &m_traceHit ); ApplyMultiDamage(); // Now hit all triggers along the ray that... TraceAttackToTriggers( CTakeDamageInfo( GetOwner(), GetOwner(), sk_plr_dmg_crowbar.GetFloat(), DMG_CLUB ), m_traceHit.startpos, m_traceHit.endpos, hitDirection ); //Play an impact sound ImpactSound( pHitEntity ); } #endif //Apply an impact effect ImpactEffect(); }
void CASW_Boomer_Blob::DoExplosion( ) { // scorch the ground trace_t tr; UTIL_TraceLine ( GetAbsOrigin(), GetAbsOrigin() + Vector( 0, 0, -80 ), MASK_SHOT, this, COLLISION_GROUP_NONE, &tr); if ( m_bMaster ) { if ( ( tr.m_pEnt != GetWorldEntity() ) || ( tr.hitbox != 0 ) ) { // non-world needs smaller decals if( tr.m_pEnt && !tr.m_pEnt->IsNPC() ) { UTIL_DecalTrace( &tr, "SmallScorch" ); } } else { UTIL_DecalTrace( &tr, "Scorch" ); } UTIL_ASW_ScreenShake( GetAbsOrigin(), 7.0f, 45.0f, 0.5f, 150, SHAKE_START ); } // explosion effects DispatchParticleEffect( "boomer_drop_explosion", GetAbsOrigin(), Vector( m_DmgRadius, 0.0f, 0.0f ), QAngle( 0.0f, 0.0f, 0.0f ) ); EmitSound( "ASW_Boomer_Grenade.Explode" ); // damage to nearby things ASWGameRules()->RadiusDamage( CTakeDamageInfo( this, m_hFirer.Get(), m_flDamage, DMG_BLAST ), GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CGrenadeRocket::MissileTouch( CBaseEntity *pOther ) { Assert( pOther ); if ( !pOther->IsSolid() ) return; Vector vecAbsOrigin = GetAbsOrigin(); CPASFilter filter( vecAbsOrigin ); te->Explosion( filter, 0.0, &vecAbsOrigin, g_sModelIndexFireball, 2.0, 15, TE_EXPLFLAG_NONE, 100, m_flDamage ); StopSound( "GrenadeRocket.FlyLoop" ); // Don't apply explosive damage if it hit a shield of any kind... bool bHittingShield = false; if (pOther->GetCollisionGroup() == TFCOLLISION_GROUP_SHIELD) { bHittingShield = true; } else if ( pOther->IsPlayer() ) { CBaseTFPlayer *pPlayer = static_cast<CBaseTFPlayer*>(pOther); trace_t tr; float flDamage = m_flDamage; bHittingShield = pPlayer->IsHittingShield( GetAbsVelocity(), &flDamage ); } if (!bHittingShield) { RadiusDamage( CTakeDamageInfo( this, m_pRealOwner, m_flDamage, DMG_BLAST ), vecAbsOrigin, 100, CLASS_NONE ); } UTIL_Remove( this ); }
//----------------------------------------------------------------------------- // Purpose: // Input : *pOther - //----------------------------------------------------------------------------- void CFlare::FlareBurnTouch( CBaseEntity *pOther ) { if ( pOther && pOther->m_takedamage && ( m_flNextDamage < gpGlobals->curtime ) ) { pOther->TakeDamage( CTakeDamageInfo( this, m_pOwner, 1, (DMG_BULLET|DMG_BURN) ) ); m_flNextDamage = gpGlobals->curtime + 1.0f; } }
//----------------------------------------------------------------------------- // Purpose: Called every frame when the bruch is blocked while moving // Input : pOther - The blocking entity. //----------------------------------------------------------------------------- void CFuncMoveLinear::Blocked( CBaseEntity *pOther ) { // Hurt the blocker if ( m_flBlockDamage ) { pOther->TakeDamage( CTakeDamageInfo( this, this, m_flBlockDamage, DMG_CRUSH ) ); } }
static int luasrc_CTakeDamageInfo (lua_State *L) { if (lua_gettop(L) < 4) { CTakeDamageInfo info = CTakeDamageInfo(); lua_pushdamageinfo(L, info); } else if (lua_gettop(L) <= 5) { CTakeDamageInfo info = CTakeDamageInfo(luaL_checkentity(L, 1), luaL_checkentity(L, 2), luaL_checknumber(L, 3), luaL_checkint(L, 4), luaL_optint(L, 5, 0)); lua_pushdamageinfo(L, info); } else if (lua_gettop(L) <= 6) { CTakeDamageInfo info = CTakeDamageInfo(luaL_checkentity(L, 1), luaL_checkentity(L, 2), luaL_checkentity(L, 3), luaL_checknumber(L, 4), luaL_checkint(L, 5), luaL_optint(L, 6, 0)); lua_pushdamageinfo(L, info); } else if (lua_gettop(L) < 9) { CTakeDamageInfo info = CTakeDamageInfo(luaL_checkentity(L, 1), luaL_checkentity(L, 2), luaL_checkvector(L, 3), luaL_checkvector(L, 4), luaL_checknumber(L, 5), luaL_checkint(L, 6), luaL_optint(L, 7, 0), &luaL_optvector(L, 8, NULL)); lua_pushdamageinfo(L, info); } else { CTakeDamageInfo info = CTakeDamageInfo(luaL_checkentity(L, 1), luaL_checkentity(L, 2), luaL_checkentity(L, 3), luaL_checkvector(L, 4), luaL_checkvector(L, 5), luaL_checknumber(L, 6), luaL_checkint(L, 7), luaL_optint(L, 8, 0), &luaL_optvector(L, 9, NULL)); lua_pushdamageinfo(L, info); } return 1; }
void CTripmineGrenade::BeamBreakThink( void ) { // See if I can go solid yet (has dropper moved out of way?) if (IsSolidFlagSet( FSOLID_NOT_SOLID )) { trace_t tr; Vector vUpBit = GetAbsOrigin(); vUpBit.z += 5.0; UTIL_TraceEntity( this, GetAbsOrigin(), vUpBit, MASK_SHOT, &tr ); if ( !tr.startsolid && (tr.fraction == 1.0) ) { RemoveSolidFlags( FSOLID_NOT_SOLID ); } } trace_t tr; // NOT MASK_SHOT because we want only simple hit boxes UTIL_TraceLine( GetAbsOrigin(), m_vecEnd, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); // ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength ); // respawn detect. if ( !m_pBeam ) { MakeBeam( ); if ( tr.m_pEnt ) m_hOwner = tr.m_pEnt; // reset owner too } CBaseEntity *pEntity = tr.m_pEnt; CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity ); bool bAttachMoved = false; if ( m_bAttached && m_hAttachEntity.Get() != NULL ) { if ( m_hAttachEntity.Get()->GetAbsOrigin() != m_vAttachedPosition ) bAttachMoved = true; } // Also blow up if the attached entity goes away, ie: a crate if (pBCC || fabs( m_flBeamLength - tr.fraction ) > 0.001 || ( m_bAttached && m_hAttachEntity.Get() == NULL) || bAttachMoved ) { m_iHealth = 0; if (m_pConstraint) m_pConstraint->Deactivate(); Event_Killed( CTakeDamageInfo( (CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL ) ); return; } SetNextThink( gpGlobals->curtime + 0.05f ); }
//----------------------------------------------------------------------------- // Purpose: Explode and die //----------------------------------------------------------------------------- void CBasePlasmaProjectile::Detonate( void ) { #if !defined( CLIENT_DLL ) // Should I explode? if ( m_flExplosiveRadius ) { RadiusDamage( CTakeDamageInfo( this, GetOwnerEntity(), m_flDamage, m_DamageType | DMG_BLAST ), GetAbsOrigin(), m_flExplosiveRadius, CLASS_NONE, NULL ); } #endif Remove( ); }
void CShockBeam::BallTouch( CBaseEntity* pOther ) { if( pOther->GetTakeDamageMode() != DAMAGE_NO ) { TraceResult tr = UTIL_GetGlobalTrace(); CBaseEntity* pOwner = GetOwner(); g_MultiDamage.Clear(); int bitsDamageTypes = DMG_ALWAYSGIB | DMG_SHOCK; if( CBaseMonster* pMonster = pOther->MyMonsterPointer() ) { bitsDamageTypes = 64; if( pMonster->m_flShockDuration > 1.0 ) { bitsDamageTypes = 8192; } pMonster->AddShockEffect( 63, 152, 208, 16, 0.5 ); } pOther->TraceAttack( CTakeDamageInfo( pOwner, bIsMultiplayer() ? gSkillData.GetPlrDmgShockRoachM() : gSkillData.GetPlrDmgShockRoachS(), bitsDamageTypes ), GetAbsVelocity().Normalize(), &tr ); g_MultiDamage.ApplyMultiDamage( this, pOwner ); SetAbsVelocity( g_vecZero ); } SetThink( &CShockBeam::ExplodeThink ); SetNextThink( gpGlobals->time + 0.01 ); if( pOther->GetTakeDamageMode() == DAMAGE_NO ) { TraceResult tr; UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + GetAbsVelocity() * 10, dont_ignore_monsters, edict(), &tr ); UTIL_DecalTrace( &tr, DECAL_OFSCORCH1 + UTIL_RandomLong( 0, 2 ) ); MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, GetAbsOrigin() ); WRITE_BYTE( TE_SPARKS ); WRITE_COORD_VECTOR( GetAbsOrigin() ); MESSAGE_END(); } }
void CGrenadeAR2::Detonate(void) { if (!m_bIsLive) { return; } m_bIsLive = false; m_takedamage = DAMAGE_NO; if(m_hSmokeTrail) { UTIL_Remove(m_hSmokeTrail); m_hSmokeTrail = NULL; } CPASFilter filter( GetAbsOrigin() ); te->Explosion( filter, 0.0, &GetAbsOrigin(), g_sModelIndexFireball, 2.0, 15, TE_EXPLFLAG_NONE, m_DmgRadius, m_flDamage ); Vector vecForward = GetAbsVelocity(); VectorNormalize(vecForward); trace_t tr; UTIL_TraceLine ( GetAbsOrigin(), GetAbsOrigin() + 60*vecForward, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr); if ((tr.m_pEnt != GetWorldEntity()) || (tr.hitbox != 0)) { // non-world needs smaller decals if( tr.m_pEnt && !tr.m_pEnt->IsNPC() ) { UTIL_DecalTrace( &tr, "SmallScorch" ); } } else { UTIL_DecalTrace( &tr, "Scorch" ); } UTIL_ScreenShake( GetAbsOrigin(), 25.0, 150.0, 1.0, 750, SHAKE_START ); RadiusDamage ( CTakeDamageInfo( this, GetThrower(), m_flDamage, DMG_BLAST ), GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL ); UTIL_Remove( this ); }
void CGrenadeMP5::Detonate(void) { if (!m_bIsLive) { return; } m_bIsLive = false; m_takedamage = DAMAGE_NO; CPASFilter filter( GetAbsOrigin() ); te->Explosion( filter, 0.0, &GetAbsOrigin(), GetWaterLevel() == 0 ? g_sModelIndexFireball : g_sModelIndexWExplosion, (m_flDamage - 50) * .60, 15, TE_EXPLFLAG_NONE, m_DmgRadius, m_flDamage ); trace_t tr; tr = CBaseEntity::GetTouchTrace(); if ( (tr.m_pEnt != GetWorldEntity()) || (tr.hitbox != 0) ) { // non-world needs smaller decals UTIL_DecalTrace( &tr, "SmallScorch"); } else { UTIL_DecalTrace( &tr, "Scorch" ); } CSoundEnt::InsertSound ( SOUND_COMBAT, GetAbsOrigin(), BASEGRENADE_EXPLOSION_VOLUME, 3.0 ); RadiusDamage ( CTakeDamageInfo( this, GetThrower(), m_flDamage, DMG_BLAST ), GetAbsOrigin(), m_flDamage * 2.5, CLASS_NONE, NULL ); CPASAttenuationFilter filter2( this ); EmitSound( filter2, entindex(), "GrenadeMP5.Detonate" ); if ( GetWaterLevel() == 0 ) { int sparkCount = random->RandomInt( 0,3 ); QAngle angles; VectorAngles( tr.plane.normal, angles ); for ( int i = 0; i < sparkCount; i++ ) Create( "spark_shower", GetAbsOrigin(), angles, NULL ); } UTIL_Remove( this ); }
void CShockBeam::WaterExplodeThink() { CBaseEntity* pOwner = GetOwner(); Explode(); ::RadiusDamage( GetAbsOrigin(), CTakeDamageInfo( this, pOwner, 100.0, DMG_ALWAYSGIB | DMG_BLAST ), 150.0, 0 ); UTIL_Remove( this ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::IncreaseCharge() { if ( m_flNextChargeTime > gpGlobals->curtime ) return; CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; //Check our charge time if ( ( gpGlobals->curtime - m_flChargeStartTime ) > MAX_GAUSS_CHARGE_TIME ) { //Notify the player they're at maximum charge if ( m_bChargeIndicated == false ) { WeaponSound( SPECIAL2 ); m_bChargeIndicated = true; } #ifndef CLIENT_DLL if ( ( gpGlobals->curtime - m_flChargeStartTime ) > DANGER_GAUSS_CHARGE_TIME ) { //Damage the player WeaponSound( SPECIAL2 ); // Add DMG_CRUSH because we don't want any physics force pOwner->TakeDamage( CTakeDamageInfo( this, this, 25, DMG_SHOCK | DMG_CRUSH ) ); color32 gaussDamage = {255,128,0,128}; UTIL_ScreenFade( pOwner, gaussDamage, 0.2f, 0.2f, FFADE_IN ); m_flNextChargeTime = gpGlobals->curtime + random->RandomFloat( 0.5f, 2.5f ); } #endif return; } //Decrement power pOwner->RemoveAmmo( 1, m_iPrimaryAmmoType ); //Make sure we can draw power if ( pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) { ChargedFire(); return; } m_flNextChargeTime = gpGlobals->curtime + GAUSS_CHARGE_TIME; }
void CSnark::Event_Killed( const CTakeDamageInfo &inputInfo ) { // pev->model = iStringNull;// make invisible SetThink( &CSnark::SUB_Remove ); SetNextThink( gpGlobals->curtime + 0.1f ); SetTouch( NULL ); // since squeak grenades never leave a body behind, clear out their takedamage now. // Squeaks do a bit of radius damage when they pop, and that radius damage will // continue to call this function unless we acknowledge the Squeak's death now. (sjb) m_takedamage = DAMAGE_NO; // play squeek blast CPASAttenuationFilter filter( this, 0.5 ); enginesound->EmitSound( filter, entindex(), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5, 0, PITCH_NORM ); CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), SNARK_EXPLOSION_VOLUME, 3.0 ); UTIL_BloodDrips( WorldSpaceCenter(), Vector( 0, 0, 0 ), BLOOD_COLOR_YELLOW, 80 ); if ( m_hOwner != NULL ) { RadiusDamage( CTakeDamageInfo( this, m_hOwner, GetDamage(), DMG_BLAST ), GetAbsOrigin(), GetDamage() * 2.5, CLASS_NONE ); } else { RadiusDamage( CTakeDamageInfo( this, this, GetDamage(), DMG_BLAST ), GetAbsOrigin(), GetDamage() * 2.5, CLASS_NONE ); } // reset owner so death message happens if ( m_hOwner != NULL ) SetOwnerEntity( m_hOwner ); CTakeDamageInfo info = inputInfo; info.SetDamageType( DMG_GIB_CORPSE ); BaseClass::Event_Killed( info ); }
//----------------------------------------------------------------------------- // Purpose: Called every frame when the bruch is blocked while moving // Input : pOther - The blocking entity. //----------------------------------------------------------------------------- void CFuncMoveLinear::Blocked( CBaseEntity *pOther ) { // Hurt the blocker if ( m_flBlockDamage ) { if ( pOther->m_takedamage == DAMAGE_EVENTS_ONLY ) { if ( FClassnameIs( pOther, "gib" ) ) UTIL_Remove( pOther ); } else pOther->TakeDamage( CTakeDamageInfo( this, this, m_flBlockDamage, DMG_CRUSH ) ); } }
void CASW_Radiation_Volume::RadHurt(CBaseEntity *pEnt) { if (!pEnt) return; CBaseEntity *pAttacker = this; if (m_hCreator.Get() && pEnt->Classify() != CLASS_ASW_MARINE) // don't deal friendly fire damage from rad barrels pAttacker = m_hCreator.Get(); float fDamage = ASW_RAD_DAMAGE; if (pEnt->Classify() == CLASS_ASW_MARINE) fDamage *= 0.5f; pEnt->TakeDamage( CTakeDamageInfo( this, pAttacker, fDamage, DMG_RADIATION ) ); }
//----------------------------------------------------------------------------- // Purpose: Burn targets around us //----------------------------------------------------------------------------- void CEntityFlame::FlameThink( void ) { if ( m_flLifetime < gpGlobals->curtime ) { SetThink( &CEntityFlame::SUB_Remove ); SetNextThink( gpGlobals->curtime + 0.1f ); return; } RadiusDamage( CTakeDamageInfo( this, this, 4.0f, DMG_BURN ), GetAbsOrigin(), m_flSize/2, CLASS_NONE ); FireSystem_AddHeatInRadius( GetAbsOrigin(), m_flSize/2, 2.0f ); SetNextThink( gpGlobals->curtime + 0.1f ); }
//----------------------------------------------------------------------------- // Purpose: Will hurt others based on how fast the brush is spinning. // Input : pOther - //----------------------------------------------------------------------------- void CFuncRotating::HurtTouch ( CBaseEntity *pOther ) { // we can't hurt this thing, so we're not concerned with it if ( !pOther->m_takedamage ) return; // calculate damage based on rotation speed m_flBlockDamage = GetLocalAngularVelocity().Length() / 10; pOther->TakeDamage( CTakeDamageInfo( this, this, m_flBlockDamage, DMG_CRUSH ) ); Vector vecNewVelocity = pOther->GetAbsOrigin() - WorldSpaceCenter(); VectorNormalize(vecNewVelocity); vecNewVelocity *= m_flBlockDamage; pOther->SetAbsVelocity( vecNewVelocity ); }
void CTripmineGrenade::BeamBreakThink( void ) { // See if I can go solid yet (has dropper moved out of way?) if (IsSolidFlagSet( FSOLID_NOT_SOLID )) { trace_t tr; Vector vUpBit = GetAbsOrigin(); vUpBit.z += 5.0; UTIL_TraceEntity( this, GetAbsOrigin(), vUpBit, MASK_SHOT, &tr ); if ( !tr.startsolid && (tr.fraction == 1.0) ) { RemoveSolidFlags( FSOLID_NOT_SOLID ); } } trace_t tr; // NOT MASK_SHOT because we want only simple hit boxes UTIL_TraceLine( GetAbsOrigin(), m_vecEnd, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); // ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength ); // respawn detect. if ( !m_pBeam ) { MakeBeam( ); if ( tr.m_pEnt ) m_hOwner = tr.m_pEnt; // reset owner too } CBaseEntity *pEntity = tr.m_pEnt; CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity ); if (pBCC && pBCC->GetTeamNumber() != m_nTeam && pBCC->m_floatCloakFactor < 1.0f) //if (pBCC || fabs( m_flBeamLength - tr.fraction ) > 0.001) { m_iHealth = 0; Event_Killed( CTakeDamageInfo( (CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL ) ); return; } SetNextThink( gpGlobals->curtime + 0.05f ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPlayer_Missile::BlowUp(void) { // Don't take damage any more m_takedamage = DAMAGE_NO; // Mark as dead so won't be attacked m_lifeState = LIFE_DEAD; // Stop fly and launch sounds StopSound( "Player_Manhack.Fly" ); StopSound( "Player_Manhack.Fire" ); CPASFilter filter( GetAbsOrigin() ); te->Explosion( filter, 0.0, &GetAbsOrigin(), g_sModelIndexFireball, 2.0, 15, TE_EXPLFLAG_NONE, m_flDamageRadius, m_flDamage ); Vector vecForward = GetAbsVelocity(); VectorNormalize(vecForward); trace_t tr; UTIL_TraceLine ( GetAbsOrigin(), GetAbsOrigin() + 60*vecForward, MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr); UTIL_DecalTrace( &tr, "Scorch" ); UTIL_ScreenShake( GetAbsOrigin(), 25.0, 150.0, 1.0, 750, SHAKE_START ); CSoundEnt::InsertSound ( SOUND_DANGER, GetAbsOrigin(), 1024, 3.0 ); RadiusDamage ( CTakeDamageInfo( this, this, m_flDamage, DMG_BLAST ), GetAbsOrigin(), m_flDamageRadius, CLASS_NONE ); SetThink(ExplodeThink); SetTouch(NULL); m_vBounceVel = -0.2 * GetAbsVelocity(); AddSolidFlags( FSOLID_NOT_SOLID ); Relink(); // Stop emitting smoke if(m_hSmokeTrail) { ((SmokeTrail*)(CBaseEntity*)m_hSmokeTrail)->SetEmit(false); } }
void CBMortar::Touch( CBaseEntity *pOther ) { trace_t tr; int iPitch; // splat sound iPitch = random->RandomFloat( 90, 110 ); EmitSound( "NPC_BigMomma.SpitTouch1" ); switch ( random->RandomInt( 0, 1 ) ) { case 0: EmitSound( "NPC_BigMomma.SpitHit1" ); break; case 1: EmitSound( "NPC_BigMomma.SpitHit2" ); break; } if ( pOther->IsBSPModel() ) { // make a splat on the wall UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + GetAbsVelocity() * 10, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); UTIL_DecalTrace( &tr, "Splash" ); } else { tr.endpos = GetAbsOrigin(); Vector vVelocity = GetAbsVelocity(); VectorNormalize( vVelocity ); tr.plane.normal = -1 * vVelocity; } // make some flecks MortarSpray( tr.endpos + Vector( 0, 0, 15 ), tr.plane.normal, gSpitSprite, 24 ); CBaseEntity *pOwner = GetOwnerEntity(); RadiusDamage( CTakeDamageInfo( this, pOwner, sk_bigmomma_dmg_blast.GetFloat(), DMG_ACID ), GetAbsOrigin(), sk_bigmomma_radius_blast.GetFloat(), CLASS_NONE, NULL ); UTIL_Remove( pSprite ); UTIL_Remove( this ); }
void CBreakable::BreakTouch( CBaseEntity *pOther ) { float flDamage; // only players can break these right now if ( !pOther->IsPlayer() || !IsBreakable() ) { return; } // can I be broken when run into? if ( HasSpawnFlags( SF_BREAK_TOUCH ) ) { flDamage = pOther->GetSmoothedVelocity().Length() * 0.01; if (flDamage >= m_iHealth) { m_takedamage = DAMAGE_YES; SetTouch( NULL ); OnTakeDamage( CTakeDamageInfo( pOther, pOther, flDamage, DMG_CRUSH ) ); // do a little damage to player if we broke glass or computer CTakeDamageInfo info( pOther, pOther, flDamage/4, DMG_SLASH ); CalculateMeleeDamageForce( &info, (pOther->GetAbsOrigin() - GetAbsOrigin()), GetAbsOrigin() ); pOther->TakeDamage( info ); } } // can I be broken when stood upon? if ( HasSpawnFlags( SF_BREAK_PRESSURE ) && pOther->GetGroundEntity() == this ) { // play creaking sound here. DamageSound(); m_hBreaker = pOther; SetThink ( &CBreakable::Die ); SetTouch( NULL ); // Add optional delay SetNextThink( gpGlobals->curtime + m_flPressureDelay ); } }
//----------------------------------------------------------------------------- // Purpose: Push a physics object in our wash. Return false if it's now out of our wash //----------------------------------------------------------------------------- bool CBaseHelicopter::DoWashPush( washentity_t *pWash, Vector vecWashOrigin ) { if ( !pWash || !pWash->hEntity.Get() ) return false; // Make sure the entity is still within our wash's radius CBaseEntity *pEntity = pWash->hEntity; Vector vecSpot = pEntity->BodyTarget( vecWashOrigin ); Vector vecToSpot = ( vecSpot - vecWashOrigin ); vecToSpot.z = 0; float flDist = VectorNormalize( vecToSpot ); if ( flDist > BASECHOPPER_WASH_RADIUS ) return false; IPhysicsObject *pPhysObject = pEntity->VPhysicsGetObject(); if ( pPhysObject == NULL ) return false; // Push it away from the center of the wash float flMass = pPhysObject->GetMass(); float flPushTime = (gpGlobals->curtime - pWash->flWashStartTime); float flMinPush = BASECHOPPER_WASH_PUSH_MIN * flMass; float flMaxPush = BASECHOPPER_WASH_PUSH_MAX * flMass; float flWashAmount = min( flMaxPush, RemapVal( flPushTime, 0, BASECHOPPER_WASH_RAMP_TIME, flMinPush, flMaxPush ) ); Vector vecForce = flWashAmount * vecToSpot * phys_pushscale.GetFloat(); pEntity->VPhysicsTakeDamage( CTakeDamageInfo( this, this, vecForce, vecWashOrigin, flWashAmount, DMG_BLAST ) ); // Debug if ( g_debug_basehelicopter.GetInt() == BASECHOPPER_DEBUG_WASH ) { NDebugOverlay::Cross3D( pEntity->GetAbsOrigin(), -Vector(4,4,4), Vector(4,4,4), 255, 0, 0, true, 0.1f ); NDebugOverlay::Line( pEntity->GetAbsOrigin(), pEntity->GetAbsOrigin() + vecForce, 255, 255, 0, true, 0.1f ); IPhysicsObject *pPhysObject = pEntity->VPhysicsGetObject(); Msg("Pushed %s (mass %f) with force %f (min %.2f max %.2f) at time %.2f\n", pEntity->GetClassname(), pPhysObject->GetMass(), flWashAmount, flMinPush, flMaxPush, gpGlobals->curtime ); } // If we've pushed this thing for some time, remove it to give us a chance to find lighter things nearby if ( flPushTime > 2.0 ) return false; return true; }
//----------------------------------------------------------------------------- // Purpose: Make the object fall away // Input : pOther - The entity that is touching us. //----------------------------------------------------------------------------- void CASW_Trigger_Fall::FallTouch( CBaseEntity *pOther ) { // If it's a player, just kill him for now if ( pOther->IsNPC() ) { if ( pOther->IsAlive() == false ) return; pOther->TakeDamage( CTakeDamageInfo( this, this, 500, DMG_FALL ) ); } else { // Just remove the entity //UTIL_Remove( pOther ); } // Fire our output m_OnFallingObject.FireOutput( pOther, this ); }
void CWalkerMiniStrider::UpdateLargeGun() { float dt = GetTimeDelta(); if ( !m_bFiringLargeGun ) return; m_flLargeGunCountdown -= dt; if ( m_flLargeGunCountdown <= 0 ) { // Fire! Vector vSrc = GetLargeGunShootOrigin(); trace_t trace; UTIL_TraceLine( vSrc, vSrc + m_vLargeGunForward * 2000, MASK_SOLID, this, COLLISION_GROUP_NONE, &trace ); if ( trace.fraction < 1 ) { CBasePlayer *pDriver = GetPassenger( VEHICLE_DRIVER ); if ( pDriver ) { UTIL_ImpactTrace( &trace, DMG_ENERGYBEAM, "Strider" ); Vector vHitPos = trace.endpos; float flDamageRadius = 100; float flDamage = 100; CPASFilter filter( vHitPos ); te->Explosion( filter, 0.0, &vHitPos, g_sModelIndexFireball, 2.0, 15, TE_EXPLFLAG_NONE, flDamageRadius, flDamage ); UTIL_ScreenShake( vHitPos, 10.0, 150.0, 1.0, 100, SHAKE_START ); RadiusDamage( CTakeDamageInfo( this, pDriver, flDamage, DMG_BLAST ), vHitPos, flDamageRadius, CLASS_NONE ); } } StopFiringLargeGun(); } }