void CSqueakGrenade :: Killed( entvars_t *pevAttacker, int iGib ) { pev->model = iStringNull;// make invisible SetThink( SUB_Remove ); SetTouch( NULL ); pev->nextthink = gpGlobals->time + 0.1; // 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) pev->takedamage = DAMAGE_NO; // play squeek blast EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5, 0, PITCH_NORM); CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, SMALL_EXPLOSION_VOLUME, 3.0 ); UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 ); if (m_hOwner != NULL) RadiusDamage ( pev, m_hOwner->pev, pev->dmg, CLASS_NONE, DMG_BLAST ); else RadiusDamage ( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST ); // reset owner so death message happens if (m_hOwner != NULL) pev->owner = m_hOwner->edict(); CBaseMonster :: Killed( pevAttacker, GIB_ALWAYS ); }
//----------------------------------------------------------------------------- // 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 ); }
void CWeaponDrainGrenade::Explode( CBaseCombatCharacter* pAttacker, CBaseEntity* pInflictor, CBaseEntity* pIgnore, Vector vecPosition, float flDamage, float flRadius, float flDrainFocus ) { #if !defined( CLIENT_DLL ) //CSoundEnt::InsertSound ( SOUND_COMBAT, vecPosition, 1024, 3.0 ); CTakeDamageInfo info; info.CFSet( pInflictor, pAttacker, vec3_origin, vecPosition, flDamage, DMG_BLAST, WEAPON_NONE, &vecPosition, false ); info.SetDrainFocus( flDrainFocus ); DispatchParticleEffect("grenade_explosion", vecPosition, vec3_angle, pIgnore); //TODO: Figure out sound. CPASAttenuationFilter filter( this ); filter.UsePredictionRules(); EmitSound( filter, entindex(), "Numen.FireAoE" ); //CSoundEnt::InsertSound ( SOUND_COMBAT, GetAbsOrigin(), BASEGRENADE_EXPLOSION_VOLUME, 3.0 ); RadiusDamage( info, vecPosition, flRadius ); #endif //!defined( CLIENT_DLL ) }
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(); }
void CMmissile::ExplodeTouch( CBaseEntity *pOther ) { if ( UTIL_PointContents(pev->origin) == CONTENT_SKY ) { FX_Trail( pev->origin, entindex(), PROJ_REMOVE ); UTIL_Remove( this ); return; } if (pOther->pev->health == 666) { return; } TraceResult tr; Vector vecSpot = pev->origin - pev->velocity.Normalize() * 32; Vector vecEnd = pev->origin + pev->velocity.Normalize() * 64; UTIL_TraceLine( vecSpot, vecEnd, ignore_monsters, ENT(pev), &tr ); entvars_t *pevOwner = VARS( pev->owner ); RadiusDamage ( pev, pevOwner, pev->dmg, CLASS_NONE, DMG_BLAST ); FX_Trail( tr.vecEndPos + (tr.vecPlaneNormal * 15), entindex(), (UTIL_PointContents(pev->origin) == CONTENT_WATER)?PROJ_MMISSILE_DETONATE_WATER:PROJ_MMISSILE_DETONATE ); int tex = (int)TEXTURETYPE_Trace(&tr, vecSpot, vecEnd); CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); FX_ImpRocket( tr.vecEndPos, tr.vecPlaneNormal, pEntity->IsBSPModel()?1:0, BULLET_SMALEXP, (float)tex ); if (pOther->pev->takedamage) { ClearMultiDamage( ); pOther->TraceAttack(pevOwner, pev->dmg/3, gpGlobals->v_forward, &tr, DMG_BULLETMAGNUM ); ApplyMultiDamage( pev, pevOwner); } UTIL_Remove( this ); }
void CEnvExplosion::RealUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { pev->model = iStringNull;//invisible pev->solid = SOLID_NOT;// intangible pev->origin = pev->origin + Vector(0,0,12); // do damage if ( !( pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE ) ) RadiusDamage ( pev, pev, m_iMagnitude, CLASS_NONE, DMG_BLAST ); MESSAGE_BEGIN( MSG_ALL, gmsgWorldExp ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_SHORT( m_spriteScale ); WRITE_BYTE( (pev->spawnflags & SF_ENVEXPLOSION_NOSMOKE)?0:1 ); WRITE_BYTE( (pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS)?0:1 ); WRITE_BYTE( (pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL)?0:1 ); WRITE_BYTE( (pev->spawnflags & SF_ENVEXPLOSION_NORING)?0:1 ); WRITE_BYTE( (pev->spawnflags & SF_ENVEXPLOSION_NODECAL)?0:1 ); MESSAGE_END(); if ( !(pev->spawnflags & SF_ENVEXPLOSION_REPEATABLE) ) UTIL_Remove( this ); }
void CBlackHole :: DesintegrateThink( void ) { entvars_t *pevOwner = VARS( pev->owner ); if (UTIL_PointContents ( pev->origin ) == CONTENTS_WATER) { ::RadiusDamage( pev->origin, pev, pevOwner, (dmg_chrono_radius.value/2) * (mp_wpn_power.value/100), dmg_chrono_radius.value * (mp_wpn_power.value/100), CLASS_NONE, DMG_SONIC); FX_Trail( pev->origin, entindex(), PROJ_BLACKHOLE_DETONATE ); UTIL_Remove( this ); return; } ::FullRadiusDamage( pev->origin, pev, pevOwner, 999, 200, CLASS_NONE, DMG_ANNIHILATION); RadiusDamage(); pev->frags--; if (pev->frags <= 0) { ::RadiusDamage( pev->origin, pev, pevOwner, (dmg_chrono_radius.value/2) * (mp_wpn_power.value/100), dmg_chrono_radius.value* (mp_wpn_power.value/100), CLASS_NONE, DMG_SONIC); FX_Trail( pev->origin, entindex(), PROJ_BLACKHOLE_DETONATE ); UTIL_Remove( this ); return; } pev->nextthink = gpGlobals->time + 0.1; }
void CPropCannon::ProjectileExplosion( void ) { ExplosionCreate( m_vCrashPoint, vec3_angle, NULL, 512, 512, false ); // do damage CTakeDamageInfo info( this, this, g_cannon_damageandradius.GetInt(), DMG_BLAST ); info.SetDamagePosition( m_vCrashPoint ); RadiusDamage( info, m_vCrashPoint, g_cannon_damageandradius.GetInt(), CLASS_NONE, NULL ); }
//----------------------------------------------------------------------------- // 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 CMGargantua :: FlameUpdate( void ) { int i; static float offset[2] = { 60, -60 }; TraceResult trace; Vector vecStart, angleGun; BOOL streaks = FALSE; for ( i = 0; i < 2; i++ ) { if ( m_pFlame[i] ) { Vector vecAim = pev->angles; vecAim.x += m_flameX; vecAim.y += m_flameY; UTIL_MakeVectors( vecAim ); GetAttachment( i+1, vecStart, angleGun ); Vector vecEnd = vecStart + (gpGlobals->v_forward * GARG_FLAME_LENGTH); // - offset[i] * gpGlobals->v_right; UTIL_TraceLine( vecStart, vecEnd, dont_ignore_monsters, edict(), &trace ); m_pFlame[i]->SetStartPos( trace.vecEndPos ); m_pFlame[i+2]->SetStartPos( (vecStart * 0.6) + (trace.vecEndPos * 0.4) ); if ( trace.flFraction != 1.0 && gpGlobals->time > m_streakTime ) { StreakSplash( trace.vecEndPos, trace.vecPlaneNormal, 6, 20, 50, 400 ); streaks = TRUE; UTIL_DecalTrace( &trace, DECAL_SMALLSCORCH1 + RANDOM_LONG(0,2) ); } RadiusDamage( trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN ); FlameDamage( vecStart, trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN ); MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); WRITE_SHORT( entindex( ) + 0x1000 * (i + 2) ); // entity, attachment WRITE_COORD( vecStart.x ); // origin WRITE_COORD( vecStart.y ); WRITE_COORD( vecStart.z ); WRITE_COORD( RANDOM_FLOAT( 32, 48 ) ); // radius WRITE_BYTE( 255 ); // R WRITE_BYTE( 255 ); // G WRITE_BYTE( 255 ); // B WRITE_BYTE( 2 ); // life * 10 WRITE_COORD( 0 ); // decay MESSAGE_END(); } } if ( streaks ) m_streakTime = gpGlobals->time; }
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 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 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: 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: //----------------------------------------------------------------------------- void CTFBaseRocket::Explode( trace_t *pTrace, CBaseEntity *pOther ) { // Save this entity as enemy, they will take 100% damage. m_hEnemy = pOther; // Invisible. SetModelName( NULL_STRING ); AddSolidFlags( FSOLID_NOT_SOLID ); m_takedamage = DAMAGE_NO; // Pull out a bit. if ( pTrace->fraction != 1.0 ) { SetAbsOrigin( pTrace->endpos + ( pTrace->plane.normal * 1.0f ) ); } // Play explosion sound and effect. Vector vecOrigin = GetAbsOrigin(); CPVSFilter filter( vecOrigin ); TE_TFExplosion( filter, 0.0f, vecOrigin, pTrace->plane.normal, GetWeaponID(), pOther->entindex() ); CSoundEnt::InsertSound ( SOUND_COMBAT, vecOrigin, 1024, 3.0 ); // Damage. CBaseEntity *pAttacker = GetOwnerEntity(); IScorer *pScorerInterface = dynamic_cast<IScorer*>( pAttacker ); if ( pScorerInterface ) { pAttacker = pScorerInterface->GetScorer(); } CTakeDamageInfo info( this, pAttacker, vec3_origin, vecOrigin, GetDamage(), GetDamageType() ); float flRadius = GetRadius(); RadiusDamage( info, vecOrigin, flRadius, CLASS_NONE, NULL ); // Debug! if ( tf_rocket_show_radius.GetBool() ) { DrawRadius( flRadius ); } // Don't decal players with scorch. if ( !pOther->IsPlayer() ) { UTIL_DecalTrace( pTrace, "Scorch" ); } // Remove the rocket. UTIL_Remove( this ); }
//----------------------------------------------------------------------------- // 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 CNihilanthHVR::ZapTouch( CBaseEntity *pOther ) { UTIL_EmitAmbientSound( edict(), pev->origin, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, RANDOM_LONG( 90, 95 ) ); RadiusDamage( pev, pev, 50, CLASS_NONE, DMG_SHOCK ); pev->velocity = pev->velocity * 0; /* for (int i = 0; i < 10; i++) { Crawl( ); } */ SetTouch( NULL ); UTIL_Remove( this ); pev->nextthink = gpGlobals->time + 0.2; }
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(); } }
void CBaseGrenadeProjectile::Explode( trace_t *pTrace, int bitsDamageType ) { SetModelName( NULL_STRING );//invisible AddSolidFlags( FSOLID_NOT_SOLID ); m_takedamage = DAMAGE_NO; // Pull out of the wall a bit if ( pTrace->fraction != 1.0 ) { SetAbsOrigin( pTrace->endpos + (pTrace->plane.normal * 0.6) ); } Vector vecAbsOrigin = GetAbsOrigin(); // Since this code only runs on the server, make sure it shows the tempents it creates. // This solves a problem with remote detonating the pipebombs (client wasn't seeing the explosion effect) CDisablePredictionFiltering disabler; DispatchParticleEffect("grenade_exp1", vecAbsOrigin, QAngle(0, 0, 0)); CSoundEnt::InsertSound ( SOUND_COMBAT, vecAbsOrigin, BASEGRENADE_EXPLOSION_VOLUME, 3.0 ); // Use the thrower's position as the reported position Vector vecReported = GetThrower() ? GetThrower()->GetAbsOrigin() : vec3_origin; CTakeDamageInfo info( this, GetThrower(), GetBlastForce(), vecAbsOrigin, m_flDamage, bitsDamageType, 0, &vecReported ); RadiusDamage( info, vecAbsOrigin, m_DmgRadius, CLASS_NONE, NULL ); UTIL_DecalTrace( pTrace, "Scorch" ); EmitSound( "BaseGrenade.Explode" ); SetThink( &CBaseGrenade::SUB_Remove ); SetTouch( NULL ); SetSolid( SOLID_NONE ); AddEffects( EF_NODRAW ); SetAbsVelocity( vec3_origin ); SetNextThink( gpGlobals->curtime ); }
void CBMortar::Touch( CBaseEntity *pOther ) { TraceResult tr; int iPitch; // splat sound iPitch = RANDOM_FLOAT( 90, 110 ); EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch ); switch ( RANDOM_LONG( 0, 1 ) ) { case 0: EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch ); break; case 1: EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch ); break; } if ( pOther->IsBSPModel() ) { // make a splat on the wall UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT( pev ), &tr ); UTIL_DecalTrace(&tr, DECAL_MOMMASPLAT); } else { tr.vecEndPos = pev->origin; tr.vecPlaneNormal = -1 * pev->velocity.Normalize(); } // make some flecks MortarSpray( tr.vecEndPos, tr.vecPlaneNormal, gSpitSprite, 24 ); entvars_t *pevOwner = NULL; if ( pev->owner ) pevOwner = VARS(pev->owner); RadiusDamage( pev->origin, pev, pevOwner, gSkillData.bigmommaDmgBlast, gSkillData.bigmommaRadiusBlast, CLASS_NONE, DMG_ACID ); UTIL_Remove( this ); }
void Explode( float magnitude ) { //Create a concussive explosion CPASFilter filter( GetAbsOrigin() ); Vector vecForward; AngleVectors( GetAbsAngles(), &vecForward ); TE_ConcussiveExplosion( filter, 0.0, &GetAbsOrigin(),//position 1.0f, //scale 256*magnitude, //radius 175*magnitude, //magnitude &vecForward ); //normal int colorRamp = random->RandomInt( 128, 255 ); //Shockring CBroadcastRecipientFilter filter2; te->BeamRingPoint( filter2, 0, GetAbsOrigin(), //origin 16, //start radius 300*magnitude, //end radius m_spriteTexture, //texture 0, //halo index 0, //start frame 2, //framerate 0.3f, //life 128, //width 16, //spread 0, //amplitude colorRamp, //r colorRamp, //g 255, //g 24, //a 128 //speed ); //Do the radius damage RadiusDamage( CTakeDamageInfo( this, GetOwnerEntity(), 200, DMG_BLAST|DMG_DISSOLVE ), GetAbsOrigin(), 256, CLASS_NONE, NULL ); UTIL_Remove( this ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPointHurt::HurtThink( void ) { if ( m_strTarget != NULL_STRING ) { CBaseEntity *pEnt = NULL; CTakeDamageInfo info( this, m_pActivator, m_nDamage, m_bitsDamageType ); while ( ( pEnt = gEntList.FindEntityByName( pEnt, m_strTarget, NULL, m_pActivator ) ) != NULL ) { GuessDamageForce( &info, (pEnt->GetAbsOrigin() - GetAbsOrigin()), pEnt->GetAbsOrigin() ); pEnt->TakeDamage( info ); } } else { RadiusDamage( CTakeDamageInfo( this, this, m_nDamage, m_bitsDamageType ), GetAbsOrigin(), m_flRadius, CLASS_NONE, NULL ); } SetNextThink( gpGlobals->curtime + m_flDelay ); }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ void CGrenadePathfollower::Detonate(void) { StopSound(entindex(), CHAN_BODY, STRING(m_sFlySound)); m_takedamage = DAMAGE_NO; if(m_hRocketTrail) { UTIL_Remove(m_hRocketTrail); m_hRocketTrail = NULL; } CPASFilter filter( GetAbsOrigin() ); te->Explosion( filter, 0.0, &GetAbsOrigin(), g_sModelIndexFireball, 0.5, 15, TE_EXPLFLAG_NONE, m_DmgRadius, 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(), 400, 0.2 ); RadiusDamage ( CTakeDamageInfo( this, GetThrower(), m_flDamage, DMG_BLAST ), GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL ); CPASAttenuationFilter filter2( this, "GrenadePathfollower.StopSounds" ); EmitSound( filter2, entindex(), "GrenadePathfollower.StopSounds" ); UTIL_Remove( this ); }
// UNDONE: temporary scorching for PreAlpha - find a less sleazy permenant solution. void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) { float flRndSound;// sound randomizer pev->model = iStringNull;//invisible pev->solid = SOLID_NOT;// intangible pev->takedamage = DAMAGE_NO; // Pull out of the wall a bit if ( pTrace->flFraction != 1.0 ) { pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6); } int iContents = UTIL_PointContents ( pev->origin ); MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_EXPLOSION ); // This makes a dynamic light and the explosion sprites/sound WRITE_COORD( pev->origin.x ); // Send to PAS because of the sound WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); if (iContents != CONTENTS_WATER) { WRITE_SHORT( g_sModelIndexFireball ); } else { WRITE_SHORT( g_sModelIndexWExplosion ); } WRITE_BYTE( (pev->dmg - 50) * .60 ); // scale * 10 WRITE_BYTE( 15 ); // framerate WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); entvars_t *pevOwner; if ( pev->owner ) pevOwner = VARS( pev->owner ); else pevOwner = NULL; pev->owner = NULL; // can't traceline attack owner if this is set RadiusDamage ( pev, pevOwner, pev->dmg, CLASS_NONE, bitsDamageType ); if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 ) { UTIL_DecalTrace( pTrace, DECAL_SCORCH1 ); } else { UTIL_DecalTrace( pTrace, DECAL_SCORCH2 ); } flRndSound = RANDOM_FLOAT( 0 , 1 ); switch ( RANDOM_LONG( 0, 2 ) ) { case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris1.wav", 0.55, ATTN_NORM); break; case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris2.wav", 0.55, ATTN_NORM); break; case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris3.wav", 0.55, ATTN_NORM); break; } pev->effects |= EF_NODRAW; SetThink( &CGrenade::Smoke ); pev->velocity = g_vecZero; pev->nextthink = gpGlobals->time + 0.3; if (iContents != CONTENTS_WATER) { int sparkCount = RANDOM_LONG(0,3); for ( int i = 0; i < sparkCount; i++ ) Create( "spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL ); } }
//----------------------------------------------------------------------------- // Purpose: Burn targets around us //----------------------------------------------------------------------------- void CEntityFlame::FlameThink( void ) { // Assure that this function will be ticked again even if we early-out in the if below. SetNextThink( gpGlobals->curtime + FLAME_DAMAGE_INTERVAL ); if ( m_hEntAttached ) { if ( m_hEntAttached->GetFlags() & FL_TRANSRAGDOLL ) { SetRenderColorA( 0 ); return; } CAI_BaseNPC *pNPC = m_hEntAttached->MyNPCPointer(); if ( pNPC && !pNPC->IsAlive() ) { UTIL_Remove( this ); // Notify the NPC that it's no longer burning! pNPC->Extinguish(); return; } if( m_hEntAttached->GetWaterLevel() > 0 ) { Vector mins, maxs; mins = m_hEntAttached->WorldSpaceCenter(); maxs = mins; maxs.z = m_hEntAttached->WorldSpaceCenter().z; maxs.x += 32; maxs.y += 32; mins.z -= 32; mins.x -= 32; mins.y -= 32; UTIL_Bubbles( mins, maxs, 12 ); } } else { UTIL_Remove( this ); return; } // See if we're done burning, or our attached ent has vanished if ( m_flLifetime < gpGlobals->curtime || m_hEntAttached == NULL ) { EmitSound( "General.StopBurning" ); m_bPlayingSound = false; SetThink( &CEntityFlame::SUB_Remove ); SetNextThink( gpGlobals->curtime + 0.5f ); // Notify anything we're attached to if ( m_hEntAttached ) { CBaseCombatCharacter *pAttachedCC = m_hEntAttached->MyCombatCharacterPointer(); if( pAttachedCC ) { // Notify the NPC that it's no longer burning! pAttachedCC->Extinguish(); } } return; } if ( m_hEntAttached ) { // Do radius damage ignoring the entity I'm attached to. This will harm things around me. RadiusDamage( CTakeDamageInfo( this, this, 4.0f, DMG_BURN ), GetAbsOrigin(), m_flSize/2, CLASS_NONE, m_hEntAttached ); // Directly harm the entity I'm attached to. This is so we can precisely control how much damage the entity // that is on fire takes without worrying about the flame's position relative to the bodytarget (which is the // distance that the radius damage code uses to determine how much damage to inflict) m_hEntAttached->TakeDamage( CTakeDamageInfo( this, this, FLAME_DIRECT_DAMAGE, DMG_BURN | DMG_DIRECT ) ); if( !m_hEntAttached->IsNPC() && hl2_episodic.GetBool() ) { const int ENTITYFLAME_MOVE_AWAY_DIST = 24; // Make a sound near my origin, and up a little higher (in case I'm on the ground, so NPC's still hear it) CSoundEnt::InsertSound( SOUND_MOVE_AWAY, GetAbsOrigin(), ENTITYFLAME_MOVE_AWAY_DIST, 0.1f, this, SOUNDENT_CHANNEL_REPEATED_DANGER ); CSoundEnt::InsertSound( SOUND_MOVE_AWAY, GetAbsOrigin() + Vector( 0, 0, 48.0f ), ENTITYFLAME_MOVE_AWAY_DIST, 0.1f, this, SOUNDENT_CHANNEL_REPEATING ); } } else { RadiusDamage( CTakeDamageInfo( this, this, FLAME_RADIUS_DAMAGE, DMG_BURN ), GetAbsOrigin(), m_flSize/2, CLASS_NONE, NULL ); } FireSystem_AddHeatInRadius( GetAbsOrigin(), m_flSize/2, 2.0f ); }
void CSDKGameRules::RadiusDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore ) { RadiusDamage( info, vecSrcIn, flRadius, iClassIgnore, false ); }
void CHL1BaseGrenade::Explode( trace_t *pTrace, int bitsDamageType ) { float flRndSound;// sound randomizer SetModelName( NULL_STRING );//invisible AddSolidFlags( FSOLID_NOT_SOLID ); m_takedamage = DAMAGE_NO; // Pull out of the wall a bit if ( pTrace->fraction != 1.0 ) { SetLocalOrigin( pTrace->endpos + (pTrace->plane.normal * 0.6) ); } UTIL_Relink( this ); Vector vecAbsOrigin = GetAbsOrigin(); int contents = UTIL_PointContents ( vecAbsOrigin ); if ( pTrace->fraction != 1.0 ) { Vector vecNormal = pTrace->plane.normal; surfacedata_t *pdata = physprops->GetSurfaceData( pTrace->surface.surfaceProps ); CPASFilter filter( vecAbsOrigin ); te->Explosion( filter, 0.0, &vecAbsOrigin, !( contents & MASK_WATER ) ? g_sModelIndexFireball : g_sModelIndexWExplosion, m_DmgRadius * .03, 25, TE_EXPLFLAG_NONE, m_DmgRadius, m_flDamage, &vecNormal, (char) pdata->gameMaterial ); } else { CPASFilter filter( vecAbsOrigin ); te->Explosion( filter, 0.0, &vecAbsOrigin, !( contents & MASK_WATER ) ? g_sModelIndexFireball : g_sModelIndexWExplosion, m_DmgRadius * .03, 25, TE_EXPLFLAG_NONE, m_DmgRadius, m_flDamage ); } CSoundEnt::InsertSound ( SOUND_COMBAT, GetAbsOrigin(), BASEGRENADE_EXPLOSION_VOLUME, 3.0 ); // Use the owner's position as the reported position Vector vecReported = GetOwner() ? GetOwner()->GetAbsOrigin() : vec3_origin; CTakeDamageInfo info( this, GetOwner(), GetBlastForce(), GetAbsOrigin(), m_flDamage, bitsDamageType, 0, &vecReported ); RadiusDamage( info, GetAbsOrigin(), m_DmgRadius, CLASS_NONE ); UTIL_DecalTrace( pTrace, "Scorch" ); flRndSound = random->RandomFloat( 0 , 1 ); EmitSound( "BaseGrenade.Explode" ); SetTouch( NULL ); m_fEffects |= EF_NODRAW; SetAbsVelocity( vec3_origin ); SetThink( Smoke ); SetNextThink( gpGlobals->curtime + 0.3); if ( GetWaterLevel() == 0 ) { int sparkCount = random->RandomInt( 0,3 ); QAngle angles; VectorAngles( pTrace->plane.normal, angles ); for ( int i = 0; i < sparkCount; i++ ) Create( "spark_shower", GetAbsOrigin(), angles, NULL ); } }
/* <7f233> ../cstrike/dlls/explode.cpp:150 */ void CEnvExplosion::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { TraceResult tr; pev->model = iStringNull;//invisible pev->solid = SOLID_NOT;//intangible Vector vecSpot;// trace starts here! vecSpot = pev->origin + Vector(0, 0, 8); UTIL_TraceLine(vecSpot, vecSpot + Vector (0, 0, -40), ignore_monsters, ENT(pev), & tr); // Pull out of the wall a bit if (tr.flFraction != 1.0f) { pev->origin = tr.vecEndPos + (tr.vecPlaneNormal * (m_iMagnitude - 24) * 0.6f); } else { pev->origin = pev->origin; } // draw decal if (! (pev->spawnflags & SF_ENVEXPLOSION_NODECAL)) { if (RANDOM_FLOAT(0, 1) < 0.5) { UTIL_DecalTrace(&tr, DECAL_SCORCH1); } else { UTIL_DecalTrace(&tr, DECAL_SCORCH2); } } // draw fireball if (!(pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL)) { MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); WRITE_BYTE(TE_EXPLOSION); WRITE_COORD(pev->origin.x); WRITE_COORD(pev->origin.y); WRITE_COORD(pev->origin.z); WRITE_SHORT(g_sModelIndexFireball); WRITE_BYTE((byte)m_spriteScale); // scale * 10 WRITE_BYTE(15); // framerate WRITE_BYTE(TE_EXPLFLAG_NONE); MESSAGE_END(); } else { MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); WRITE_BYTE(TE_EXPLOSION); WRITE_COORD(pev->origin.x); WRITE_COORD(pev->origin.y); WRITE_COORD(pev->origin.z); WRITE_SHORT(g_sModelIndexFireball); WRITE_BYTE(0); // no sprite WRITE_BYTE(15); // framerate WRITE_BYTE(TE_EXPLFLAG_NONE); MESSAGE_END(); } // do damage if (!(pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE)) { RadiusDamage(pev, pev, m_iMagnitude, CLASS_NONE, DMG_BLAST); } SetThink(&CEnvExplosion::Smoke); pev->nextthink = gpGlobals->time + 0.3f; // draw sparks if (!(pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS)) { int sparkCount = RANDOM_LONG(0, 3); for (int i = 0; i < sparkCount; i++) { Create("spark_shower", pev->origin, tr.vecPlaneNormal, NULL); } } }
// Основная атака огнеметом // This is the cremator's main attack, or more precisely, its damage function. void CNPC_Cremator::DispatchSpray( CBaseEntity *pEntity ) { Vector vecSrc, vecAim; trace_t tr; //const char *entityname = pEntity->GetClassname(); Vector forward, right, up; AngleVectors( GetAbsAngles(), &forward, &right, &up ); vecSrc = GetAbsOrigin() + up * 36; vecAim = GetShootEnemyDir( vecSrc ); float deflection = 0.01; vecAim = vecAim + 1 * right * random->RandomFloat( 0, deflection ) + up * random->RandomFloat( -deflection, deflection ); UTIL_TraceLine ( vecSrc, vecSrc + vecAim * 512, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr); /* if ( tr.DidHitWorld() ) // spawn flames on solid surfaces. // It's not very important since it is extremely rare for a cremator to // hit brush geometry but might be a nice feature for a close-space combat // it also works fine but again is EXTREMELY hard to get in-game { Vector ofsDir = ( tr.endpos - GetAbsOrigin() ); float offset = VectorNormalize( ofsDir ); if ( offset > 128 ) offset = 128; float scale = 0.1f + ( 0.75f * ( 1.0f - ( offset / 128.0f ) ) ); float growth = 0.1f + ( 0.75f * (offset / 128.0f ) ); if ( tr.surface.flags & CONTENTS_GRATE ) // get smaller flames on grates since they have a smaller burning area { scale = 0.1f + ( 0.15f * ( 1.0f - ( offset / 128.0f ) ) ); } else { scale = 0.1f + ( 0.75f * ( 1.0f - ( offset / 128.0f ) ) ); } FireSystem_StartFire( tr.endpos, scale, growth, 8.0, 10.0f, (SF_FIRE_START_ON|SF_FIRE_START_FULL), (CBaseEntity*) this, FIRE_NATURAL ); } */ pEntity = tr.m_pEnt; if ( pEntity != NULL && m_takedamage ) { CTakeDamageInfo firedamage( this, this, sk_cremator_firedamage.GetFloat(), DMG_BURN ); CTakeDamageInfo radiusdamage( this, this, sk_cremator_radiusdamage.GetFloat(), DMG_PLASMA ); CalculateMeleeDamageForce( &firedamage, vecAim, tr.endpos ); RadiusDamage ( CTakeDamageInfo ( this, this, 2, DMG_PLASMA ), // AOE; this stuff makes cremators absurdly powerfull sometimes btw tr.endpos, 64.0f, CLASS_NONE, NULL ); pEntity->DispatchTraceAttack( ( firedamage ), vecAim, &tr ); Vector flEnemyLKP = pEntity->GetAbsOrigin(); GetMotor()->SetIdealYawToTargetAndUpdate( flEnemyLKP ); ClearMultiDamage(); } m_iAmmo --; }