/* ================ idTrigger_EntityName::Event_Trigger the trigger was just activated activated should be the entity that originated the activation sequence (ie. the original target) activator should be set to the activator so it can be held through a delay so wait for the delay time before firing ================ */ void idTrigger_EntityName::Event_Trigger( idEntity *activator ) { if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } if ( !activator || ( activator->name != entityName ) ) { return; } if ( triggerFirst ) { triggerFirst = false; return; } // don't allow it to trigger twice in a single frame nextTriggerTime = gameLocal.time + 1; if ( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, activator ); } else { TriggerAction( activator ); } }
/* ================ idTrigger_EntityName::Event_Touch ================ */ void idTrigger_EntityName::Event_Touch( idEntity *other, trace_t *trace ) { if( triggerFirst ) { return; } if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } // RAVEN BEGIN // abahr: so we can exclude an entity by name if( !other ) { return; } if( spawnArgs.GetBool("excludeEntityName") && other->name == entityName ) { return; } if( !spawnArgs.GetBool("excludeEntityName") && other->name != entityName ) { return; } // RAVEN END nextTriggerTime = gameLocal.time + 1; if ( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, other ); } else { TriggerAction( other ); } }
/* ================ idTrigger_Multi::Event_Trigger the trigger was just activated activated should be the entity that originated the activation sequence (ie. the original target) activator should be set to the activator so it can be held through a delay so wait for the delay time before firing ================ */ void idTrigger_Multi::Event_Trigger( idEntity *activator ) { // RAVEN BEGIN // bdube: moved trigger first if ( triggerFirst ) { triggerFirst = false; return; } if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } // see if this trigger requires an item if ( !gameLocal.RequirementMet( activator, requires, removeItem ) ) { return; } if ( !CheckFacing( activator ) ) { return; } // RAVEN END // don't allow it to trigger twice in a single frame nextTriggerTime = gameLocal.time + 1; if ( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, activator ); } else { TriggerAction( activator ); } }
/* ================ idTrigger_EntityName::Event_Touch ================ */ void idTrigger_EntityName::Event_Touch( idEntity *other, trace_t *trace ) { if( triggerFirst ) { return; } if( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } if( !other || ( other->name != entityName ) ) { return; } nextTriggerTime = gameLocal.time + 1; if( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, other ); } else { TriggerAction( other ); } }
/* ================ idTrigger_Multi::Event_Touch ================ */ void idTrigger_Multi::Event_Touch( idEntity *other, trace_t *trace ) { if( triggerFirst ) { return; } bool player = other->IsType( idPlayer::Type ); if( player ) { if( !touchClient ) { return; } if( static_cast< idPlayer * >( other )->spectating ) { return; } } else if( !touchOther ) { return; } if( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } // see if this trigger requires an item if( !gameLocal.RequirementMet( other, requires, removeItem ) ) { return; } if( !CheckFacing( other ) ) { return; } if( spawnArgs.GetBool( "toggleTriggerFirst" ) ) { triggerFirst = true; } nextTriggerTime = gameLocal.time + 1; if( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, other ); } else { TriggerAction( other ); } }
/* ================ idTrigger_EntityName::Event_Touch ================ */ void idTrigger_EntityName::Event_Touch( idEntity* other, trace_t* trace ) { if( common->IsClient() ) { return; } if( triggerFirst ) { return; } if( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } bool validEntity = false; if( other ) { if( testPartialName ) { if( other->name.Find( entityName, false ) >= 0 ) { validEntity = true; } } if( other->name == entityName ) { validEntity = true; } } if( !validEntity ) { return; } nextTriggerTime = gameLocal.time + 1; if( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, other ); } else { TriggerAction( other ); } }
/** * Check whether the watchdog timer is running and trigger proper action * * @return true if thread can exit, false if not **/ bool NewSimulatorWatchdog::TriggerAction() { stdlog << "DBG: CheckWatchdogTimer\n"; if ( m_wdt_data.Running == SAHPI_FALSE ) return true; if ( ! m_start.IsSet() ) return true; // Ok, we have a running wdt cTime now( cTime::Now() ); now -= m_start; if ( now.GetMsec() >= m_wdt_data.InitialCount ) { if ( m_state != PRETIMEOUT ) TriggerAction( PRETIMEOUT ); TriggerAction( TIMEOUT ); stdlog << "DBG: WatchdogTimer expires.\n"; return true; } if ( now.GetMsec() >= m_wdt_data.InitialCount - m_wdt_data.PreTimeoutInterval ) { TriggerAction( PRETIMEOUT ); return false; } m_wdt_data.PresentCount = m_wdt_data.InitialCount - now.GetMsec(); return false; }
/* ================ idTrigger_Multi::Event_Trigger the trigger was just activated activated should be the entity that originated the activation sequence (ie. the original target) activator should be set to the activator so it can be held through a delay so wait for the delay time before firing ================ */ void idTrigger_Multi::Event_Trigger( idEntity *activator ) { if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } // see if this trigger requires an item if ( !gameLocal.RequirementMet( activator, requires, removeItem ) ) { return; } if ( !CheckFacing( activator ) ) { return; } if ( triggerFirst ) { triggerFirst = false; return; } // don't allow it to trigger twice in a single frame nextTriggerTime = gameLocal.time + 1; if ( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, activator ); } else { TriggerAction( activator ); } //BC recording. idEntity *recordEnt; recordEnt = gameLocal.FindEntity( "world1" ); if (recordEnt) { if (this->spawnArgs.GetBool("recordable", "0")) { static_cast<idWorldManager *>( recordEnt )->RecordFrob(this->GetName()); } } }
/* ================ idTrigger_EntityName::Event_Touch ================ */ void idTrigger_classname::Event_Touch( idEntity *other, trace_t *trace ) { if( triggerFirst ) { return; } if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } if ( !other || ( other->spawnArgs.GetString("classname") != className ) ) { return; } nextTriggerTime = gameLocal.time + 1; TriggerAction( other ); }
/* ================ idTrigger_EntityName::Event_Trigger the trigger was just activated activated should be the entity that originated the activation sequence (ie. the original target) activator should be set to the activator so it can be held through a delay so wait for the delay time before firing ================ */ void idTrigger_EntityName::Event_Trigger( idEntity *activator ) { if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } // RAVEN BEGIN // abahr: so we can exclude an entity by name if( !activator ) { return; } if( spawnArgs.GetBool("excludeEntityName") && activator->name == entityName ) { return; } if( !spawnArgs.GetBool("excludeEntityName") && activator->name != entityName ) { return; } // RAVEN END if ( triggerFirst ) { triggerFirst = false; return; } // don't allow it to trigger twice in a single frame nextTriggerTime = gameLocal.time + 1; if ( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, activator ); } else { TriggerAction( activator ); } }
// RAVEN BEGIN // kfuller: void idTrigger_Multi::Event_EarthQuake(float requiresLOS) { // does this entity even care about earthquakes? float quakeChance = 0; if (!spawnArgs.GetFloat("quakeChance", "0", quakeChance)) { return; } if (rvRandom::flrand(0, 1.0f) > quakeChance) { // failed its activation roll return; } if (requiresLOS) { // if the player doesn't have line of sight to this fx, don't do anything trace_t trace; idPlayer *player = gameLocal.GetLocalPlayer(); idVec3 viewOrigin; idMat3 viewAxis; player->GetViewPos(viewOrigin, viewAxis); // RAVEN BEGIN // ddynerman: multiple clip worlds gameLocal.TracePoint( this, trace, viewOrigin, GetPhysics()->GetOrigin(), MASK_OPAQUE, player ); // RAVEN END if (trace.fraction < 1.0f) { // something blocked LOS return; } } // activate this effect now TriggerAction(gameLocal.entities[ENTITYNUM_WORLD]); }
void idTrigger_classname::Event_Trigger( idEntity *activator ) { if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } if ( !activator || ( activator->spawnArgs.GetString("classname") != className ) ) { return; } if ( triggerFirst ) { triggerFirst = false; return; } // don't allow it to trigger twice in a single frame nextTriggerTime = gameLocal.time + 1; TriggerAction( activator ); }
/* ================ idTrigger_EntityName::Event_TriggerAction ================ */ void idTrigger_EntityName::Event_TriggerAction( idEntity *activator ) { TriggerAction( activator ); }
/* ================ idTrigger_Multi::Event_Touch ================ */ void idTrigger_Multi::Event_Touch( idEntity *other, trace_t *trace ) { if( triggerFirst ) { return; } // RAVEN BEGIN // jdischler: vehicle only trigger if ( touchVehicle ) { if ( !other->IsType(rvVehicle::GetClassType()) ) { return; } } else { // RAVEN BEGIN // jnewquist: Use accessor for static class type bool player = other->IsType( idPlayer::GetClassType() ); // RAVEN END if ( player ) { if ( !touchClient ) { return; } if ( static_cast< idPlayer * >( other )->spectating ) { return; } // Buy zone handling if ( buyZoneTrigger /*&& gameLocal.mpGame.mpGameState.gameState.currentState != 1*/ ) { idPlayer *p = static_cast< idPlayer * >( other ); if ( buyZoneTrigger-1 == p->team || buyZoneTrigger == 3) { p->inBuyZone = true; p->inBuyZonePrev = true; } } // Control zone handling if ( controlZoneTrigger > 0 ) { idPlayer *p = static_cast< idPlayer * >( other ); if ( p->PowerUpActive(POWERUP_DEADZONE) || !spawnArgs.GetBool("requiresDeadZonePowerup", "1") ) playersInTrigger.Append(p); } } else if ( !touchOther ) { return; } } if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } // see if this trigger requires an item if ( !gameLocal.RequirementMet( other, requires, removeItem ) ) { return; } if ( !CheckFacing( other ) ) { return; } if ( spawnArgs.GetBool( "toggleTriggerFirst" ) ) { triggerFirst = true; } // RAVEN BEGIN // rjohnson: added block if ( developer.GetBool() && *spawnArgs.GetString ( "message" ) ) { gameLocal.DPrintf ( "Trigger: %s\n", spawnArgs.GetString ( "message" ) ); } // RAVEN END nextTriggerTime = gameLocal.time + 1; if ( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, other ); } else { TriggerAction( other ); } }
/* ================ idTrigger_Multi::Event_TriggerAction ================ */ void idTrigger_Multi::Event_TriggerAction( idEntity *activator ) { TriggerAction( activator ); }
/* ================ idTrigger_EntityName::Event_Touch ================ */ void idTrigger_EntityName::Event_Touch( idEntity *other, trace_t *trace ) { if( triggerFirst ) { return; } if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } if ( !other || ( other->name != entityName ) ) { return; } nextTriggerTime = gameLocal.time + 1; if ( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, other ); } else { //bc this is VERY car-specific hack to ensure all four corners of the car are within the "hidey" trigger. if ( other->IsType( idActivator::Type ) ) { idAngles otherAngles; idVec3 size; idVec3 forward; idVec3 right; other->spawnArgs.GetVector( "size", "0 0 0", size ); if (size.x != 0 && size.y != 0 && size.z != 0) { otherAngles = other->GetPhysics()->GetAxis().ToAngles(); forward = otherAngles.ToForward(); otherAngles.yaw += 90; right = otherAngles.ToForward(); idVec3 frontLeft = other->GetPhysics()->GetAbsBounds().GetCenter() + forward * (size.x/2) + right * (size.y/2); idVec3 frontRight = other->GetPhysics()->GetAbsBounds().GetCenter() + forward * (size.x/2) + right * -(size.y/2); idVec3 rearLeft = other->GetPhysics()->GetAbsBounds().GetCenter() + forward * -(size.x/2) + right * (size.y/2); idVec3 rearRight = other->GetPhysics()->GetAbsBounds().GetCenter() + forward * -(size.x/2) + right * -(size.y/2); /* gameRenderWorld->DebugCircle( colorWhite, frontLeft, idVec3(0,0,1), 4, 6, 500 ); gameRenderWorld->DebugCircle( colorWhite, frontRight, idVec3(0,0,1), 4, 6, 500 ); gameRenderWorld->DebugCircle( colorWhite, rearLeft, idVec3(0,0,1), 4, 6, 500 ); gameRenderWorld->DebugCircle( colorWhite, rearRight, idVec3(0,0,1), 4, 6, 500 ); */ if (!this->GetPhysics()->GetAbsBounds().ContainsPoint( frontLeft) || !this->GetPhysics()->GetAbsBounds().ContainsPoint( frontRight) || !this->GetPhysics()->GetAbsBounds().ContainsPoint( rearLeft) || !this->GetPhysics()->GetAbsBounds().ContainsPoint( rearRight)) { return; } else { //inside the trigger. idEntity *carMaster = gameLocal.FindEntity( other->spawnArgs.GetString( "master" ) ); if (carMaster) { gameLocal.GetLocalPlayer()->UseFrob( carMaster, "inEntTrigger" ); TriggerAction( other ); return; } return; } } } TriggerAction( other ); } }
/* ================ idTrigger_Multi::Event_Touch ================ */ void idTrigger_Multi::Event_Touch( idEntity *other, trace_t *trace ) { if( triggerFirst ) { return; } bool player = other->IsType( idPlayer::Type ); if ( player ) { if ( !touchClient ) { return; } if ( static_cast< idPlayer * >( other )->spectating ) { return; } } else if ( !touchOther ) { return; } if ( nextTriggerTime > gameLocal.time ) { // can't retrigger until the wait is over return; } // see if this trigger requires an item if ( !gameLocal.RequirementMet( other, requires, removeItem ) ) { return; } if ( !CheckFacing( other ) ) { return; } if ( spawnArgs.GetBool( "toggleTriggerFirst" ) ) { triggerFirst = true; } if (player && spawnArgs.GetBool( "falltrigger" )) { StartSound( "snd_camerasnap" , SND_CHANNEL_ANY, 0, false, NULL ); if (gameLocal.GetLocalPlayer()->inDeck) { //kick player out of deck. //cvarSystem->SetCVarBool("deckActive", true, 0); //gameLocal.GetLocalPlayer()->deckEnt.GetEntity()->GetPhysics()->SetOrigin(popcornpos); //gameLocal.sessionCommand = "stopgui"; gameLocal.GetLocalPlayer()->ExitDeck(true); } const char *manualPos = this->spawnArgs.GetString("target"); if (manualPos) { idEntity *manualEnt = gameLocal.FindEntity( manualPos ); if (manualEnt) { other->SetOrigin( manualEnt->GetPhysics()->GetOrigin() + idVec3(0,0,1) ); other->GetPhysics()->PutToRest(); return; } } //current.velocity.Zero(); idVec3 popcornpos = static_cast< idPlayer * >( other )->popcornPosition; if (popcornpos == vec3_zero) { //no valid popcorn position. //reset player to spawn point. int spawnIndex = 0; idEntity *recordEnt; recordEnt = gameLocal.FindEntity( "world1" ); if (recordEnt) { spawnIndex = static_cast<idWorldManager *>( recordEnt )->index; } idEntity *spawnEnt; spawnEnt = gameLocal.FindEntity( va("heliinsertion%d", spawnIndex) ); if (spawnEnt) { other->SetOrigin( spawnEnt->GetPhysics()->GetOrigin() + idVec3(0,0,1) ); other->GetPhysics()->PutToRest(); } } else { other->SetOrigin( popcornpos + idVec3(0,0,1) ); other->GetPhysics()->PutToRest(); } } nextTriggerTime = gameLocal.time + 1; if ( delay > 0 ) { // don't allow it to trigger again until our delay has passed nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() ); PostEventSec( &EV_TriggerAction, delay, other ); } else { TriggerAction( other ); } }