void hhGibbable::Explode(idEntity *activator) { hhFxInfo fxInfo; Hide(); fl.takedamage = false; GetPhysics()->SetContents( 0 ); ActivateTargets( activator ); SetSkinByName(NULL); if ( spawnArgs.GetFloat( "respawn", "0" ) ) { PostEventSec( &EV_Respawn, spawnArgs.GetFloat( "respawn", "0" ) ); } else { PostEventMS( &EV_Remove, 200 ); // Remove after a small delay to allow sound commands to execute } StartSound( "snd_gib", SND_CHANNEL_ANY ); // Find thinnest axis in the bounds and use for fx normal idVec3 thinnest = vec3_origin; int axisIndex = DetermineThinnestAxis(); thinnest[axisIndex] = 1.0f; thinnest *= GetAxis(); fxInfo.RemoveWhenDone( true ); fxInfo.SetNormal(thinnest); // Spawn FX system for gib BroadcastFxInfo( spawnArgs.GetString("fx_gib"), GetOrigin(), GetAxis(), &fxInfo ); // Spawn gibs if (spawnArgs.FindKey("def_debrisspawner")) { hhUtils::SpawnDebrisMass(spawnArgs.GetString("def_debrisspawner"), this ); } }
/* ================ idTrigger_Hurt::Event_Touch ================ */ void idTrigger_Hurt::Event_Touch( idEntity* other, trace_t* trace ) { const char* damage; if( common->IsClient() ) { return; } if( on && other && gameLocal.time >= nextTime ) { bool playerOnly = spawnArgs.GetBool( "playerOnly" ); if( playerOnly ) { if( !other->IsType( idPlayer::Type ) ) { return; } } damage = spawnArgs.GetString( "def_damage", "damage_painTrigger" ); idVec3 dir = vec3_origin; if( spawnArgs.GetBool( "kick_from_center", "0" ) ) { dir = other->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin(); dir.Normalize(); } other->Damage( NULL, NULL, dir, damage, 1.0f, INVALID_JOINT ); ActivateTargets( other ); CallScript(); nextTime = gameLocal.time + SEC2MS( delay ); } }
/* ================ idBrittleFracture::AddForce ================ */ void idBrittleFracture::AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force ) { //if ( id < 0 || id >= shards.Num() ) if ( id < 0) { return; } if (id >= shards.Num()) id = shards.Num() - 1; if ( shards[id]->droppedTime != -1 ) { shards[id]->physicsObj.AddForce( 0, point, force ); } //else if ( health <= 0 && !disableFracture ) else if ( !disableFracture ) { Shatter( point, force, gameLocal.time ); //StartSound( "snd_shatter", SND_CHANNEL_ANY, 0, false, NULL ); //BC Trigger any alarm things. ActivateTargets( gameLocal.GetLocalPlayer() ); } }
/* ============ idMoveable::Killed ============ */ void idMoveable::Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location ) { if( unbindOnDeath ) { Unbind(); } if( brokenModel != "" ) { SetModel( brokenModel ); } if( explode ) { if( brokenModel == "" ) { PostEventMS( &EV_Remove, 1000 ); } } if( renderEntity.gui[ 0 ] ) { renderEntity.gui[ 0 ] = NULL; } ActivateTargets( this ); fl.takedamage = false; }
/* ===================== idCameraView::Stop ===================== */ void idCameraView::Stop( void ) { if ( g_debugCinematic.GetBool() ) { gameLocal.Printf( "%d: '%s' stop\n", gameLocal.framenum, GetName() ); } gameLocal.SetCamera(NULL); ActivateTargets( gameLocal.GetLocalPlayer() ); }
void hhSlots::CheckVictory() { #define NUM_VICTORIES 16 static victory_t victoryTable[NUM_VICTORIES] = { { MASK_BARBARBAR, MASK_BARBARBAR, MASK_BARBARBAR, 10000}, { MASK_BARBAR, MASK_BARBAR, MASK_BARBAR, 1000}, { MASK_BAR, MASK_BAR, MASK_BAR, 500}, { MASK_ANYBAR, MASK_ANYBAR, MASK_ANYBAR, 100}, { MASK_MELON, MASK_MELON, MASK_MELON, 60}, { MASK_GRAPE, MASK_GRAPE, MASK_GRAPE, 50}, { MASK_APPLE, MASK_APPLE, MASK_APPLE, 40}, { MASK_LEMON, MASK_LEMON, MASK_LEMON, 30}, { MASK_ORANGE, MASK_ORANGE, MASK_ORANGE, 20}, { MASK_CHERRY, MASK_CHERRY, MASK_CHERRY, 10}, { MASK_CHERRY, MASK_CHERRY, MASK_ANY, 5}, { MASK_ANY, MASK_CHERRY, MASK_CHERRY, 5}, { MASK_CHERRY, MASK_ANY, MASK_CHERRY, 5}, { MASK_CHERRY, MASK_ANY, MASK_ANY, 2}, { MASK_ANY, MASK_CHERRY, MASK_ANY, 2}, { MASK_ANY, MASK_ANY, MASK_CHERRY, 2} }; PlayerCredits -= Bet; result = SLOTRESULT_LOSE; creditsWon = 0; for (int ix=0; ix<NUM_VICTORIES; ix++) { int fruitmask1 = MaskForFruit(reel1[ReelPos2Slot(reelPos1)]); int fruitmask2 = MaskForFruit(reel2[ReelPos2Slot(reelPos2)]); int fruitmask3 = MaskForFruit(reel3[ReelPos2Slot(reelPos3)]); if ((fruitmask1 & victoryTable[ix].f1) && (fruitmask2 & victoryTable[ix].f2) && (fruitmask3 & victoryTable[ix].f3) ) { result = SLOTRESULT_WIN; creditsWon = Bet * victoryTable[ix].payoff; PlayerCredits += creditsWon; PlayerCredits = idMath::ClampInt(0, 999999999, PlayerCredits); // Play victory sound if (victoryAmount && PlayerCredits >= victoryAmount) { StartSound( "snd_victory", SND_CHANNEL_ANY ); ActivateTargets( gameLocal.GetLocalPlayer() ); victoryAmount = 0; } else if (victoryTable[ix].payoff > 5) { StartSound( "snd_winbig", SND_CHANNEL_ANY ); } else { StartSound( "snd_win", SND_CHANNEL_ANY ); } break; } } PlayerBet = idMath::ClampInt(0, PlayerCredits, PlayerBet); }
/* ================ idTrigger_Count::Event_TriggerAction ================ */ void idTrigger_Count::Event_TriggerAction( idEntity *activator ) { ActivateTargets( activator ); CallScript( activator ); if ( goal == -1 ) { PostEventMS( &EV_Remove, 0 ); } }
/* ================ idTrigger_Multi::TriggerAction ================ */ void idTrigger_Multi::TriggerAction( idEntity *activator ) { // RAVEN BEGIN // jdischler: added for Aweldon. The trigger, when activated, will call the listed func with all attached targets, then return. if ( spawnArgs.GetBool( "_callWithTargets", "0" )) { idEntity *ent; for( int i = 0; i < targets.Num(); i++ ) { ent = targets[ i ].GetEntity(); if ( !ent ) { continue; } CallScript( ent ); } return; } // RAVEN END ActivateTargets( triggerWithSelf ? this : activator ); CallScript( triggerWithSelf ? this : activator ); if ( wait >= 0 ) { nextTriggerTime = gameLocal.time + SEC2MS( wait + random * gameLocal.random.CRandomFloat() ); } else { // we can't just remove (this) here, because this is a touch function // called while looping through area links... nextTriggerTime = gameLocal.time + 1; PostEventMS( &EV_Remove, 0 ); } }
/* ================ idTrigger_Timer::Event_Timer ================ */ void idTrigger_Timer::Event_Timer( void ) { ActivateTargets( this ); // set time before next firing if( wait >= 0.0f ) { PostEventSec( &EV_Timer, wait + gameLocal.random.CRandomFloat() * random ); } }
/* ============== idSpawner::Event_Activate ============== */ void idSpawner::Event_Activate( idEntity *activator ) { // "trigger_only" spawners will attempt to spawn when triggered if ( spawnArgs.GetBool( "trigger_only" ) ) { // Update next spawn time to follo CheckSpawn into thinking its time to spawn again nextSpawnTime = gameLocal.time; CheckSpawn(); return; } // If nextSpawnTime is zero then the spawner is currently deactivated if ( nextSpawnTime == 0 ) { // Start thinking BecomeActive( TH_THINK ); // Allow immediate spawn nextSpawnTime = gameLocal.time; // Spawn any ai targets and add them to the current count ActivateTargets( this ); } else { nextSpawnTime = 0; BecomeInactive( TH_THINK ); // Remove the spawner if need be if ( spawnArgs.GetBool( "remove", "1" ) ) { PostEventMS( &EV_Remove, 0 ); } } }
/* ================ idTrigger_Touch::TouchEntities ================ */ void idTrigger_Touch::TouchEntities( void ) { int numClipModels, i; idBounds bounds; idClipModel *cm, *clipModelList[ MAX_GENTITIES ]; if( clipModel == NULL || scriptFunction == NULL ) { return; } bounds.FromTransformedBounds( clipModel->GetBounds(), clipModel->GetOrigin(), clipModel->GetAxis() ); numClipModels = gameLocal.clip.ClipModelsTouchingBounds( bounds, -1, clipModelList, MAX_GENTITIES ); for( i = 0; i < numClipModels; i++ ) { cm = clipModelList[ i ]; if( !cm->IsTraceModel() ) { continue; } idEntity *entity = cm->GetEntity(); if( !entity ) { continue; } if( !gameLocal.clip.ContentsModel( cm->GetOrigin(), cm, cm->GetAxis(), -1, clipModel->Handle(), clipModel->GetOrigin(), clipModel->GetAxis() ) ) { continue; } ActivateTargets( entity ); idThread *thread = new idThread(); thread->CallFunction( entity, scriptFunction, false ); thread->DelayedStart( 0 ); } }
/* ================ idBrittleFracture::Shatter ================ */ void idBrittleFracture::Shatter( const idVec3 &point, const idVec3 &impulse, const int time ) { int i; idVec3 dir; shard_t *shard; float m; if ( gameLocal.isServer ) { idBitMsg msg; byte msgBuf[MAX_EVENT_PARAM_SIZE]; msg.Init( msgBuf, sizeof( msgBuf ) ); msg.BeginWriting(); msg.WriteFloat( point[0] ); msg.WriteFloat( point[1] ); msg.WriteFloat( point[2] ); msg.WriteFloat( impulse[0] ); msg.WriteFloat( impulse[1] ); msg.WriteFloat( impulse[2] ); ServerSendEvent( EVENT_SHATTER, &msg, true, -1 ); } if ( time > ( gameLocal.time - SHARD_ALIVE_TIME ) ) { StartSound( "snd_shatter", SND_CHANNEL_ANY, 0, false, NULL ); } if ( !IsBroken() ) { Break(); } if ( fxFracture.Length() ) { idEntityFx::StartFx( fxFracture, &point, &GetPhysics()->GetAxis(), this, true ); } dir = impulse; m = dir.Normalize(); for ( i = 0; i < shards.Num(); i++ ) { shard = shards[i]; if ( shard->droppedTime != -1 ) { continue; } if ( ( shard->clipModel->GetOrigin() - point ).LengthSqr() > Square( maxShatterRadius ) ) { continue; } DropShard( shard, point, dir, m, time ); } DropFloatingIslands( point, impulse, time ); //trigger it. if (!firedTargets) { firedTargets = true; ActivateTargets(this); } }
/* ================ idBrittleFracture::Killed ================ */ void idBrittleFracture::Killed( idEntity* inflictor, idEntity* attacker, int damage, const idVec3& dir, int location ) { if( !disableFracture ) { ActivateTargets( this ); Break(); } }
/* ================ idItem::Pickup ================ */ bool idItem::Pickup(idPlayer *player) { if (!GiveToPlayer(player)) { return false; } if (gameLocal.isServer) { ServerSendEvent(EVENT_PICKUP, NULL, false, -1); } // play pickup sound StartSound("snd_acquire", SND_CHANNEL_ITEM, 0, false, NULL); // trigger our targets ActivateTargets(player); // clear our contents so the object isn't picked up twice GetPhysics()->SetContents(0); // hide the model Hide(); // add the highlight shell if (itemShellHandle != -1) { gameRenderWorld->FreeEntityDef(itemShellHandle); itemShellHandle = -1; } float respawn = spawnArgs.GetFloat("respawn"); bool dropped = spawnArgs.GetBool("dropped"); bool no_respawn = spawnArgs.GetBool("no_respawn"); if (gameLocal.isMultiplayer && respawn == 0.0f) { respawn = 20.0f; } if (respawn && !dropped && !no_respawn) { const char *sfx = spawnArgs.GetString("fxRespawn"); if (sfx && *sfx) { PostEventSec(&EV_RespawnFx, respawn - 0.5f); } PostEventSec(&EV_RespawnItem, respawn); } else if (!spawnArgs.GetBool("inv_objective") && !no_respawn) { // give some time for the pickup sound to play // FIXME: Play on the owner if (!spawnArgs.GetBool("inv_carry")) { PostEventMS(&EV_Remove, 5000); } } BecomeInactive(TH_THINK); return true; }
/* ================ idLight::BecomeBroken ================ */ void idLight::BecomeBroken( idEntity *activator ) { const char *damageDefName; fl.takedamage = false; if ( brokenModel.Length() ) { SetModel( brokenModel ); if ( !spawnArgs.GetBool( "nonsolid" ) ) { GetPhysics()->SetClipModel( new idClipModel( brokenModel.c_str() ), 1.0f ); GetPhysics()->SetContents( CONTENTS_SOLID ); } } else if ( spawnArgs.GetBool( "hideModelOnBreak" ) ) { SetModel( "" ); GetPhysics()->SetContents( 0 ); } if ( gameLocal.isServer ) { ServerSendEvent( EVENT_BECOMEBROKEN, NULL, true, -1 ); if ( spawnArgs.GetString( "def_damage", "", &damageDefName ) ) { idVec3 origin = renderEntity.origin + renderEntity.bounds.GetCenter() * renderEntity.axis; gameLocal.RadiusDamage( origin, activator, activator, this, this, damageDefName ); } } ActivateTargets( activator ); // offset the start time of the shader to sync it to the game time renderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time ); renderLight.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time ); // set the state parm renderEntity.shaderParms[ SHADERPARM_MODE ] = 1; renderLight.shaderParms[ SHADERPARM_MODE ] = 1; // if the light has a sound, either start the alternate (broken) sound, or stop the sound const char *parm = spawnArgs.GetString( "snd_broken" ); if ( refSound.shader || ( parm && *parm ) ) { StopSound( SND_CHANNEL_ANY, false ); const idSoundShader *alternate = refSound.shader ? refSound.shader->GetAltSound() : declManager->FindSound( parm ); if ( alternate ) { // start it with no diversity, so the leadin break sound plays refSound.referenceSound->StartSound( alternate, SND_CHANNEL_ANY, 0.0, 0 ); } } parm = spawnArgs.GetString( "mtr_broken" ); if ( parm && *parm ) { SetShader( parm ); } UpdateVisuals(); }
/* ================ idSecurityCamera::Event_Alert ================ */ void idSecurityCamera::Event_Alert( void ) { float wait; SetAlertMode( ACTIVATED ); StopSound( SND_CHANNEL_ANY, false ); StartSound( "snd_activate", SND_CHANNEL_BODY, 0, false, NULL ); ActivateTargets( this ); CancelEvents( &EV_SecurityCam_ContinueSweep ); wait = spawnArgs.GetFloat( "wait", "20" ); PostEventSec( &EV_SecurityCam_ContinueSweep, wait ); }
/* ================ idTrigger_Hurt::Event_Touch ================ */ void idTrigger_Hurt::Event_Touch( idEntity *other, trace_t *trace ) { const char *damage; if( on && other && gameLocal.time >= nextTime ) { damage = spawnArgs.GetString( "def_damage", "damage_painTrigger" ); other->Damage( NULL, NULL, vec3_origin, damage, 1.0f, INVALID_JOINT ); ActivateTargets( other ); CallScript(); nextTime = gameLocal.time + SEC2MS( delay ); } }
/* ================= rvEffect::Event_Activate ================= */ void rvEffect::Event_Activate( idEntity *activator ) { // Stop the effect if its already playing if( !clientEntities.IsListEmpty ( ) ) { Event_Stop ( ); } else { Event_Start ( ); } ActivateTargets( activator ); }
/* ================ idTrigger_EntityName::TriggerAction ================ */ void idTrigger_EntityName::TriggerAction( idEntity *activator ) { ActivateTargets( activator ); CallScript(); if( wait >= 0 ) { nextTriggerTime = gameLocal.time + SEC2MS( wait + random * gameLocal.random.CRandomFloat() ); } else { // we can't just remove (this) here, because this is a touch function // called while looping through area links... nextTriggerTime = gameLocal.time + 1; PostEventMS( &EV_Remove, 0 ); } }
void CMultiStateMover::DoneMoving() { idMover::DoneMoving(); if( spawnArgs.GetBool( "trigger_on_reached", "0" ) ) { // Trigger targets now that we've reached our goal position ActivateTargets( this ); } // Try to locate the position entity CMultiStateMoverPosition *positionEnt = GetPositionEntity( GetPhysics()->GetOrigin() ); if( positionEnt != NULL ) { // Fire the event on the position entity positionEnt->OnMultistateMoverArrive( this ); } }
/* ================ idBrittleFracture::Killed ================ */ void idBrittleFracture::Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location ) { bool bPlayerResponsible( false ); if( !disableFracture ) { ActivateTargets( this ); Break(); } if( attacker && attacker->IsType( idPlayer::Type ) ) { bPlayerResponsible = ( attacker == gameLocal.GetLocalPlayer() ); } else if( attacker && attacker->m_SetInMotionByActor.GetEntity() ) { bPlayerResponsible = ( attacker->m_SetInMotionByActor.GetEntity() == gameLocal.GetLocalPlayer() ); } gameLocal.m_MissionData->MissionEvent( COMP_DESTROY, this, bPlayerResponsible ); }
/* ================ idTarget_WaitForButton::Think ================ */ void idTarget_WaitForButton::Think( void ) { idPlayer *player; if( thinkFlags & TH_THINK ) { player = gameLocal.GetLocalPlayer(); if( player && !( player->oldButtons & BUTTON_ATTACK ) && ( player->usercmd.buttons & BUTTON_ATTACK ) ) { player->usercmd.buttons &= ~BUTTON_ATTACK; BecomeInactive( TH_THINK ); ActivateTargets( player ); } } else { BecomeInactive( TH_ALL ); } }
void hhBlackJack::AssessScores() { if (PlayerScore > 21) { creditsWon = -Bet; resultIndex = BJRESULT_BUST; } else if (DealerScore > 21) { creditsWon = Bet; resultIndex = BJRESULT_WIN; } else if (PlayerScore == 21 && PlayerHand.Num() == 2) { // BlackJack creditsWon = Bet * 2; resultIndex = BJRESULT_BLACKJACK; } else if (PlayerScore <= 21 && PlayerHand.Num() == 5) { creditsWon = Bet * 5; resultIndex = BJRESULT_5CARD; } else if (DealerScore > PlayerScore) { creditsWon = -Bet; resultIndex = BJRESULT_LOSE; } else if (PlayerScore > DealerScore) { creditsWon = Bet; resultIndex = BJRESULT_WIN; } else { // Push creditsWon = 0; resultIndex = BJRESULT_PUSH; } PlayerCredits += creditsWon; PlayerCredits = idMath::ClampInt(0, 999999999, PlayerCredits); Bet = PlayerBet; // Play victory/failure sound if (victoryAmount && PlayerCredits >= victoryAmount) { StartSound( "snd_victory", SND_CHANNEL_ANY, 0, true, NULL ); ActivateTargets( gameLocal.GetLocalPlayer() ); victoryAmount = 0; } else if (creditsWon > 0) { StartSound( "snd_win", SND_CHANNEL_ANY, 0, true, NULL ); } else if (creditsWon < 0) { StartSound( "snd_lose", SND_CHANNEL_ANY, 0, true, NULL ); } }
/* ===================== idCameraAnim::Stop ===================== */ void idCameraAnim::Stop(void) { if (gameLocal.GetCamera() == this) { if (g_debugCinematic.GetBool()) { gameLocal.Printf("%d: '%s' stop\n", gameLocal.framenum, GetName()); } BecomeInactive(TH_THINK); gameLocal.SetCamera(NULL); if (threadNum) { idThread::ObjectMoveDone(threadNum, this); threadNum = 0; } ActivateTargets(activator.GetEntity()); } }
/* ================ idTrigger_Multi::TriggerAction ================ */ void idTrigger_Multi::TriggerAction( idEntity *activator ) { ActivateTargets( triggerWithSelf ? this : activator ); CallScript(); if ( wait >= 0 ) { nextTriggerTime = gameLocal.time + SEC2MS( wait + random * gameLocal.random.CRandomFloat() ); } else { // we can't just remove (this) here, because this is a touch function // called while looping through area links... // If the player spawned inside the trigger, the player Spawn function called Think directly, // allowing for multiple triggers on a trigger_once. Increasing the nextTriggerTime prevents it. nextTriggerTime = gameLocal.time + 99999; PostEventMS( &EV_Remove, 0 ); } }
/* ================ idItem::Pickup ================ */ bool idItem::Pickup( idPlayer *player ) { if ( !GiveToPlayer( player ) ) { return false; } // play pickup sound StartSound( "snd_acquire", SND_CHANNEL_ITEM, 0, false, NULL ); // sikk - play the sounds through the player //player->StartSoundShader( declManager->FindSound( spawnArgs.GetString( "snd_acquire" ) ), SND_CHANNEL_ITEM, SSF_PRIVATE_SOUND, false, NULL ); // trigger our targets ActivateTargets( player ); // clear our contents so the object isn't picked up twice GetPhysics()->SetContents( 0 ); // hide the model Hide(); FreeLightDef(); // sikk - Crumb Light // add the highlight shell if ( itemShellHandle != -1 ) { gameRenderWorld->FreeEntityDef( itemShellHandle ); itemShellHandle = -1; } float respawn = spawnArgs.GetFloat( "respawn" ); bool dropped = spawnArgs.GetBool( "dropped" ); bool no_respawn = spawnArgs.GetBool( "no_respawn" ); if ( respawn && !dropped && !no_respawn ) { const char *sfx = spawnArgs.GetString( "fxRespawn" ); if ( sfx && *sfx ) { PostEventSec( &EV_RespawnFx, respawn - 0.5f ); } PostEventSec( &EV_RespawnItem, respawn ); } else if ( !spawnArgs.GetBool( "inv_objective" ) && !no_respawn ) { // give some time for the pickup sound to play // FIXME: Play on the owner if ( !spawnArgs.GetBool( "inv_carry" ) ) { PostEventMS( &EV_Remove, 5000 ); } } BecomeInactive( TH_THINK ); return true; }
/* ================ rvCTF_AssaultPoint::ResetSpawns ================ */ void rvCTF_AssaultPoint::ResetSpawns( int team ) { // check to see if team can spawn at me, if not pass down if( owner == team ) { ActivateTargets( this ); } else { if( team == TEAM_MARINE ) { if( static_cast<rvCTF_AssaultPoint*>(toMarine.GetEntity())->IsType( rvCTF_AssaultPoint::Type ) ) { static_cast<rvCTF_AssaultPoint*>(toMarine.GetEntity())->ResetSpawns( team ); } } else if( team == TEAM_STROGG ) { if( static_cast<rvCTF_AssaultPoint*>(toStrogg.GetEntity())->IsType( rvCTF_AssaultPoint::Type ) ) { static_cast<rvCTF_AssaultPoint*>(toStrogg.GetEntity())->ResetSpawns( team ); } } } }
/* ================ idTrigger_EntityName::TriggerAction ================ */ void idTrigger_EntityName::TriggerAction( idEntity *activator ) { // RAVEN BEGIN // abahr: want same functionality as trigger_multi. Need to move this code into these two function calls idEntity* scriptEntity = spawnArgs.GetBool("triggerWithSelf") ? this : activator; ActivateTargets( scriptEntity ); CallScript( scriptEntity ); // RAVEN END if ( wait >= 0 ) { nextTriggerTime = gameLocal.time + SEC2MS( wait + random * gameLocal.random.CRandomFloat() ); } else { // we can't just remove (this) here, because this is a touch function // called while looping through area links... nextTriggerTime = gameLocal.time + 1; PostEventMS( &EV_Remove, 0 ); } }
void CFrobLock::Event_TriggerTargets() { ActivateTargets(this); // Additionally to triggering the targets, update the frobability according to our locked status if (spawnArgs.GetBool("update_target_frobability", "0")) { for (int i = 0; i < targets.Num(); ++i) { idEntity* ent = targets[i].GetEntity(); if (ent == NULL) continue; // Set frobability based on unlocked/locked status ent->SetFrobable(!IsLocked()); } } }
void CMultiStateMover::Activate( idEntity *activator ) { // Fire the TRIGGER response TriggerResponse( activator, ST_TRIGGER ); if( activator == NULL ) { return; } // Get the "position" spawnarg from the activator idStr targetPosition; if( !activator->spawnArgs.GetString( "position", "", targetPosition ) ) { return; // no "position" key found => exit } int targetPositionIndex = GetPositionInfoIndex( targetPosition ); if( targetPositionIndex == -1 ) { gameLocal.Warning( "Multistate mover '%s' is targetted by entity '%s' with unknown 'position': %s", name.c_str(), activator->name.c_str(), targetPosition.c_str() ); return; } // We appear to have a valid position index, start moving CMultiStateMoverPosition *positionEnt = positionInfo[targetPositionIndex].positionEnt.GetEntity(); if( IsAtPosition( positionEnt ) ) { // nothing to do, we're already at the target position return; } const idVec3 &targetPos = positionEnt->GetPhysics()->GetOrigin(); const idVec3 &curPos = GetPhysics()->GetOrigin(); // Check if we are at a defined position CMultiStateMoverPosition *curPositionEnt = GetPositionEntity( curPos ); // We're done moving if the velocity is very close to zero bool isAtRest = GetPhysics()->GetLinearVelocity().Length() <= VECTOR_EPSILON; if( isAtRest ) { if( spawnArgs.GetBool( "trigger_on_leave", "0" ) ) { // We're leaving our position, trigger targets ActivateTargets( this ); } if( curPositionEnt != NULL ) { // Fire the event on the position entity curPositionEnt->OnMultistateMoverLeave( this ); } } // Set the rotation direction of any targetted func_rotaters SetGearDirection( targetPos ); // Finally start moving (this will update the "stage" members of the mover) MoveToPos( targetPos ); }