//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFGrenadeEmpProjectile::Detonate() { if ( ShouldNotDetonate() ) { RemoveGrenade(); return; } // Explosion effect on client // SendDispatchEffect(); float flRadius = 180; float flDamage = 1; if ( tf_grenade_show_radius.GetBool() ) { DrawRadius( flRadius ); } // Apply some amount of EMP damage to every entity in the radius. They will calculate // their own damage based on how much ammo they have or some other wacky calculation. CTakeDamageInfo info( this, GetThrower(), vec3_origin, GetAbsOrigin(), flDamage, /* DMG_EMP |*/ DMG_PREVENT_PHYSICS_FORCE ); CBaseEntity *pEntityList[100]; int nEntityCount = UTIL_EntitiesInSphere( pEntityList, 100, GetAbsOrigin(), flRadius, 0 ); int iEntity; for ( iEntity = 0; iEntity < nEntityCount; ++iEntity ) { CBaseEntity *pEntity = pEntityList[iEntity]; if ( pEntity == this ) continue; if ( pEntity && pEntity->IsPlayer() ) continue; if ( pEntity && ( pEntity->m_takedamage == DAMAGE_YES || pEntity->m_takedamage == DAMAGE_EVENTS_ONLY ) ) { pEntity->TakeDamage( info ); //if ( pEntity->IsPlayer() /* || is ammo box || is enemy object */ ) { CBeam *pBeam = CBeam::BeamCreate( "sprites/physcannon_bluelight1b.vmt", 3.0 ); if ( !pBeam ) return; pBeam->PointsInit( GetAbsOrigin(), pEntity->WorldSpaceCenter() ); pBeam->SetColor( 255, 255, 255 ); pBeam->SetBrightness( 128 ); pBeam->SetNoise( 12.0f ); pBeam->SetEndWidth( 3.0f ); pBeam->SetWidth( 3.0f ); pBeam->LiveForTime( 0.5f ); // Fail-safe pBeam->SetFrameRate( 25.0f ); pBeam->SetFrame( random->RandomInt( 0, 2 ) ); } } } DispatchParticleEffect( "emp_shockwave", GetAbsOrigin(), vec3_angle ); UTIL_Remove( this ); #if 0 // Tell the bots an HE grenade has exploded CTFPlayer *pPlayer = ToTFPlayer( GetThrower() ); if ( pPlayer ) { KeyValues *pEvent = new KeyValues( "tf_weapon_grenade_detonate" ); pEvent->SetInt( "userid", pPlayer->GetUserID() ); gameeventmanager->FireEventServerOnly( pEvent ); } #endif }
void CLocusBeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBaseEntity *pStartEnt; CBaseEntity *pEndEnt; Vector vecStartPos; Vector vecEndPos; CBeam *pBeam; switch(pev->impulse) { case 0: // ents pStartEnt = UTIL_FindEntityByTargetname(NULL, STRING(m_iszStart), pActivator); pEndEnt = UTIL_FindEntityByTargetname(NULL, STRING(m_iszEnd), pActivator); if (pStartEnt == NULL || pEndEnt == NULL) return; pBeam = CBeam::BeamCreate( STRING(m_iszSprite), m_iWidth ); pBeam->EntsInit( pStartEnt->entindex(), pEndEnt->entindex() ); break; case 1: // pointent vecStartPos = CalcLocus_Position( this, pActivator, STRING(m_iszStart) ); pEndEnt = UTIL_FindEntityByTargetname(NULL, STRING(m_iszEnd), pActivator); if (pEndEnt == NULL) return; pBeam = CBeam::BeamCreate( STRING(m_iszSprite), m_iWidth ); pBeam->PointEntInit( vecStartPos, pEndEnt->entindex() ); break; case 2: // points vecStartPos = CalcLocus_Position( this, pActivator, STRING(m_iszStart) ); vecEndPos = CalcLocus_Position( this, pActivator, STRING(m_iszEnd) ); pBeam = CBeam::BeamCreate( STRING(m_iszSprite), m_iWidth ); pBeam->PointsInit( vecStartPos, vecEndPos ); break; case 3: // point & offset vecStartPos = CalcLocus_Position( this, pActivator, STRING(m_iszStart) ); vecEndPos = CalcLocus_Velocity( this, pActivator, STRING(m_iszEnd) ); pBeam = CBeam::BeamCreate( STRING(m_iszSprite), m_iWidth ); pBeam->PointsInit( vecStartPos, vecStartPos + vecEndPos ); break; } pBeam->SetColor( pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z ); pBeam->SetBrightness( pev->renderamt ); pBeam->SetNoise( m_iDistortion ); pBeam->SetFrame( m_fFrame ); pBeam->SetScrollRate( m_iScrollRate ); pBeam->SetFlags( m_iFlags ); pBeam->pev->dmg = m_fDamage; pBeam->pev->frags = m_iDamageType; pBeam->pev->spawnflags |= pev->spawnflags & (SF_BEAM_RING | SF_BEAM_SPARKSTART | SF_BEAM_SPARKEND | SF_BEAM_DECALS); if (m_fDuration) { pBeam->SetThink(&CBeam:: SUB_Remove ); pBeam->SetNextThink( m_fDuration ); } pBeam->pev->targetname = m_iszTargetName; if (pev->target) { FireTargets( STRING(pev->target), pBeam, this, USE_TOGGLE, 0 ); } }