void CPlayerBall::RemovePlayerBall() { UTIL_Remove(this); }
//--------------------------------------------------------- // Count of all the weapons in the world of my type and // see if we have a surplus. If there is a surplus, try // to find suitable candidates for removal. // // Right now we just remove the first weapons we find that // are behind the player, or are out of the player's PVS. // Later, we may want to score the results so that we // removed the farthest gun that's not in the player's // viewcone, etc. // // Some notes and thoughts: // // This code is designed NOT to remove weapons that are // hand-placed by level designers. It should only clean // up weapons dropped by dead NPCs, which is useful in // situations where enemies are spawned in for a sustained // period of time. // // Right now we PREFER to remove weapons that are not in the // player's PVS, but this could be opposite of what we // really want. We may only want to conduct the cleanup on // weapons that are IN the player's PVS. //--------------------------------------------------------- void CGameWeaponManager::Think() { int i; // Don't have to think all that often. SetNextThink( gpGlobals->curtime + 2.0 ); const char *pszWeaponName = STRING( m_iszWeaponName ); CUtlVector<CBaseEntity *> candidates( 0, 64 ); if ( m_bExpectingWeapon ) { CBaseCombatWeapon *pWeapon = NULL; // Firstly, count the total number of weapons of this type in the world. // Also count how many of those can potentially be removed. pWeapon = assert_cast<CBaseCombatWeapon *>(gEntList.FindEntityByClassname( pWeapon, pszWeaponName )); while( pWeapon ) { if( !pWeapon->IsEffectActive( EF_NODRAW ) && pWeapon->IsRemoveable() ) { candidates.AddToTail( pWeapon ); } pWeapon = assert_cast<CBaseCombatWeapon *>(gEntList.FindEntityByClassname( pWeapon, pszWeaponName )); } } else { for ( i = 0; i < m_ManagedNonWeapons.Count(); i++) { CBaseEntity *pEntity = m_ManagedNonWeapons[i]; if ( pEntity ) { Assert( pEntity->m_iClassname == m_iszWeaponName ); if ( !pEntity->IsEffectActive( EF_NODRAW ) ) { candidates.AddToTail( pEntity ); } } else { m_ManagedNonWeapons.FastRemove( i-- ); } } } // Calculate the surplus. int surplus = candidates.Count() - m_iMaxPieces; // Based on what the player can see, try to clean up the world by removing weapons that // the player cannot see right at the moment. CBaseEntity *pCandidate; for ( i = 0; i < candidates.Count() && surplus > 0; i++ ) { bool fRemovedOne = false; pCandidate = candidates[i]; Assert( !pCandidate->IsEffectActive( EF_NODRAW ) ); if ( gpGlobals->maxClients == 1 ) { CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); // Nodraw serves as a flag that this weapon is already being removed since // all we're really doing inside this loop is marking them for removal by // the entity system. We don't want to count the same weapon as removed // more than once. if( !UTIL_FindClientInPVS( pCandidate->edict() ) ) { fRemovedOne = true; } else if( !pPlayer->FInViewCone( pCandidate ) ) { fRemovedOne = true; } else if ( UTIL_DistApprox( pPlayer->GetAbsOrigin(), pCandidate->GetAbsOrigin() ) > (30*12) ) { fRemovedOne = true; } } else { fRemovedOne = true; } if( fRemovedOne ) { pCandidate->AddEffects( EF_NODRAW ); UTIL_Remove( pCandidate ); DevMsg( 2, "Surplus %s removed\n", pszWeaponName); surplus--; } } }
void CTankProj::Killed (entvars_t *pevAttacker, int iGib) { UTIL_Remove( this ); }
//========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. // // Returns number of events handled, 0 if none. //========================================================= void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) { // ALERT( at_console, "event %d : %f\n", pEvent->event, pev->frame ); switch( pEvent->event ) { case ISLAVE_AE_CLAW: { // SOUND HERE! CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.slaveDmgClaw, DMG_SLASH ); if ( pHurt ) { if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) { pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; } // Play a random attack hit sound EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); } else { // Play a random attack miss sound EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); } } break; case ISLAVE_AE_CLAWRAKE: { CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.slaveDmgClawrake, DMG_SLASH ); if ( pHurt ) { if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) { pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; } EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); } else { EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); } } break; case ISLAVE_AE_ZAP_POWERUP: { // speed up attack when on hard if (g_iSkillLevel == SKILL_HARD) pev->framerate = 1.5; UTIL_MakeAimVectors( pev->angles ); if (m_iBeams == 0) { Vector vecSrc = pev->origin + gpGlobals->v_forward * 2; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); WRITE_BYTE(TE_DLIGHT); WRITE_COORD(vecSrc.x); // X WRITE_COORD(vecSrc.y); // Y WRITE_COORD(vecSrc.z); // Z WRITE_BYTE( 12 ); // radius * 0.1 WRITE_BYTE( 255 ); // r WRITE_BYTE( 180 ); // g WRITE_BYTE( 96 ); // b WRITE_BYTE( 20 / pev->framerate ); // time * 10 WRITE_BYTE( 0 ); // decay * 0.1 MESSAGE_END( ); } if (m_hDead != 0) { WackBeam( -1, m_hDead ); WackBeam( 1, m_hDead ); } else { ArmBeam( -1 ); ArmBeam( 1 ); BeamGlow( ); } EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "debris/zap4.wav", 1, ATTN_NORM, 0, 100 + m_iBeams * 10 ); pev->skin = m_iBeams / 2; } break; case ISLAVE_AE_ZAP_SHOOT: { ClearBeams( ); if (m_hDead != 0) { Vector vecDest = m_hDead->pev->origin + Vector( 0, 0, 38 ); TraceResult trace; UTIL_TraceHull( vecDest, vecDest, dont_ignore_monsters, human_hull, m_hDead->edict(), &trace ); if ( !trace.fStartSolid ) { CBaseEntity *pNew = Create( "monster_alien_slave", m_hDead->pev->origin, m_hDead->pev->angles ); pNew->pev->spawnflags |= 1; WackBeam( -1, pNew ); WackBeam( 1, pNew ); UTIL_Remove( m_hDead ); EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "hassault/hw_shoot1.wav", 1, ATTN_NORM, 0, RANDOM_LONG( 130, 160 ) ); /* CBaseEntity *pEffect = Create( "test_effect", pNew->Center(), pev->angles ); pEffect->Use( this, this, USE_ON, 1 ); */ break; } } ClearMultiDamage(); UTIL_MakeAimVectors( pev->angles ); ZapBeam( -1 ); ZapBeam( 1 ); EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "hassault/hw_shoot1.wav", 1, ATTN_NORM, 0, RANDOM_LONG( 130, 160 ) ); // STOP_SOUND( ENT(pev), CHAN_WEAPON, "debris/zap4.wav" ); ApplyMultiDamage(pev, pev); m_flNextAttack = gpGlobals->time + RANDOM_FLOAT( 0.5, 4.0 ); } break; case ISLAVE_AE_ZAP_DONE: { ClearBeams( ); } break; default: CSquadMonster::HandleAnimEvent( pEvent ); break; } }
// Pickup backpack BOOL CItemBackpack::MyTouch( CBasePlayer *pPlayer ) { if (pPlayer->pev->health <= 0) return FALSE; if (gpGlobals->deathmatch == 4 && pPlayer->m_flInvincibleFinished > 0) return FALSE; if (gpGlobals->deathmatch == 4) { pPlayer->pev->health += 10; ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#Additional_Health" ); if ((pPlayer->pev->health > 250) && (pPlayer->pev->health < 300)) EMIT_SOUND( ENT(pPlayer->pev), CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM ); else EMIT_SOUND( ENT(pPlayer->pev), CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM ); // Become invulnerable if the player's reached 300 health if (pPlayer->pev->health > 299) { if (pPlayer->m_flInvincibleFinished == 0) { // Give player invincibility and quad pPlayer->m_flInvincibleFinished = gpGlobals->time + 30; pPlayer->m_flSuperDamageFinished = gpGlobals->time + 30; pPlayer->m_iQuakeItems |= (IT_INVULNERABILITY | IT_QUAD); pPlayer->m_iAmmoCells = 0; // Make player glow red pPlayer->pev->renderfx = kRenderFxGlowShell; pPlayer->pev->rendercolor = Vector( 255, 128, 0 ); // RGB pPlayer->pev->renderamt = 100; // Shell size EMIT_SOUND( ENT(pPlayer->pev), CHAN_VOICE, "items/sight1.wav", 1, ATTN_NORM ); UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Bonus_Power", STRING(pPlayer->pev->netname) ); } } UTIL_Remove( this ); // We've removed ourself, so don't let CQuakeItem handle respawn return FALSE; } // Get the weapon from the pack if (m_iItems) { if ( !(pPlayer->m_iQuakeItems & m_iItems) ) { switch ( m_iItems ) { case IT_SUPER_SHOTGUN: ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_SS", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break; case IT_NAILGUN: ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_NG", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break; case IT_SUPER_NAILGUN: ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_SG", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break; case IT_GRENADE_LAUNCHER: ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_GL", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break; case IT_ROCKET_LAUNCHER: ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_RL", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break; case IT_LIGHTNING: ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_LG", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break; } } else ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_NoGun", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); } // Get ammo from pack pPlayer->m_iAmmoShells += ammo_shells; pPlayer->m_iAmmoNails += ammo_nails; pPlayer->m_iAmmoRockets += ammo_rockets; pPlayer->m_iAmmoCells += ammo_cells; pPlayer->CheckAmmo(); int iNewWeapon = m_iItems; if (!iNewWeapon) iNewWeapon = pPlayer->m_iQuakeWeapon; int iOldWeapon = pPlayer->m_iQuakeItems; pPlayer->m_iQuakeItems |= m_iItems; // Give them at least 5 rockets in DM==3 and DM==5 if ( (gpGlobals->deathmatch==3 || gpGlobals->deathmatch == 5) & ( (WeaponCode(iNewWeapon)==6) || (WeaponCode(iNewWeapon)==7) ) & (pPlayer->m_iAmmoRockets < 5) ) pPlayer->m_iAmmoRockets = 5; EMIT_SOUND( ENT(pPlayer->pev), CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM ); // Switch to a better weapon if ( WeaponCode(iNewWeapon) <= pPlayer->m_iBackpackSwitch ) { if (pPlayer->pev->flags & FL_INWATER) { if (iNewWeapon != IT_LIGHTNING) { pPlayer->Deathmatch_Weapon(iOldWeapon, iNewWeapon); } } else { pPlayer->Deathmatch_Weapon(iOldWeapon, iNewWeapon); } } pPlayer->W_SetCurrentAmmo(); pPlayer->m_iClientQuakeWeapon = -1; pPlayer->m_fWeapon = FALSE; pPlayer->m_fKnownItem = FALSE; pPlayer->UpdateClientData(); UTIL_Remove( this ); // We've removed ourself, so don't let CQuakeItem handle respawn return FALSE; }
void CControllerHeadBall :: HuntThink( void ) { pev->nextthink = gpGlobals->time + 0.1; pev->renderamt -= 5; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); WRITE_SHORT( entindex( ) ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_COORD( pev->renderamt / 16 ); // radius WRITE_BYTE( 255 ); // R WRITE_BYTE( 255 ); // G WRITE_BYTE( 255 ); // B WRITE_BYTE( 2 ); // life * 10 WRITE_COORD( 0 ); // decay MESSAGE_END(); // check world boundaries if (gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096) { SetTouch( NULL ); UTIL_Remove( this ); return; } MovetoTarget( m_hEnemy->Center( ) ); if ((m_hEnemy->Center() - pev->origin).Length() < 64) { TraceResult tr; UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, ENT(pev), &tr ); CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); if (pEntity != NULL && pEntity->pev->takedamage) { ClearMultiDamage( ); pEntity->TraceAttack( m_hOwner->pev, gSkillData.controllerDmgZap, pev->velocity, &tr, DMG_SHOCK ); ApplyMultiDamage( pev, m_hOwner->pev ); } MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMENTPOINT ); WRITE_SHORT( entindex() ); WRITE_COORD( tr.vecEndPos.x ); WRITE_COORD( tr.vecEndPos.y ); WRITE_COORD( tr.vecEndPos.z ); WRITE_SHORT( g_sModelIndexLaser ); WRITE_BYTE( 0 ); // frame start WRITE_BYTE( 10 ); // framerate WRITE_BYTE( 3 ); // life WRITE_BYTE( 20 ); // width WRITE_BYTE( 0 ); // noise WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // brightness WRITE_BYTE( 10 ); // speed MESSAGE_END(); UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) ); m_flNextAttack = gpGlobals->time + 3.0; SetThink( DieThink ); pev->nextthink = gpGlobals->time + 0.3; } // Crawl( ); }
void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) { pev->takedamage = DAMAGE_NO; pev->deadflag = DEAD_DEAD; UTIL_Remove( this ); }
void CTentacle :: DieThink( void ) { pev->nextthink = gpGlobals-> time + 0.1; DispatchAnimEvents( ); StudioFrameAdvance( ); ChangeYaw( 24 ); if (m_fSequenceFinished) { if (pev->sequence == m_iGoalAnim) { switch( m_iGoalAnim ) { case TENTACLE_ANIM_Engine_Idle: case TENTACLE_ANIM_Engine_Sway: case TENTACLE_ANIM_Engine_Swat: case TENTACLE_ANIM_Engine_Bob: m_iGoalAnim = TENTACLE_ANIM_Engine_Sway + RANDOM_LONG( 0, 2 ); break; case TENTACLE_ANIM_Engine_Death1: case TENTACLE_ANIM_Engine_Death2: case TENTACLE_ANIM_Engine_Death3: UTIL_Remove( this ); return; } } // ALERT( at_console, "%d : %d => ", pev->sequence, m_iGoalAnim ); pev->sequence = FindTransition( pev->sequence, m_iGoalAnim, &m_iDir ); // ALERT( at_console, "%d\n", pev->sequence ); if (m_iDir > 0) { pev->frame = 0; } else { pev->frame = 255; } ResetSequenceInfo( ); float dy; switch( pev->sequence ) { case TENTACLE_ANIM_Floor_Rear: case TENTACLE_ANIM_Floor_Rear_Idle: case TENTACLE_ANIM_Lev1_Rear: case TENTACLE_ANIM_Lev1_Rear_Idle: case TENTACLE_ANIM_Lev2_Rear: case TENTACLE_ANIM_Lev2_Rear_Idle: case TENTACLE_ANIM_Lev3_Rear: case TENTACLE_ANIM_Lev3_Rear_Idle: case TENTACLE_ANIM_Engine_Idle: case TENTACLE_ANIM_Engine_Sway: case TENTACLE_ANIM_Engine_Swat: case TENTACLE_ANIM_Engine_Bob: case TENTACLE_ANIM_Engine_Death1: case TENTACLE_ANIM_Engine_Death2: case TENTACLE_ANIM_Engine_Death3: pev->framerate = RANDOM_FLOAT( m_iDir - 0.2, m_iDir + 0.2 ); dy = 180; break; default: pev->framerate = 1.5; dy = 0; break; } pev->ideal_yaw = m_flInitialYaw + dy; } }
void InputOnBreak( inputdata_t &inputdata ) { UTIL_Remove(this); }
void CASW_Grenade_PRifle::Detonate() { if ( !ASWGameResource() ) return; m_takedamage = DAMAGE_NO; CPASFilter filter( GetAbsOrigin() ); Vector vecForward = GetAbsVelocity(); VectorNormalize(vecForward); trace_t tr; Vector vecDir = -vecForward; //te->GaussExplosion( filter, 0.0, //GetAbsOrigin(), vecDir, 0 ); CEffectData data; data.m_vOrigin = GetAbsOrigin(); DispatchEffect( "aswstunexplo", data ); EmitSound("ASW_Weapon_PRifle.StunGrenadeExplosion"); 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_ASW_ScreenShake( GetAbsOrigin(), 25.0, 150.0, 1.0, 750, SHAKE_START ); int nPreviousStunnedAliens = ASWGameResource()->m_iElectroStunnedAliens; // do just 1 damage... CTakeDamageInfo info( this, GetOwnerEntity(), 1, DMG_SHOCK ); info.SetWeapon( m_hCreatorWeapon ); RadiusDamage ( info , GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL ); // count as a shot fired CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>(GetOwnerEntity()); if ( pMarine && pMarine->GetMarineResource() ) { CASW_Marine_Resource *pMR = pMarine->GetMarineResource(); pMR->UsedWeapon(NULL, 1); int nAliensStunned = ASWGameResource()->m_iElectroStunnedAliens - nPreviousStunnedAliens; if ( nAliensStunned >= 6 && pMR->IsInhabited() && pMR->GetCommander() ) { pMR->GetCommander()->AwardAchievement( ACHIEVEMENT_ASW_STUN_GRENADE ); pMR->m_bStunGrenadeMedal = true; } } UTIL_Remove( this ); }
//----------------------------------------------------------------------------- // Purpose: // Input : pOther - //----------------------------------------------------------------------------- void CItem::ItemTouch( CBaseEntity *pOther ) { // Vehicles can touch items + pick them up if ( pOther->GetServerVehicle() ) { pOther = pOther->GetServerVehicle()->GetPassenger(); if ( !pOther ) return; } // if it's not a player, ignore if ( !pOther->IsPlayer() ) return; CBasePlayer *pPlayer = (CBasePlayer *)pOther; // Must be a valid pickup scenario (no blocking). Though this is a more expensive // check than some that follow, this has to be first Obecause it's the only one // that inhibits firing the output OnCacheInteraction. if ( ItemCanBeTouchedByPlayer( pPlayer ) == false ) return; m_OnCacheInteraction.FireOutput(pOther, this); // Can I even pick stuff up? if ( !pPlayer->IsAllowedToPickupWeapons() ) return; // ok, a player is touching this item, but can he have it? if ( !g_pGameRules->CanHaveItem( pPlayer, this ) ) { // no? Ignore the touch. return; } if ( MyTouch( pPlayer ) ) { m_OnPlayerTouch.FireOutput(pOther, this); SetTouch( NULL ); SetThink( NULL ); // player grabbed the item. g_pGameRules->PlayerGotItem( pPlayer, this ); if ( g_pGameRules->ItemShouldRespawn( this ) == GR_ITEM_RESPAWN_YES ) { Respawn(); } else { UTIL_Remove( this ); #ifdef HL2MP HL2MPRules()->RemoveLevelDesignerPlacedObject( this ); #endif } } else if (gEvilImpulse101) { UTIL_Remove( this ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNPC_GroundTurret::Spawn( void ) { Precache(); UTIL_SetModel( this, "models/combine_turrets/ground_turret.mdl" ); SetNavType( NAV_FLY ); SetSolid( SOLID_VPHYSICS ); SetBloodColor( DONT_BLEED ); m_iHealth = 125; m_flFieldOfView = cos( ((GROUNDTURRET_VIEWCONE / 2.0f) * M_PI / 180.0f) ); m_NPCState = NPC_STATE_NONE; m_vecSpread.x = 0.5; m_vecSpread.y = 0.5; m_vecSpread.z = 0.5; CapabilitiesClear(); AddEFlags( EFL_NO_DISSOLVE ); NPCInit(); CapabilitiesAdd( bits_CAP_SIMPLE_RADIUS_DAMAGE ); m_iAmmoType = GetAmmoDef()->Index( "PISTOL" ); m_pSmoke = NULL; m_bHasExploded = false; m_bEnabled = false; if( ai_newgroundturret.GetBool() ) { m_flSensingDist = 384; SetDistLook( m_flSensingDist ); } else { m_flSensingDist = 2048; } if( !GetParent() ) { DevMsg("ERROR! npc_ground_turret with no parent!\n"); UTIL_Remove(this); return; } m_flTimeNextShoot = gpGlobals->curtime; m_flTimeNextPing = gpGlobals->curtime; m_vecClosedPos = GetAbsOrigin(); StudioFrameAdvance(); Vector vecPos; GetAttachment( "eyes", vecPos ); SetViewOffset( vecPos - GetAbsOrigin() ); GetAttachment( "light", vecPos ); m_vecLightOffset = vecPos - GetAbsOrigin(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CGrenadeBugBait::BugBaitTouch( CBaseEntity *pOther ) { Assert( pOther ); if ( !pOther->IsSolid() ) return; if ( m_pSporeTrail != NULL ) { m_pSporeTrail->m_bEmit = false; } //Do effect for the hit SporeExplosion *pSporeExplosion = SporeExplosion::CreateSporeExplosion(); if ( pSporeExplosion ) { Vector dir = -GetAbsVelocity(); VectorNormalize( dir ); QAngle angles; VectorAngles( dir, angles ); pSporeExplosion->SetLocalAngles( angles ); pSporeExplosion->SetLocalOrigin( GetAbsOrigin() ); pSporeExplosion->m_flSpawnRate = 1.0f; pSporeExplosion->m_flParticleLifetime = 2.0f; pSporeExplosion->SetRenderColor( 0.0f, 0.5f, 0.25f, 0.15f ); pSporeExplosion->m_flStartSize = 0.0f; pSporeExplosion->m_flEndSize = 32.0f; pSporeExplosion->m_flSpawnRadius = 2.0f; pSporeExplosion->SetLifetime( bugbait_distract_time.GetFloat() ); UTIL_Relink( pSporeExplosion ); } trace_t tr; Vector traceDir, tracePos; Vector directions[ NUM_SPLASHES ] = { Vector( 1, 0, 0 ), Vector( -1, 0, 0 ), Vector( 0, 1, 0 ), Vector( 0, -1, 0 ), Vector( 0, 0, 1 ), Vector( 0, 0, -1 ), }; //Splatter decals everywhere for ( int i = 0; i < NUM_SPLASHES; i++ ) { traceDir = directions[i]; tracePos = GetAbsOrigin() + ( traceDir * 64.0f ); UTIL_TraceLine( GetAbsOrigin(), tracePos, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction < 1.0f ) { UTIL_DecalTrace( &tr, "BeerSplash" ); //TODO: Use real decal } } //Make a splat sound CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), CHAN_WEAPON, "weapons/bugbait/splat.wav", 1.0f, ATTN_NORM ); //Attempt to activate any spawners in a radius around the bugbait CBaseEntity* pList[100]; Vector delta( 256, 256, 256 ); bool suppressCall = false; int count = UTIL_EntitiesInBox( pList, 100, GetAbsOrigin() - delta, GetAbsOrigin() + delta, 0 ); //Iterate over all the possible targets for ( i = 0; i < count; i++ ) { //See if this is a bugbait sensor if ( FClassnameIs( pList[i], "point_bugbait" ) ) { CBugBaitSensor *pSensor = dynamic_cast<CBugBaitSensor *>(pList[i]); if ( pSensor == NULL ) continue; //Make sure we're within range of the sensor if ( pSensor->GetRadius() > ( pSensor->GetAbsOrigin() - GetAbsOrigin() ).Length() ) { //Tell the sensor it's been hit pSensor->Baited( GetOwner() ); //If we're suppressing the call to antlions, then don't make a bugbait sound if ( pSensor->SuppressCall() ) { suppressCall = true; } } } } //Make sure we want to call antlions if ( suppressCall == false ) { //Alert any antlions around CSoundEnt::InsertSound( SOUND_BUGBAIT, GetAbsOrigin(), bugbait_hear_radius.GetInt(), bugbait_distract_time.GetFloat(), GetOwner() ); } //Go away UTIL_Remove( this ); }
void CGrenadeEnergy::Detonate(void) { m_takedamage = DAMAGE_NO; UTIL_Remove( this ); }
void CC4::PrimaryAttack() { bool PlaceBomb = false; CCSPlayer *pPlayer = GetPlayerOwner(); int onGround = FBitSet( pPlayer->GetFlags(), FL_ONGROUND ); if( m_bStartedArming == false ) { if( pPlayer->m_bInBombZone && onGround ) { m_bStartedArming = true; m_fArmedTime = gpGlobals->curtime + WEAPON_C4_ARM_TIME; m_bBombPlacedAnimation = false; //SendWeaponAnim( C4_ARM, UseDecrement() ? 1: 0 ); #if !defined( CLIENT_DLL ) // freeze the player in place while planting pPlayer->SetMaxSpeed( 1 ); // player "arming bomb" animation pPlayer->SetAnimation( PLAYER_ATTACK1 ); pPlayer->SetProgressBarTime( 3 ); #endif } else { if ( !pPlayer->m_bInBombZone ) { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_At_Bomb_Spot"); } else { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground"); } m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; return; } } else { if ( !onGround || !pPlayer->m_bInBombZone ) { if( !pPlayer->m_bInBombZone ) { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Arming_Cancelled" ); } else { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground" ); } m_flNextPrimaryAttack = gpGlobals->curtime + 1.5; m_bStartedArming = false; #if !defined( CLIENT_DLL ) // release the player from being frozen, we've somehow left the bomb zone pPlayer->ResetMaxSpeed(); pPlayer->SetProgressBarTime( 0 ); //pPlayer->SetAnimation( PLAYER_HOLDBOMB ); #endif /* if(m_bBombPlacedAnimation == true) //this means the placement animation is canceled { SendWeaponAnim( C4_DRAW, UseDecrement() ? 1: 0 ); } else { SendWeaponAnim( C4_IDLE1, UseDecrement() ? 1: 0 ); } */ return; } else { if( gpGlobals->curtime >= m_fArmedTime ) //the c4 is ready to be armed { //check to make sure the player is still in the bomb target area PlaceBomb = true; } else if( ( gpGlobals->curtime >= (m_fArmedTime - 0.75) ) && ( !m_bBombPlacedAnimation ) ) { //call the c4 Placement animation m_bBombPlacedAnimation = true; //SendWeaponAnim( C4_DROP, UseDecrement() ? 1: 0 ); #if !defined( CLIENT_DLL ) // player "place" animation //pPlayer->SetAnimation( PLAYER_HOLDBOMB ); #endif } } } if ( PlaceBomb && m_bStartedArming ) { m_bStartedArming = false; m_fArmedTime = 0; if( pPlayer->m_bInBombZone ) { #if !defined( CLIENT_DLL ) //Broadcast("BOMBPL"); CPlantedC4::ShootSatchelCharge( pPlayer, pPlayer->GetAbsOrigin(), QAngle(0,0,0) ); // send director message, that something important happened here /* MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR ); WRITE_BYTE ( 9 ); // command length in bytes WRITE_BYTE ( DRC_CMD_EVENT ); // bomb placed WRITE_SHORT( ENTINDEX(pPlayer->edict()) ); WRITE_SHORT( 0 ); WRITE_LONG( 11 | DRC_FLAG_FACEPLAYER ); // eventflags (priority and flags) MESSAGE_END(); */ // tell the Ts the bomb has been planted (on radar) CTeam *pTeam = GetGlobalTeam( TEAM_TERRORIST ); for ( int iPlayer=0; iPlayer < pTeam->GetNumPlayers(); iPlayer++ ) { CBasePlayer *pTempPlayer = pTeam->GetPlayer( iPlayer ); if ( pTempPlayer->m_lifeState != LIFE_DEAD ) { /* MESSAGE_BEGIN( MSG_ONE, gmsgBombDrop, NULL, pTempPlayer->pev ); WRITE_COORD( pBomb->pev->origin.x ); WRITE_COORD( pBomb->pev->origin.y ); WRITE_COORD( pBomb->pev->origin.z ); WRITE_BYTE( 1 ); // bomb was planted MESSAGE_END(); */ } } UTIL_ClientPrintAll( HUD_PRINTCENTER,"#Bomb_Planted" ); pPlayer->SetProgressBarTime( 0 ); // tell bots the bomb has been planted //g_pBotControl->OnEvent( EVENT_BOMB_PLANTED, pPlayer ); CSGameRules()->m_bBombDropped = false; // Play the plant sound. CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "c4.plant" ); // release the player from being frozen pPlayer->ResetMaxSpeed(); // Remove the C4 icon from the HUD //pPlayer->SetBombIcon(); // No more c4! pPlayer->Weapon_Drop( this, NULL, NULL ); UTIL_Remove( this ); #endif return; } else { ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Activated_At_Bomb_Spot" ); #if !defined( CLIENT_DLL ) //pPlayer->SetAnimation( PLAYER_HOLDBOMB ); // release the player from being frozen pPlayer->ResetMaxSpeed(); #endif m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; return; } } m_flNextPrimaryAttack = gpGlobals->curtime + 0.3; m_flTimeWeaponIdle = gpGlobals->curtime + random->RandomFloat ( 10, 15 ); }
//----------------------------------------------------------------------------- // 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 float ENTITYFLAME_MOVE_AWAY_DIST = 24.0f; // 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 ); }
static int luasrc_UTIL_Remove (lua_State *L) { UTIL_Remove(luaL_checkentity(L, 1)); return 0; }
//----------------------------------------------------------------------------- // Purpose: // Input : &data - //----------------------------------------------------------------------------- void CItem_AmmoCrate::InputKill( inputdata_t &data ) { UTIL_Remove( this ); }
void CControllerHeadBall :: DieThink( void ) { UTIL_Remove( this ); }
void CSqueakGrenade::HuntThink( void ) { // ALERT( at_console, "think\n" ); if (!IsInWorld()) { SetTouch( NULL ); UTIL_Remove( this ); return; } StudioFrameAdvance( ); pev->nextthink = gpGlobals->time + 0.1; // explode when ready if (gpGlobals->time >= m_flDie) { g_vecAttackDir = pev->velocity.Normalize( ); pev->health = -1; Killed( pev, 0 ); return; } // float if (pev->waterlevel != 0) { if (pev->movetype == MOVETYPE_BOUNCE) { pev->movetype = MOVETYPE_FLY; } pev->velocity = pev->velocity * 0.9; pev->velocity.z += 8.0; } else if (pev->movetype = MOVETYPE_FLY) { pev->movetype = MOVETYPE_BOUNCE; } // return if not time to hunt if (m_flNextHunt > gpGlobals->time) return; m_flNextHunt = gpGlobals->time + 2.0; CBaseEntity *pOther = NULL; Vector vecDir; TraceResult tr; Vector vecFlat = pev->velocity; vecFlat.z = 0; vecFlat = vecFlat.Normalize( ); UTIL_MakeVectors( pev->angles ); if (m_hEnemy == NULL || !m_hEnemy->IsAlive()) { // find target, bounce a bit towards it. Look( 512 ); m_hEnemy = BestVisibleEnemy( ); } // squeek if it's about time blow up if ((m_flDie - gpGlobals->time <= 0.5) && (m_flDie - gpGlobals->time >= 0.3)) { EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_die1.wav", 1, ATTN_NORM, 0, 100 + RANDOM_LONG(0,0x3F)); CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 256, 0.25 ); } // higher pitch as squeeker gets closer to detonation time float flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY); if (flpitch < 80) flpitch = 80; if (m_hEnemy != NULL) { if (FVisible( m_hEnemy )) { vecDir = m_hEnemy->EyePosition() - pev->origin; m_vecTarget = vecDir.Normalize( ); } float flVel = pev->velocity.Length(); float flAdj = 50.0 / (flVel + 10.0); if (flAdj > 1.2) flAdj = 1.2; // ALERT( at_console, "think : enemy\n"); // ALERT( at_console, "%.0f %.2f %.2f %.2f\n", flVel, m_vecTarget.x, m_vecTarget.y, m_vecTarget.z ); pev->velocity = pev->velocity * flAdj + m_vecTarget * 300; } if (pev->flags & FL_ONGROUND) { pev->avelocity = Vector( 0, 0, 0 ); } else { if (pev->avelocity == Vector( 0, 0, 0)) { pev->avelocity.x = RANDOM_FLOAT( -100, 100 ); pev->avelocity.z = RANDOM_FLOAT( -100, 100 ); } } if ((pev->origin - m_posPrev).Length() < 1.0) { pev->velocity.x = RANDOM_FLOAT( -100, 100 ); pev->velocity.y = RANDOM_FLOAT( -100, 100 ); } m_posPrev = pev->origin; pev->angles = UTIL_VecToAngles( pev->velocity ); pev->angles.z = 0; pev->angles.x = 0; }
//----------------------------------------------------------------------------- // 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 CRopeAnchor::RemoveThink() { UTIL_Remove( m_hRope ); SetThink( &CRopeAnchor::SUB_Remove ); SetNextThink( gpGlobals->curtime ); }
//========================================================= // CWeaponBox - Touch: try to add my contents to the toucher // if the toucher is a player. //========================================================= void CWeaponBox::Touch( CBaseEntity *pOther ) { if ( !(pev->flags & FL_ONGROUND ) ) { return; } if ( !pOther->IsPlayer() ) { // only players may touch a weaponbox. return; } if ( !pOther->IsAlive() ) { // no dead guys. return; } CBasePlayer *pPlayer = (CBasePlayer *)pOther; int i; // dole out ammo for ( i = 0 ; i < MAX_AMMO_SLOTS ; i++ ) { if ( !FStringNull( m_rgiszAmmo[ i ] ) ) { // there's some ammo of this type. pPlayer->GiveAmmo( m_rgAmmo[ i ], (char *)STRING( m_rgiszAmmo[ i ] ), MaxAmmoCarry( m_rgiszAmmo[ i ] ) ); //ALERT ( at_console, "Gave %d rounds of %s\n", m_rgAmmo[i], STRING(m_rgiszAmmo[i]) ); // now empty the ammo from the weaponbox since we just gave it to the player m_rgiszAmmo[ i ] = iStringNull; m_rgAmmo[ i ] = 0; } } // go through my weapons and try to give the usable ones to the player. // it's important the the player be given ammo first, so the weapons code doesn't refuse // to deploy a better weapon that the player may pick up because he has no ammo for it. for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) { if ( m_rgpPlayerItems[ i ] ) { CBasePlayerItem *pItem; // have at least one weapon in this slot while ( m_rgpPlayerItems[ i ] ) { //ALERT ( at_console, "trying to give %s\n", STRING( m_rgpPlayerItems[ i ]->pev->classname ) ); pItem = m_rgpPlayerItems[ i ]; m_rgpPlayerItems[ i ] = m_rgpPlayerItems[ i ]->m_pNext;// unlink this weapon from the box if ( pPlayer->AddPlayerItem( pItem ) ) { pItem->AttachToPlayer( pPlayer ); } } } } EMIT_SOUND( pOther->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM ); SetTouch(NULL); UTIL_Remove(this); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CGrenadeBugBait::BugBaitTouch( CBaseEntity *pOther ) { // Don't hit triggers or water Assert( pOther ); if ( pOther->IsSolidFlagSet(FSOLID_TRIGGER|FSOLID_VOLUME_CONTENTS) ) return; if ( m_pSporeTrail != NULL ) { m_pSporeTrail->m_bEmit = false; } //Do effect for the hit SporeExplosion *pSporeExplosion = SporeExplosion::CreateSporeExplosion(); if ( pSporeExplosion ) { Vector dir = -GetAbsVelocity(); VectorNormalize( dir ); QAngle angles; VectorAngles( dir, angles ); pSporeExplosion->SetLocalAngles( angles ); pSporeExplosion->SetLocalOrigin( GetAbsOrigin() ); pSporeExplosion->m_flSpawnRate = 8.0f; pSporeExplosion->m_flParticleLifetime = 2.0f; pSporeExplosion->SetRenderColor( 0.0f, 0.5f, 0.25f ); pSporeExplosion->SetRenderAlpha( 0.15f ); pSporeExplosion->m_flStartSize = 32.0f; pSporeExplosion->m_flEndSize = 64.0f; pSporeExplosion->m_flSpawnRadius = 32.0f; pSporeExplosion->SetLifetime( bugbait_distract_time.GetFloat() ); } trace_t tr; Vector traceDir = GetAbsVelocity(); VectorNormalize( traceDir ); UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + traceDir * 64, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction < 1.0f ) { UTIL_DecalTrace( &tr, "BeerSplash" ); //TODO: Use real decal } //Make a splat sound CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "GrenadeBugBait.Splat" ); //Make sure we want to call antlions if ( ActivateBugbaitTargets( GetThrower(), GetAbsOrigin(), false ) == false ) { //Alert any antlions around CSoundEnt::InsertSound( SOUND_BUGBAIT, GetAbsOrigin(), bugbait_hear_radius.GetInt(), bugbait_distract_time.GetFloat(), GetThrower() ); } // Tell all spawners to now fight to this position g_AntlionMakerManager.BroadcastFightGoal( GetAbsOrigin() ); //Go away UTIL_Remove( this ); }
int CZombie :: RealTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { if ( bitsDamageType & (DMG_RADIATION | DMG_BLIND | DMG_NERVEGAS | DMG_DROWN) ) { flDamage = 0; return 0; } if (m_fEndfrozen) flDamage *= 2; if (bitsDamageType &(DMG_BLAST | DMG_NUKE | DMG_ENERGYBLAST | DMG_CRUSH)) flDamage = flDamage*1.5; if (bitsDamageType & (DMG_SONIC | DMG_PLASMA)) flDamage = flDamage*1.2; if (bitsDamageType &(DMG_SHOCK | DMG_IGNITE | DMG_BURN | DMG_ENERGYBEAM | DMG_GENERIC)) flDamage = flDamage*1; if (bitsDamageType &(DMG_SLASH | DMG_ACID)) flDamage = flDamage*0.6; if (bitsDamageType &( DMG_BULLET | DMG_BULLETMAGNUM | DMG_BULLETBUCKSHOT | DMG_FREEZE)) flDamage = flDamage*0.4; if (bitsDamageType &(DMG_POISON)) flDamage = flDamage*0.2; if ( IsAlive() && gpGlobals->time >= m_flNextPain && !m_fEndfrozen ) { PainSound(); m_flNextPain = gpGlobals->time + 5; } if ( (bitsDamageType &(DMG_BLAST) || m_fEndfrozen) && flDamage >= pev->health ) { FX_PlrGib( pev->origin, (m_iInjuryType&DAMAGE_DESTROY_FLESH)?(GIBBED_IGNITE):((m_fEndfrozen)?GIBBED_FROZEN:GIBBED_BODY)); UTIL_Remove(this); return 0; } if ( (bitsDamageType &(DMG_SHOCK | DMG_ENERGYBLAST)) && flDamage >= pev->health) { FX_PlrGib( pev->origin, GIBBED_ELECTRO); UTIL_Remove(this); return 0; } if ( (bitsDamageType &(DMG_PLASMA | DMG_NUKE | DMG_ENERGYBEAM | DMG_IGNITE)) && flDamage >= pev->health) { FX_PlrGib( pev->origin, GIBBED_IGNITE); UTIL_Remove(this); return 0; } else if ((bitsDamageType &(DMG_ACID)) && flDamage >= pev->health) { if (m_iInjuryType & DAMAGE_BLOW_HEAD) SetBodygroup(BODYGROUP_BODY, SUBMDL_BODY_SKELETON_NOSKULL); else SetBodygroup(BODYGROUP_BODY, SUBMDL_BODY_SKELETON); m_iInjuryType |= DAMAGE_DESTROY_FLESH; return 0; } if (!pev->takedamage) return 0; if (bitsDamageType & DMG_FREEZE) { IgniteEnd(); FrozenStart(); } if (bitsDamageType & DMG_IGNITE) { FrozenEnd(); IgniteStart(); } return CBaseMonster::RealTakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); }
//----------------------------------------------------------------------------- // Purpose: // Input : *pOther - //----------------------------------------------------------------------------- void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) { if ( !pOther->IsSolid() || pOther->IsSolidFlagSet(FSOLID_VOLUME_CONTENTS) ) return; if ( pOther->m_takedamage != DAMAGE_NO ) { trace_t tr, tr2; tr = BaseClass::GetTouchTrace(); Vector vecNormalizedVel = GetAbsVelocity(); ClearMultiDamage(); VectorNormalize( vecNormalizedVel ); if( GetOwnerEntity() && GetOwnerEntity()->IsPlayer() && pOther->IsNPC() ) { CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), m_iDamage, DMG_NEVERGIB ); dmgInfo.AdjustPlayerDamageInflictedForSkillLevel(); CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f ); dmgInfo.SetDamagePosition( tr.endpos ); pOther->DispatchTraceAttack( dmgInfo, vecNormalizedVel, &tr ); } else { CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), m_iDamage, DMG_BULLET | DMG_NEVERGIB ); CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f ); dmgInfo.SetDamagePosition( tr.endpos ); pOther->DispatchTraceAttack( dmgInfo, vecNormalizedVel, &tr ); } ApplyMultiDamage(); //Adrian: keep going through the glass. if ( pOther->GetCollisionGroup() == COLLISION_GROUP_BREAKABLE_GLASS ) return; SetAbsVelocity( Vector( 0, 0, 0 ) ); // play body "thwack" sound EmitSound( "Weapon_Crossbow.BoltHitBody" ); Vector vForward; AngleVectors( GetAbsAngles(), &vForward ); VectorNormalize ( vForward ); UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + vForward * 128, MASK_OPAQUE, pOther, COLLISION_GROUP_NONE, &tr2 ); if ( tr2.fraction != 1.0f ) { // NDebugOverlay::Box( tr2.endpos, Vector( -16, -16, -16 ), Vector( 16, 16, 16 ), 0, 255, 0, 0, 10 ); // NDebugOverlay::Box( GetAbsOrigin(), Vector( -16, -16, -16 ), Vector( 16, 16, 16 ), 0, 0, 255, 0, 10 ); if ( tr2.m_pEnt == NULL || ( tr2.m_pEnt && tr2.m_pEnt->GetMoveType() == MOVETYPE_NONE ) ) { CEffectData data; data.m_vOrigin = tr2.endpos; data.m_vNormal = vForward; data.m_nEntIndex = tr2.fraction != 1.0f; DispatchEffect( "BoltImpact", data ); } } SetTouch( NULL ); SetThink( NULL ); UTIL_Remove( this ); } else { trace_t tr; tr = BaseClass::GetTouchTrace(); // See if we struck the world if ( pOther->GetMoveType() == MOVETYPE_NONE && !( tr.surface.flags & SURF_SKY ) ) { EmitSound( "Weapon_Crossbow.BoltHitWorld" ); // if what we hit is static architecture, can stay around for a while. Vector vecDir = GetAbsVelocity(); float speed = VectorNormalize( vecDir ); // See if we should reflect off this surface float hitDot = DotProduct( tr.plane.normal, -vecDir ); if ( ( hitDot < 0.5f ) && ( speed > 100 ) ) { Vector vReflection = 2.0f * tr.plane.normal * hitDot + vecDir; QAngle reflectAngles; VectorAngles( vReflection, reflectAngles ); SetLocalAngles( reflectAngles ); SetAbsVelocity( vReflection * speed * 0.75f ); // Start to sink faster SetGravity( 1.0f ); } else { SetThink( &CCrossbowBolt::SUB_Remove ); SetNextThink( gpGlobals->curtime + 2.0f ); //FIXME: We actually want to stick (with hierarchy) to what we've hit SetMoveType( MOVETYPE_NONE ); Vector vForward; AngleVectors( GetAbsAngles(), &vForward ); VectorNormalize ( vForward ); CEffectData data; data.m_vOrigin = tr.endpos; data.m_vNormal = vForward; data.m_nEntIndex = 0; DispatchEffect( "BoltImpact", data ); UTIL_ImpactTrace( &tr, DMG_BULLET ); AddEffects( EF_NODRAW ); SetTouch( NULL ); SetThink( &CCrossbowBolt::SUB_Remove ); SetNextThink( gpGlobals->curtime + 2.0f ); if ( m_pGlowSprite != NULL ) { m_pGlowSprite->TurnOn(); m_pGlowSprite->FadeAndDie( 3.0f ); } } // Shoot some sparks if ( UTIL_PointContents( GetAbsOrigin() ) != CONTENTS_WATER) { g_pEffects->Sparks( GetAbsOrigin() ); } } else { // Put a mark unless we've hit the sky if ( ( tr.surface.flags & SURF_SKY ) == false ) { UTIL_ImpactTrace( &tr, DMG_BULLET ); } UTIL_Remove( this ); } } if ( g_pGameRules->IsMultiplayer() ) { // SetThink( &CCrossbowBolt::ExplodeThink ); // SetNextThink( gpGlobals->curtime + 0.1f ); } }
//----------------------------------------------------------------------------- // Purpose: // Input : &data - //----------------------------------------------------------------------------- void CItem_DynamicResupply::InputKill( inputdata_t &data ) { UTIL_Remove( this ); }
void CPlantedC4::C4Think() { if (!IsInWorld()) { UTIL_Remove( this ); return; } SetNextThink( gpGlobals->curtime + 0.12 ); if ( gpGlobals->curtime >= m_flNextFreq ) { m_flNextFreq = gpGlobals->curtime + m_flNextFreqInterval; m_flNextFreqInterval *= 0.9; m_iCurWave = clamp( m_iCurWave+1, 0, 5 ); } if ( gpGlobals->curtime >= m_flNextBeep ) { m_flNextBeep = gpGlobals->curtime + 1.4; // Play a beep sound. char soundName[64]; Q_snprintf( soundName, sizeof( soundName ), "c4.beep%d", m_iCurWave ); CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), soundName ); // let the bots hear the bomb beeping //g_pBotControl->OnEvent( EVENT_BOMB_BEEP, this ); } if(gpGlobals->curtime >= m_flNextBlink)//added by SupraFiend to improve Bomb visibility { m_flNextBlink = gpGlobals->curtime + BLINK_INTERVAL; Vector vPos = GetAbsOrigin(); vPos.z += 5; CPVSFilter filter( GetAbsOrigin() ); te->GlowSprite( filter, 0, &vPos, g_sModelIndexC4Glow, 1, 0.5, 255 ); } // IF the timer has expired ! blow this bomb up! if (m_flC4Blow <= gpGlobals->curtime) { // let the bots hear the bomb exploding //g_pBotControl->OnEvent( EVENT_BOMB_EXPLODED ); // Tell the bomb target brush to trigger its targets //MIKETODO: use entity IO? /* if ( m_pentCurBombTarget ) { CBaseEntity* pBombTarget = CBaseEntity::Instance( m_pentCurBombTarget ); if ( pBombTarget ) pBombTarget->Use( CBaseEntity::Instance( pev->owner ), this, USE_TOGGLE, 0 ); } */ // give the defuser credit for defusing the bomb CBasePlayer *pBombOwner = dynamic_cast< CBasePlayer* >( GetOwnerEntity() ); if ( pBombOwner ) { pBombOwner->IncrementFragCount( 3 ); } CSGameRules()->m_bBombDropped = false; if (GetWaterLevel() == 0) SetThink ( &CPlantedC4::Detonate2 ); else UTIL_Remove (this); // Get rid of this thing if it's underwater.. } //if the defusing process has started if ((m_bStartDefuse == true) && (m_pBombDefuser != NULL)) { //if the defusing process has not ended yet if ( m_flDefuseCountDown > gpGlobals->curtime) { int iOnGround = FBitSet( m_pBombDefuser->GetFlags(), FL_ONGROUND ); //if the bomb defuser has stopped defusing the bomb if( m_fNextDefuse < gpGlobals->curtime || !iOnGround ) { if ( !iOnGround ) ClientPrint( m_pBombDefuser, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground"); // release the player from being frozen m_pBombDefuser->ResetMaxSpeed(); m_pBombDefuser->m_bIsDefusing = false; //cancel the progress bar m_pBombDefuser->SetProgressBarTime( 0 ); m_pBombDefuser = NULL; m_bStartDefuse = false; m_flDefuseCountDown = 0; // tell the bots someone has aborted defusing //g_pBotControl->OnEvent( EVENT_BOMB_DEFUSE_ABORTED ); } return; } //if the defuse process has ended, kill the c4 else if ( !m_pBombDefuser->IsDead() ) { // tell the bots the bomb is defused //g_pBotControl->OnEvent( EVENT_BOMB_DEFUSED ); //MIKETODO: spectator /* // Broadcast to the entire server Broadcast( "BOMBDEF" ); // send director message, that something important happened here MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR ); WRITE_BYTE ( 9 ); WRITE_BYTE ( DRC_CMD_EVENT ); // bomb defuse WRITE_SHORT( ENTINDEX( m_pBombDefuser->edict() )); // index number of secondary entity WRITE_SHORT( 0 ); // index number of secondary entity WRITE_LONG( 15 | DRC_FLAG_DRAMATIC | DRC_FLAG_FINAL | DRC_FLAG_FACEPLAYER ); // eventflags (priority and flags) MESSAGE_END(); */ CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "c4.disarmed" ); UTIL_Remove(this); // The bomb has just been disarmed.. Check to see if the round should end now m_bJustBlew = true; // release the player from being frozen m_pBombDefuser->ResetMaxSpeed(); m_pBombDefuser->m_bIsDefusing = false; CSGameRules()->m_bBombDefused = true; CSGameRules()->CheckWinConditions(); // give the defuser credit for defusing the bomb m_pBombDefuser->IncrementFragCount( 3 ); CSGameRules()->m_bBombDropped = false; // Clear their progress bar. m_pBombDefuser->SetProgressBarTime( 0 ); m_pBombDefuser = NULL; m_bStartDefuse = false; return; } //if it gets here then the previouse defuser has taken off or been killed // release the player from being frozen m_pBombDefuser->ResetMaxSpeed(); m_pBombDefuser->m_bIsDefusing = false; m_bStartDefuse = false; m_pBombDefuser = NULL; // tell the bots someone has aborted defusing //g_pBotControl->OnEvent( EVENT_BOMB_DEFUSE_ABORTED ); } }
void CBaseDelay :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ) { // // exit immediatly if we don't have a target or kill target // if (FStringNull(pev->target) && !m_iszKillTarget) return; // // check for a delay // if (m_flDelay != 0) { // create a temp object to fire at a later time CBaseDelay *pTemp = GetClassPtr( (CBaseDelay *)NULL); pTemp->pev->classname = MAKE_STRING("DelayedUse"); pTemp->pev->nextthink = gpGlobals->time + m_flDelay; pTemp->SetThink( DelayThink ); // Save the useType pTemp->pev->button = (int)useType; pTemp->m_iszKillTarget = m_iszKillTarget; pTemp->m_flDelay = 0; // prevent "recursion" pTemp->pev->target = pev->target; // HACKHACK // This wasn't in the release build of Half-Life. We should have moved m_hActivator into this class // but changing member variable hierarchy would break save/restore without some ugly code. // This code is not as ugly as that code if ( pActivator && pActivator->IsPlayer() ) // If a player activates, then save it { pTemp->pev->owner = pActivator->edict(); } else { pTemp->pev->owner = NULL; } return; } // // kill the killtargets // if ( m_iszKillTarget ) { edict_t *pentKillTarget = NULL; ALERT( at_aiconsole, "KillTarget: %s\n", STRING(m_iszKillTarget) ); pentKillTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_iszKillTarget) ); while ( !FNullEnt(pentKillTarget) ) { UTIL_Remove( CBaseEntity::Instance(pentKillTarget) ); ALERT( at_aiconsole, "killing %s\n", STRING( pentKillTarget->v.classname ) ); pentKillTarget = FIND_ENTITY_BY_TARGETNAME( pentKillTarget, STRING(m_iszKillTarget) ); } } // // fire targets // if (!FStringNull(pev->target)) { FireTargets( STRING(pev->target), pActivator, this, useType, value ); } }
IASW_Spawnable_NPC* CASW_Base_Spawner::SpawnAlien( const char *szAlienClassName, const Vector &vecHullMins, const Vector &vecHullMaxs ) { if ( !IsValidOnThisSkillLevel() ) { UTIL_Remove(this); // delete ourself if this spawner isn't valid on this difficulty level return NULL; } if ( !CanSpawn( vecHullMins, vecHullMaxs ) ) // this may turn off m_bCurrentlySpawningUber if there's no room return NULL; CBaseEntity *pEntity = CreateEntityByName( szAlienClassName ); if ( !pEntity ) { Msg( "Failed to spawn %s\n", szAlienClassName ); return NULL; } CAI_BaseNPC *pNPC = pEntity->MyNPCPointer(); if ( pNPC ) { pNPC->AddSpawnFlags( SF_NPC_FALL_TO_GROUND ); } // check if he can see far if ( m_bLongRangeNPC ) pEntity->AddSpawnFlags( SF_NPC_LONG_RANGE ); if ( HasSpawnFlags( ASW_SF_NEVER_SLEEP ) ) pEntity->AddSpawnFlags( SF_NPC_ALWAYSTHINK ); // Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC. QAngle angles = GetAbsAngles(); angles.x = 0.0; angles.z = 0.0; pEntity->SetAbsOrigin( GetAbsOrigin() ); pEntity->SetAbsAngles( angles ); IASW_Spawnable_NPC* pSpawnable = dynamic_cast<IASW_Spawnable_NPC*>(pEntity); Assert( pSpawnable ); if ( !pSpawnable ) { Warning( "NULL Spawnable Ent in asw_spawner! AlienClass = %s\n", szAlienClassName ); UTIL_Remove( pEntity ); return NULL; } m_flLastSpawnTime = gpGlobals->curtime; if ( m_bStartBurrowed ) { pSpawnable->StartBurrowed(); } if ( m_bStartBurrowed ) { pSpawnable->SetUnburrowIdleActivity( m_UnburrowIdleActivity ); pSpawnable->SetUnburrowActivity( m_UnburrowActivity ); } DispatchSpawn( pEntity ); pEntity->SetOwnerEntity( this ); pEntity->Activate(); if ( m_AlienName != NULL_STRING ) { pEntity->SetName( m_AlienName ); } pSpawnable->SetSpawner( this ); RemoveObstructingProps( pEntity ); // give our aliens the orders pSpawnable->SetAlienOrders( m_AlienOrders, vec3_origin, GetOrderTarget() ); m_OnSpawned.FireOutput(pEntity, this); return pSpawnable; }