void CTFOClassnameFinder::FindTarget( inputdata_t &inputdata ) { bool bFound = false; CBaseEntity *pMyFoundEnt = NULL; // Try classname pMyFoundEnt = gEntList.FindEntityByClassname( NULL, szTarget.ToCStr() ); while ( pMyFoundEnt ) { if ( !strcmp( pMyFoundEnt->GetClassname(), szTarget.ToCStr() ) ) { pFoundTarget.FireOutput( this, this ); bFound = true; break; } pMyFoundEnt = gEntList.FindEntityByClassname( pMyFoundEnt, szTarget.ToCStr() ); } if ( bFound ) return; // Try the actual name pMyFoundEnt = gEntList.FindEntityByName( NULL, szTarget.ToCStr() ); while ( pMyFoundEnt ) { if ( !strcmp( pMyFoundEnt->GetEntityName().ToCStr(), szTarget.ToCStr() ) ) { pFoundTarget.FireOutput( this, this ); break; } pMyFoundEnt = gEntList.FindEntityByName( pMyFoundEnt, szTarget.ToCStr() ); } }
//----------------------------------------------------------------------------- // Purpose: Every second, check total stress and fire an output if we have reached // our threshold. If the stress is relieved below our threshold, fire a different output. //----------------------------------------------------------------------------- void CWeightButton::TriggerThink( void ) { vphysics_objectstress_t vpobj_StressOut; IPhysicsObject* pMyPhysics = VPhysicsGetObject(); if ( !pMyPhysics ) { SetNextThink( TICK_NEVER_THINK ); return; } float fStress = CalculateObjectStress( pMyPhysics, this, &vpobj_StressOut ); // fStress = vpobj_StressOut.receivedStress; if ( fStress > m_fStressToActivate && !m_bHasBeenPressed ) { m_OnPressed.FireOutput( this, this ); m_bHasBeenPressed = true; } else if ( fStress < m_fStressToActivate && m_bHasBeenPressed ) { m_OnReleased.FireOutput( this, this ); m_bHasBeenPressed = false; } // think every tick SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); }
//----------------------------------------------------------------------------- // Purpose: Called shortly after level spawn. Checks the global state and fires // targets if the global state is set or if there is not global state // to check. //----------------------------------------------------------------------------- void CLogicAuto::Think(void) { if (!m_globalstate || GlobalEntity_GetState(m_globalstate) == GLOBAL_ON) { if (gpGlobals->eLoadType == MapLoad_Transition) { m_OnMapTransition.FireOutput(NULL, this); } else if (gpGlobals->eLoadType == MapLoad_NewGame) { m_OnNewGame.FireOutput(NULL, this); } else if (gpGlobals->eLoadType == MapLoad_LoadGame) { m_OnLoadGame.FireOutput(NULL, this); } else if (gpGlobals->eLoadType == MapLoad_Background) { m_OnBackgroundMap.FireOutput(NULL, this); } m_OnMapSpawn.FireOutput(NULL, this); if (m_spawnflags & SF_AUTO_FIREONCE) { UTIL_Remove(this); } } }
//------------------------------------------------------------------------------ // Purpose : //------------------------------------------------------------------------------ void CNPC_Launcher::LauncherThink( void ) { if (gpGlobals->curtime > m_flNextAttack) { // If enemy was set, fire at enemy if (GetEnemy()) { LaunchGrenade(GetEnemy()); m_OnLaunch.FireOutput(GetEnemy(), this); m_flNextAttack = gpGlobals->curtime + m_nLaunchDelay; } // Otherwise look for enemy to fire at else { GetSenses()->Look((int)m_flMaxAttackDist); CBaseEntity* pBestEnemy = BestEnemy(); if (pBestEnemy) { LaunchGrenade(pBestEnemy); m_OnLaunch.FireOutput(pBestEnemy, this); m_flNextAttack = gpGlobals->curtime + m_nLaunchDelay; } } } SetNextThink( gpGlobals->curtime + 0.1f ); }
//----------------------------------------------------------------------------- // Purpose: // Input : &info - //----------------------------------------------------------------------------- void CAntlionGrub::Event_Killed( const CTakeDamageInfo &info ) { // Fire our output only if the player is the one that killed us if ( info.GetAttacker() && info.GetAttacker()->IsPlayer() ) { m_OnDeathByPlayer.FireOutput( info.GetAttacker(), info.GetAttacker() ); } m_OnDeath.FireOutput( info.GetAttacker(), info.GetAttacker() ); SendOnKilledGameEvent( info ); // Crush and crowbar damage hurt us more than others bool bSquashed = ( info.GetDamageType() & (DMG_CRUSH|DMG_CLUB)) ? true : false; Squash( info.GetAttacker(), false, bSquashed ); m_takedamage = DAMAGE_NO; if ( sk_grubnugget_enabled.GetBool() ) { CreateNugget(); } // Go away SetThink( &CBaseEntity::SUB_Remove ); SetNextThink( gpGlobals->curtime + 0.1f ); // we deliberately do not call BaseClass::EventKilled }
//----------------------------------------------------------------------------- // Purpose: Dissolve all weapons within our volume //----------------------------------------------------------------------------- void CTriggerWeaponDissolve::DissolveThink( void ) { int numWeapons = m_pWeapons.Count(); // Dissolve all the items within the volume for ( int i = 0; i < numWeapons; i++ ) { CBaseCombatWeapon *pWeapon = m_pWeapons[i]; Vector vecConduit = GetConduitPoint( pWeapon ); // The physcannon upgrades when this happens if ( FClassnameIs( pWeapon, "weapon_physcannon" ) ) { // This must be the last weapon for us to care if ( numWeapons > 1 ) continue; //FIXME: Make them do this on a stagger! // All conduits send power to the weapon for ( int i = 0; i < m_pConduitPoints.Count(); i++ ) { CreateBeam( m_pConduitPoints[i]->GetAbsOrigin(), pWeapon, 4.0f ); } PhysCannonBeginUpgrade( pWeapon ); m_OnChargingPhyscannon.FireOutput( this, this ); EmitSound( "WeaponDissolve.Beam" ); // We're done m_pWeapons.Purge(); m_pConduitPoints.Purge(); SetContextThink( NULL, 0, s_pDissolveThinkContext ); return; } // Randomly dissolve them all float flLifetime = random->RandomFloat( 2.5f, 4.0f ); CreateBeam( vecConduit, pWeapon, flLifetime ); pWeapon->Dissolve( NULL, gpGlobals->curtime + ( 3.0f - flLifetime ), false ); m_OnDissolveWeapon.FireOutput( this, this ); CPASAttenuationFilter filter( pWeapon ); EmitSound( filter, pWeapon->entindex(), "WeaponDissolve.Dissolve" ); // Beam looping sound EmitSound( "WeaponDissolve.Beam" ); m_pWeapons.Remove( i ); SetContextThink( &CTriggerWeaponDissolve::DissolveThink, gpGlobals->curtime + random->RandomFloat( 0.5f, 1.5f ), s_pDissolveThinkContext ); return; } SetContextThink( &CTriggerWeaponDissolve::DissolveThink, gpGlobals->curtime + 0.1f, s_pDissolveThinkContext ); }
//----------------------------------------------------------------------------- // Purpose: Input handler for forcing an instantaneous test of the condition. //----------------------------------------------------------------------------- void CPointAngleSensor::InputTest(inputdata_t &inputdata) { if (IsFacingWithinTolerance(m_hTargetEntity, m_hLookAtEntity, m_flDotTolerance)) { m_OnFacingLookat.FireOutput(inputdata.pActivator, this); } else { m_OnNotFacingLookat.FireOutput(inputdata.pActivator, this); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropVehiclePrisonerPod::HandleAnimEvent( animevent_t *pEvent ) { if ( pEvent->event == AE_POD_OPEN ) { m_OnOpen.FireOutput( this, this ); m_bLocked = false; } else if ( pEvent->event == AE_POD_CLOSE ) { m_OnClose.FireOutput( this, this ); m_bLocked = true; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropVehicleChoreoGeneric::HandleAnimEvent( animevent_t *pEvent ) { if ( pEvent->event == AE_CHOREO_VEHICLE_OPEN ) { m_OnOpen.FireOutput( this, this ); m_bLocked = false; } else if ( pEvent->event == AE_CHOREO_VEHICLE_CLOSE ) { m_OnClose.FireOutput( this, this ); m_bLocked = true; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CCommentaryAuto::Think(void) { if ( g_CommentarySystem.CommentaryWasEnabledMidGame() ) { m_OnCommentaryMidGame.FireOutput(NULL, this); } else { m_OnCommentaryNewGame.FireOutput(NULL, this); } UTIL_Remove(this); }
//----------------------------------------------------------------------------- // Purpose: Handle a collision using our special behavior //----------------------------------------------------------------------------- void CWeaponStriderBuster::VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ) { // Find out what we hit. // Don't do anything special if we're already attached to a strider. CBaseEntity *pVictim = pEvent->pEntities[!index]; if ( pVictim == NULL || m_pConstraint != NULL ) { BaseClass::VPhysicsCollision( index, pEvent ); return; } // Don't attach if we're being held by the player if ( VPhysicsGetObject()->GetGameFlags() & FVPHYSICS_PLAYER_HELD ) { BaseClass::VPhysicsCollision( index, pEvent ); return; } // Save off the speed of the object m_flCollisionSpeedSqr = ( pEvent->preVelocity[ index ] ).LengthSqr(); // Break if we hit the world while going fast enough. // Launched duds detonate if they hit the world at any speed. if ( pVictim->IsWorld() && ( ( m_bDud && m_bLaunched ) || m_flCollisionSpeedSqr > Square( 500 ) ) ) { m_OnShatter.FireOutput( this, this ); Shatter( pVictim ); return; } // We'll handle this later in our touch call if ( ShouldStickToEntity( pVictim ) ) return; // Determine if we should shatter CBaseEntity *pOwnerEntity = pVictim->GetOwnerEntity(); bool bVictimIsStrider = ( ( pOwnerEntity != NULL ) && FClassnameIs( pOwnerEntity, "npc_strider" ) ); // Break if we hit anything other than a strider while going fast enough. // Launched duds detonate if they hit anything other than a strider any speed. if ( ( bVictimIsStrider == false ) && ( ( m_bDud && m_bLaunched ) || m_flCollisionSpeedSqr > Square( 500 ) ) ) { m_OnShatter.FireOutput( this, this ); Shatter( pVictim ); return; } // Just bounce BaseClass::VPhysicsCollision( index, pEvent ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponStriderBuster::Detonate( void ) { CBaseEntity *pVictim = GetOwnerEntity(); if ( !m_bDud && pVictim ) { // Kill the strider (with magic effect) CBasePlayer *pPlayer = AI_GetSinglePlayer(); CTakeDamageInfo info( pPlayer, this, RandomVector( -100.0f, 100.0f ), GetAbsOrigin(), pVictim->GetHealth(), DMG_GENERIC ); pVictim->TakeDamage( info ); gamestats->Event_WeaponHit( ToBasePlayer( pPlayer ), true, GetClassname(), info ); // Tracker 62293: There's a bug where the inflictor/attacker are reversed when calling TakeDamage above so the player never gets // credit for the strider buster kills. The code has a bunch of assumptions lower level, so it's safer to just fix it here by // crediting a kill to the player directly. gamestats->Event_PlayerKilledOther( pPlayer, pVictim, info ); } m_OnDetonate.FireOutput( this, this ); // Explode if ( !m_bDud ) { CreateDestroyedEffect(); EmitSound( "Weapon_StriderBuster.Detonate" ); } else { DispatchParticleEffect( "striderbuster_explode_dummy_core", GetAbsOrigin(), GetAbsAngles() ); EmitSound( "Weapon_StriderBuster.Dud_Detonate" ); } // Go to bits! Shatter( pVictim ); }
//----------------------------------------------------------------------------- // Purpose: Check to see if any of our constrained players have broken the constraint //----------------------------------------------------------------------------- void CPointPlayerMoveConstraint::ConstraintThink( void ) { int iCount = m_hConstrainedPlayers.Count(); // Count backwards, because we might drop them if they've broken the constraint for ( int i = (iCount-1); i >= 0; i-- ) { CBasePlayer *pPlayer = ToBasePlayer( m_hConstrainedPlayers[i] ); if ( pPlayer ) { float flDistanceSqr = (pPlayer->GetAbsOrigin() - GetAbsOrigin()).LengthSqr(); if ( flDistanceSqr > m_flRadiusSquared ) { // Break the constraint to this player pPlayer->DeactivateMovementConstraint(); m_hConstrainedPlayers.Remove(i); // Fire the broken output m_OnConstraintBroken.FireOutput( this, pPlayer ); } } } // Only keep thinking if we any left if ( m_hConstrainedPlayers.Count() ) { SetNextThink( gpGlobals->curtime + 0.1f ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropCannon::EnterVehicle( CBaseCombatCharacter *pPassenger ) { if ( pPassenger == NULL ) return; CBasePlayer *pPlayer = ToBasePlayer( pPassenger ); if ( pPlayer != NULL ) { // Remove any player who may be in the vehicle at the moment if ( m_hPlayer ) { ExitVehicle( VEHICLE_ROLE_DRIVER ); } m_hPlayer = pPlayer; m_playerOn.FireOutput( pPlayer, this, 0 ); //m_ServerVehicle.SoundStart(); } else { // NPCs not supported yet - jdw Assert( 0 ); } }
//----------------------------------------------------------------------------- // Purpose: // Input : *player - //----------------------------------------------------------------------------- void CObjectTunnelTrigger::StartTunneling( CBaseTFPlayer *player ) { if ( !player ) return; // Ignore if it's already in the list int c = m_Tunneling.Count(); for ( int i = 0 ; i < c; i++ ) { TunnelPlayer *tp = &m_Tunneling[ i ]; if ( tp->player == player ) { return; } } TunnelPlayer tunnel; tunnel.player = player; tunnel.tunnelstarted = gpGlobals->curtime; tunnel.duration = GetTeleportDuration(); tunnel.teleporttime = tunnel.tunnelstarted + tunnel.duration; tunnel.exitstarted = false; tunnel.startpos = player->GetAbsOrigin(); tunnel.iremaining = (int)tunnel.duration; tunnel.ilastremaining = tunnel.iremaining; tunnel.needremainigcounter = ( tunnel.iremaining > TUNNEL_DURATION_MESSAGE_NEEDED ) ? true : false; // Fade user screen to black color32 black = {0,0,0,255}; float duration = tunnel.duration; float fadeouttime = TUNNEL_FADE_TIME; float holdtime = 0.0f; if ( duration < 2 * TUNNEL_FADE_TIME ) { fadeouttime = duration * 0.5f; } else { fadeouttime = TUNNEL_FADE_TIME; holdtime = duration - 2 * fadeouttime; } tunnel.fadetime = fadeouttime; tunnel.fadeintime = tunnel.tunnelstarted + fadeouttime + holdtime; UTIL_ScreenFade( player, black, fadeouttime, holdtime, FFADE_OUT | FFADE_STAYOUT | FFADE_PURGE ); m_Tunneling.AddToTail( tunnel ); player->SetMoveType( MOVETYPE_NONE ); player->EnableControl( false ); player->AddEffects( EF_NODRAW ); player->AddSolidFlags( FSOLID_NOT_SOLID ); CPASAttenuationFilter filter( player, "ObjectTunnelTrigger.TeleportSound" ); EmitSound( filter, player->entindex(), "ObjectTunnelTrigger.TeleportSound" ); OnTunnelTriggerStart.FireOutput( player, this ); }
//----------------------------------------------------------------------------- // Purpose: Input handler that does the screen fade. //----------------------------------------------------------------------------- void CEnvFade::InputFade( inputdata_t &inputdata ) { int fadeFlags = 0; if ( m_spawnflags & SF_FADE_IN ) { fadeFlags |= FFADE_IN; } else { fadeFlags |= FFADE_OUT; } if ( m_spawnflags & SF_FADE_MODULATE ) { fadeFlags |= FFADE_MODULATE; } if ( m_spawnflags & SF_FADE_ONLYONE ) { if ( inputdata.pActivator->IsNetClient() ) { UTIL_ScreenFade( inputdata.pActivator, m_clrRender, Duration(), HoldTime(), fadeFlags ); } } else { UTIL_ScreenFadeAll( m_clrRender, Duration(), HoldTime(), fadeFlags ); } m_OnBeginFade.FireOutput( inputdata.pActivator, this ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNPC_CraneDriver::RunTask( const Task_t *pTask ) { switch( pTask->iTask ) { case TASK_WAIT_FOR_MOVEMENT: { // Is the magnet over the target, and are we not moving too fast? AngularImpulse angVel; Vector vecVelocity; CBaseEntity *pMagnet = m_hCrane->GetMagnet(); IPhysicsObject *pVehiclePhysics = pMagnet->VPhysicsGetObject(); pVehiclePhysics->GetVelocity( &vecVelocity, &angVel ); float flVelocity = 100; float flDistance = 90; // More accurate on forced drops if ( m_bForcedPickup || m_bForcedDropoff ) { flVelocity = 10; flDistance = 30; } if ( m_flDistanceToTarget < flDistance && m_hCrane->GetTurnRate() < 0.1 && vecVelocity.Length() < flVelocity ) { TaskComplete(); } } break; case TASK_CRANE_DROP_MAGNET: { // Wait for the magnet to get back up if ( m_flDropWait < gpGlobals->curtime && !m_hCrane->IsDropping() ) { TaskComplete(); } } break; case TASK_CRANE_TURN_MAGNET_OFF: { // We're waiting for the pause length before dropping whatever's on our magnet if ( gpGlobals->curtime > m_flReleaseAt ) { if ( m_bForcedDropoff ) { m_OnDroppedObject.FireOutput( this, this ); } m_hCrane->TurnMagnetOff(); TaskComplete(); } } break; default: BaseClass::RunTask( pTask ); break; } }
//----------------------------------------------------------------------------- // Purpose: Called when the train is killed. // Input : pInflictor - What killed us. // pAttacker - Who killed us. // flDamage - The damage that the killing blow inflicted. // bitsDamageType - Bitfield of damage types that were inflicted. //----------------------------------------------------------------------------- void CFuncTankTrain::Event_Killed( const CTakeDamageInfo &info ) { m_takedamage = DAMAGE_NO; m_lifeState = LIFE_DEAD; m_OnDeath.FireOutput( info.GetInflictor(), this ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPointCommentaryNode::CleanupPostCommentary( void ) { CBasePlayer *pPlayer = GetCommentaryPlayer(); if ( !pPlayer ) return; if ( m_hViewPosition.Get() && pPlayer->GetActiveWeapon() ) { pPlayer->GetActiveWeapon()->Deploy(); } if ( m_hViewPositionMover && pPlayer->GetViewEntity() == m_hViewPositionMover ) { pPlayer->SetViewEntity( NULL ); } UTIL_Remove( m_hViewPositionMover ); m_bActive = false; m_flPlaybackRate = 1.0; m_bUnstoppable = false; m_flFinishedTime = 0; SetContextThink( NULL, 0, s_pCommentaryUpdateViewThink ); // Clear out any events waiting on our start commentary g_EventQueue.CancelEvents( this ); m_pOnCommentaryStopped.FireOutput( this, this ); g_CommentarySystem.SetActiveNode( NULL ); }
void CBaseTurret::Deploy(void) { SetNextThink( gpGlobals->curtime + 0.1f ); StudioFrameAdvance( ); if ( m_Activity != ACT_TURRET_OPEN ) { m_iOn = 1; SetActivity( (Activity)ACT_TURRET_OPEN ); EmitSound( "NPC_Turret.Deploy" ); m_OnDeploy.FireOutput(NULL, this); } if (m_fSequenceFinished) { Vector curmins, curmaxs; curmins = WorldAlignMins(); curmaxs = WorldAlignMaxs(); curmaxs.z = m_iDeployHeight; curmins.z = -m_iDeployHeight; SetCollisionBounds( curmins, curmaxs ); Relink(); SetActivity( (Activity)ACT_TURRET_OPEN_IDLE ); m_flPlaybackRate = 0; SetThink(SearchThink); } m_flLastSight = gpGlobals->curtime + m_flMaxWait; }
void CMapAddLabel::Think() { BaseClass::Think(); // Always do this if you override Think() //What this does, is look through entities in a sphere, and then //checks to see if they are valid, and if they are //adds them to a second list of valid entities. //Create an array of CBaseEntity pointers CBaseEntity *ppEnts[256]; int nEntCount = UTIL_EntitiesInSphere( ppEnts, 256, this->GetAbsOrigin(), m_nTriggerArea, 0 ); int i; for ( i = 0; i < nEntCount; i++ ) { //Look through the entities it found if ( ppEnts[i] != NULL ) if(ppEnts[i]->IsPlayer()) { Msg( "mapadd_trig was triggered!\n" ); m_OnTrigger.FireOutput(ppEnts[i],this); // if(m_bDeleteOnFire) // { // SetNextThink( gpGlobals->curtime + 1 ); // Think again in 1 second UTIL_Remove( this ); // } // SetNextThink( gpGlobals->curtime + 1 ); // Think again in 1 second } } SetNextThink( gpGlobals->curtime + 1 ); // Think again in 1 second }
//----------------------------------------------------------------------------- // Creates the explosion effect //----------------------------------------------------------------------------- void CEnvHeadcrabCanister::Detonate( ) { // Send the impact output m_OnImpacted.FireOutput( this, this, 0 ); if ( !HasSpawnFlags( SF_NO_IMPACT_SOUND ) ) { StopSound( "HeadcrabCanister.IncomingSound" ); EmitSound( "HeadcrabCanister.Explosion" ); } // If we're supposed to be removed, do that now if ( HasSpawnFlags( SF_REMOVE_ON_IMPACT ) ) { SetAbsOrigin( m_vecImpactPosition ); SetModel( ENV_HEADCRABCANISTER_BROKEN_MODEL ); SetMoveType( MOVETYPE_NONE ); IncrementInterpolationFrame(); m_bLanded = true; // Become invisible so our trail can finish up AddEffects( EF_NODRAW ); SetSolidFlags( FSOLID_NOT_SOLID ); SetThink( &CEnvHeadcrabCanister::SUB_Remove ); SetNextThink( gpGlobals->curtime + ENV_HEADCRABCANISTER_TRAIL_TIME ); return; } // Test for damaging things TestForCollisionsAgainstWorld( m_vecImpactPosition ); // Shake the screen unless flagged otherwise if ( !HasSpawnFlags( SF_NO_SHAKE ) ) { CBasePlayer *pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin()); // If the player is on foot, then do a more limited shake float shakeRadius = ( pPlayer && pPlayer->IsInAVehicle() ) ? sk_env_headcrabcanister_shake_radius_vehicle.GetFloat() : sk_env_headcrabcanister_shake_radius.GetFloat(); UTIL_ScreenShake( m_vecImpactPosition, sk_env_headcrabcanister_shake_amplitude.GetFloat(), 150.0, 1.0, shakeRadius, SHAKE_START ); } // Do explosion effects if ( !HasSpawnFlags( SF_NO_IMPACT_EFFECTS ) ) { // Normal explosion ExplosionCreate( m_vecImpactPosition, GetAbsAngles(), this, 50.0f, 500.0f, SF_ENVEXPLOSION_NODLIGHTS | SF_ENVEXPLOSION_NOSPARKS | SF_ENVEXPLOSION_NODAMAGE | SF_ENVEXPLOSION_NOSOUND, 1300.0f ); // Dust explosion AR2Explosion *pExplosion = AR2Explosion::CreateAR2Explosion( m_vecImpactPosition ); if( pExplosion ) { pExplosion->SetLifetime(10); } } }
//----------------------------------------------------------------------------- // Purpose: Input handler that converts our target to a physics object. //----------------------------------------------------------------------------- void CPhysConvert::InputConvertTarget( inputdata_t &inputdata ) { bool createAsleep = HasSpawnFlags(SF_CONVERT_ASLEEP); // Fire output m_OnConvert.FireOutput( inputdata.pActivator, this ); CBaseEntity *entlist[512]; CBaseEntity *pSwap = gEntList.FindEntityByName( NULL, m_swapModel, inputdata.pActivator ); CBaseEntity *pEntity = NULL; int count = 0; while ( (pEntity = gEntList.FindEntityByName( pEntity, m_target, inputdata.pActivator )) != NULL ) { entlist[count++] = pEntity; if ( count >= ARRAYSIZE(entlist) ) break; } // if we're swapping to model out, don't loop over more than one object // multiple objects with the same brush model will render, but the dynamic lights // and decals will be shared between the two instances... if ( pSwap && count > 0 ) { count = 1; } for ( int i = 0; i < count; i++ ) { pEntity = entlist[i]; // don't convert something that is already physics based if ( pEntity->GetMoveType() == MOVETYPE_VPHYSICS ) { Msg( "ERROR phys_convert %s ! Already MOVETYPE_VPHYSICS\n", STRING(pEntity->m_iClassname) ); continue; } UnlinkFromParent( pEntity ); if ( pSwap ) { // we can't reuse this physics object, so kill it pEntity->VPhysicsDestroyObject(); pEntity->SetModel( STRING(pSwap->GetModelName()) ); } CBaseEntity *pPhys = CreateSimplePhysicsObject( pEntity, createAsleep ); // created phys object, now move hierarchy over if ( pPhys ) { pPhys->SetName( pEntity->GetEntityName() ); TransferChildren( pEntity, pPhys ); pEntity->AddSolidFlags( FSOLID_NOT_SOLID ); pEntity->m_fEffects |= EF_NODRAW; UTIL_Relink( pEntity ); UTIL_Remove( pEntity ); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CEnvScreenEffect::InputStartEffect( inputdata_t &inputdata ) { m_OnStartEffect.FireOutput( this, this ); EntityMessageBegin( this ); WRITE_BYTE( 0 ); MessageEnd(); }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CNPC_Barney::UseFunc( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_bDontUseSemaphore = true; SpeakIfAllowed( TLK_USE ); m_bDontUseSemaphore = false; m_OnPlayerUse.FireOutput( pActivator, pCaller ); }
//------------------------------------------------------------------------------ void CNPC_EnemyFinder::PrescheduleThink() { BaseClass::PrescheduleThink(); bool bHasEnemies = GetEnemies()->NumEnemies() > 0; if ( GetEnemies()->NumEnemies() > 0 ) { //If I haven't seen my enemy in half a second then we'll assume he's gone. if ( gpGlobals->curtime - GetEnemyLastTimeSeen() >= 0.5f ) { bHasEnemies = false; } } if ( m_bEnemyStatus != bHasEnemies ) { if ( bHasEnemies ) { m_OnAcquireEnemies.FireOutput( this, this ); } else { m_OnLostEnemies.FireOutput( this, this ); } m_bEnemyStatus = bHasEnemies; } if( ai_debug_enemyfinders.GetBool() ) { m_debugOverlays |= OVERLAY_BBOX_BIT; if( IsInSquad() && GetSquad()->NumMembers() > 1 ) { AISquadIter_t iter; CAI_BaseNPC *pSquadmate = m_pSquad ? m_pSquad->GetFirstMember( &iter ) : NULL; while ( pSquadmate ) { NDebugOverlay::Line( WorldSpaceCenter(), pSquadmate->EyePosition(), 255, 255, 0, false, 0.1f ); pSquadmate = m_pSquad->GetNextMember( &iter ); } } } }
void CTFOChecker::CheckWep(inputdata_t &inputData) { CBasePlayer *pClient = UTIL_GetLocalPlayer(); if (pClient) { if (pClient->m_bCanPickupRewards) m_OnCheck.FireOutput(this, this); } }
//----------------------------------------------------------------------------- // Purpose: Called when an entity starts touching us. // Input : pOther - the entity that is now touching us. //----------------------------------------------------------------------------- void CTriggerBrush::StartTouch( CBaseEntity *pOther ) { if ( PassesInputFilter(pOther, m_iInputFilter) && !(m_iInputFilter & TRIGGER_IGNORETOUCH) ) { m_OnStartTouch.FireOutput( pOther, this ); if ( !m_iDontMessageParent ) BaseClass::StartTouch( pOther ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CEnvScreenEffect::InputStopEffect( inputdata_t &inputdata ) { m_OnStopEffect.FireOutput( this, this ); // Send the stop notification EntityMessageBegin( this ); WRITE_BYTE( 1 ); MessageEnd(); }
//========================================================= // Retire - stop being active //========================================================= void CNPC_BaseTurret::Retire(void) { // make the turret level m_vecGoalAngles.x = 0; m_vecGoalAngles.y = m_flStartYaw; SetNextThink( gpGlobals->curtime + 0.1 ); StudioFrameAdvance( ); EyeOff( ); if (!MoveTurret()) { if (m_iSpin) { SpinDownCall(); } else if (GetSequence() != TURRET_ANIM_RETIRE) { SetTurretAnim(TURRET_ANIM_RETIRE); CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "Turret.Undeploy" ); m_OnDeactivate.FireOutput(this, this); } //else if (IsSequenceFinished()) else if( GetSequence() == TURRET_ANIM_RETIRE && GetCycle() <= 0.0 ) { m_iOn = 0; m_flLastSight = 0; //SetTurretAnim(TURRET_ANIM_NONE); Vector curmins, curmaxs; curmins = WorldAlignMins(); curmaxs = WorldAlignMaxs(); curmaxs.z = m_iRetractHeight; curmins.z = -m_iRetractHeight; SetCollisionBounds( curmins, curmaxs ); if (m_iAutoStart) { SetThink(&CNPC_BaseTurret::AutoSearchThink); SetNextThink( gpGlobals->curtime + 0.1 ); } else { SetThink( &CBaseEntity::SUB_DoNothing ); } } } else { SetTurretAnim(TURRET_ANIM_SPIN); } }