LTBOOL SecurityCamera::Update() { State eStatePrevious = m_eState; if (m_bTripped) { UpdateFlashingLight(); SetNextUpdate(0.001f); return LTTRUE; } if (m_eState == eStateDestroyed || m_eState == eStateOff) { SetNextUpdate(0.0f); return LTTRUE; } UpdateRotation(); if (!m_bDisabled) { UpdateDetect(); } UpdateSounds(eStatePrevious); SetNextUpdate(0.001f); UpdateFlashingLight(); return LTTRUE; }
LTBOOL ClientLightFX::InitialUpdate(LTVector *pMovement) { m_damage.Init(m_hObject); m_damage.SetMaxHitPoints(m_fHitPts); m_damage.SetHitPoints(m_fHitPts); // Set Next update (randomize it if this object was loaded from the // level - so we don't have all the lights updating on the same frame)... LTFLOAT fOffset = 0.0f; if (!m_bDynamic) fOffset = g_pLTServer->Random(0.01f, 0.5f); if (m_bStartOn && m_fLifeTime > 0) { SetNextUpdate(UPDATE_DELTA + fOffset); } else { SetNextUpdate(0.0f); } Init(); SendEffectMessage(); return LTTRUE; }
void VolumeBrush::Update() { if (m_bHidden) return; // Only do updates if we have a surface... if (m_hSurfaceObj) { SetNextUpdate(UPDATE_DELTA); } else { SetNextUpdate(0.0f); } // See if we have moved... LTVector vPos; g_pLTServer->GetObjectPos(m_hObject, &vPos); if (!Equal(m_vLastPos, vPos)) { VEC_COPY(m_vLastPos, vPos); // Set the surface to its new position... LTVector vDims; g_pLTServer->GetObjectDims(m_hObject, &vDims); vPos.y += vDims.y - (m_fSurfaceHeight/2.0f); g_pLTServer->SetObjectPos(m_hSurfaceObj, &vPos); } }
// ----------------------------------------------------------------------- // // // ROUTINE: CoreDump::InitialUpdate // // PURPOSE: First update // // ----------------------------------------------------------------------- // LTBOOL CoreDump::InitialUpdate() { ObjectCreateStruct ocs; LTVector vPos; BaseClass* pObj; char szProps[1024]; char szFX[128]; // Get our position g_pLTServer->GetObjectPos(m_hObject,&vPos); // And create our clientFX at that position for(int i=0;i<MAX_CORE_DUMP_FX;i++) { // The string for the props of the SpecialFX object sprintf(szFX,"CoreDump_%d",i); sprintf(szProps,"FxName %s;Loop 1;SmoothShutdown 1",szFX); INIT_OBJECTCREATESTRUCT(ocs); ocs.m_Rotation.Init(); ocs.m_Pos = vPos; HCLASS hClass = g_pLTServer->GetClass("SpecialFX"); if(hClass) { // Here's where we actually create the object pObj = (BaseClass*)g_pLTServer->CreateObjectProps(hClass, &ocs, szProps); if(pObj) { // Store the HOBJECT in our array m_collFX[i] = pObj->m_hObject; } else { // Couldn't create the object ASSERT(FALSE); } } else { // Couldn't find the class ASSERT(FALSE); } } g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, USRFLG_CAN_ACTIVATE, USRFLG_CAN_ACTIVATE); // Here we go! (sanity check just in case we got an active message before our first update) if(!m_bActive) { SetNextUpdate(0.001f); } else { SetNextUpdate(0.0f); } return LTTRUE; }
// ----------------------------------------------------------------------- // // // ROUTINE: CoreDump::Update // // PURPOSE: Update function - drain some health/energy // // ----------------------------------------------------------------------- // LTBOOL CoreDump::Update() { // If we're updating, then we need to be decaying ASSERT(!m_bActive && !m_pPlayer); // If we've got -1.0f energy, we don't decay if(m_fTotalEnergy <= 0.0f) { SetNextUpdate(0.0f); return LTTRUE; } SetNextUpdate(0.001f); // Figure out how much to decay based on how much time has passed float fLastFrameDelta = g_pLTServer->GetFrameTime(); float fEnergyLoss = CORE_DUMP_DECAY_AMOUNT_PER_SECOND * fLastFrameDelta; if(fEnergyLoss >= m_fCurrentEnergy) { // We're done Term(); return LTTRUE; } else { // Take away some energy m_fCurrentEnergy -= fEnergyLoss; // See if we need to kill any clientFX float fPercentRemaining = m_fCurrentEnergy / m_fTotalEnergy; int nClientFX = (int)((fPercentRemaining * (float)MAX_CORE_DUMP_FX) + 1.0f); if(nClientFX >= MAX_CORE_DUMP_FX) return LTTRUE; char szFX[512]; // Go through and delete them for(int i=nClientFX;i<MAX_CORE_DUMP_FX;i++) { if(m_collFX[i]) { // If we delete one, let's spawn in a removal effect for it. sprintf(szFX,"CoreDumpRemove_%d",i); PlayClientFX(szFX,m_hObject); g_pLTServer->RemoveObject(m_collFX[i]); m_collFX[i] = NULL; } } } return LTTRUE; }
void PlayerVehicle::Update() { if (m_RespawnTimer.Stopped()) { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE); SetNextUpdate(UPDATE_NEVER); } else { SetNextUpdate(UPDATE_NEXT_FRAME); } }
bool Prop::OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg) { static CParsedMsg::CToken s_cTok_Anim("ANIM"); static CParsedMsg::CToken s_cTok_AnimLoop("ANIMLOOP"); static CParsedMsg::CToken s_cTok_Activate("ACTIVATE"); static CParsedMsg::CToken s_cTok_Remove("REMOVE"); static CParsedMsg::CToken s_cTok_Destroy("DESTROY"); uint32 dwFlags; g_pCommonLT->GetObjectFlags(m_hObject, OFT_User, dwFlags); if ( cMsg.GetArg(0) == s_cTok_Anim ) { g_pLTServer->SetModelLooping(m_hObject, LTFALSE); g_pLTServer->SetModelAnimation(m_hObject, g_pLTServer->GetAnimIndex(m_hObject, ( char* )( char const* )cMsg.GetArg( 1 ))); g_pLTServer->ResetModelAnimation(m_hObject); SetNextUpdate(UPDATE_NEXT_FRAME); // Needed to get string keys } else if ( cMsg.GetArg(0) == s_cTok_AnimLoop ) { g_pLTServer->SetModelLooping(m_hObject, LTTRUE); g_pLTServer->SetModelAnimation(m_hObject, g_pLTServer->GetAnimIndex(m_hObject, ( char* )( char const* )cMsg.GetArg( 1 ))); g_pLTServer->ResetModelAnimation(m_hObject); SetNextUpdate(UPDATE_NEXT_FRAME); // Needed to get string keys } else if ( cMsg.GetArg(0) == s_cTok_Activate ) { if(dwFlags & USRFLG_CAN_ACTIVATE) { SendActivateMessage( ); HandleTouch(hSender); } } else if( cMsg.GetArg(0) == s_cTok_Remove ) { // Remove us... g_pLTServer->RemoveObject( m_hObject ); } else if( cMsg.GetArg(0) == s_cTok_Destroy ) { m_damage.HandleDestruction( LTNULL ); HandleDestroy( LTNULL ); } else { return GameBase::OnTrigger(hSender, cMsg); } return true; }
LTBOOL NoPlayerTrigger::Update() { SetNextUpdate( UPDATE_DELTA ); // Find all the objects within the trigger... LTVector vDims; g_pPhysicsLT->GetObjectDims( m_hObject, &vDims ); LTVector vPos; g_pLTServer->GetObjectPos( m_hObject, &vPos ); LTVector vMin = vPos - vDims; LTVector vMax = vPos + vDims; ObjectList *pObjList = g_pLTServer->GetBoxIntersecters( &vMin, &vMax ); if( !pObjList ) return LTFALSE; // Count the number of players in the trigger and activate only if // NO players in the game are within the trigger... HOBJECT hObj; uint32 nPlayersInGame = CPlayerObj::GetNumberPlayersWithClients( ); bool bPlayersInTrigger = false; ObjectLink *pLink = pObjList->m_pFirstLink; while( pLink ) { hObj = pLink->m_hObject; if( hObj && IsPlayer( hObj )) { bPlayersInTrigger = true; break; } pLink = pLink->m_pNext; } g_pLTServer->RelinquishList( pObjList ); if( bPlayersInTrigger ) return LTFALSE; SetNextUpdate( UPDATE_NEVER ); // Ok! All the players are acounted for. // Let the base Trigger object activate. return Trigger::Activate(); }
void RotatingWorldModel::HandleTrigger(HOBJECT hSender, const char* szMsg) { if (m_eState == RWM_OFF && stricmp(szMsg, TRIGGER_MSG_ON) == 0) { SetSpinUp(); SetNextUpdate(RWM_UPDATE_DELTA); } else if (m_eState == RWM_NORMAL && stricmp(szMsg, TRIGGER_MSG_OFF) == 0) { SetSpinDown(); SetNextUpdate(RWM_UPDATE_DELTA); } }
void PlayerVehicle::Update() { if (m_RespawnTimer.Stopped()) { uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject); g_pLTServer->SetObjectFlags(m_hObject, dwFlags | FLAG_VISIBLE); SetNextUpdate(0.0); } else { SetNextUpdate(0.001f); } }
// ----------------------------------------------------------------------- // // // ROUTINE: CoreDump::HandleActivate // // PURPOSE: Start activating // // ----------------------------------------------------------------------- // void CoreDump::HandleActivate(HOBJECT hSender) { // Sanity checks if(m_bActive) { // We should never get an activate message when we're already activated g_pLTServer->CPrint("ERROR - CoreDump received an activate message when it was already being activated!\n"); ASSERT(FALSE); return; } if(!IsPlayer(hSender)) { g_pLTServer->CPrint("ERROR - CoreDump received an activate message from an object other than a player!\n"); ASSERT(FALSE); return; } CTronPlayerObj* pPlayer = (CTronPlayerObj*) g_pLTServer->HandleToObject(hSender); // We're all good m_pPlayer = pPlayer; m_bActive = true; // Stop the updating temporarily SetNextUpdate(0.0f); }
LTBOOL ScaleSprite::Update() { if (m_bStartOn) { g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, USRFLG_VISIBLE, USRFLG_VISIBLE); g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE); } SetNextUpdate(UPDATE_NEVER); // BUG - This isn't quite right. Sometimes this works (flipping the sprite) // other times the sprite shouldn't be flipped...Not sure what the bug is. // For some reason the sprites are sometimes backwards...Get the rotation // so we can flip it... LTRotation rRot; LTVector vPos, vDir, vU, vR, vF; g_pLTServer->GetObjectPos(m_hObject, &vPos); g_pLTServer->GetObjectRotation(m_hObject, &rRot); vU = rRot.Up(); vR = rRot.Right(); vF = rRot.Forward(); if (m_bFlushWithWorld) { // Align the sprite to the surface directly behind the sprite // (i.e., opposite the forward vector)... VEC_NORM(vF); VEC_MULSCALAR(vDir, vF, -1.0f); // Determine where on the surface to place the sprite... IntersectInfo iInfo; IntersectQuery qInfo; VEC_COPY(qInfo.m_From, vPos); VEC_COPY(qInfo.m_Direction, vDir); qInfo.m_Flags = IGNORE_NONSOLID | INTERSECT_OBJECTS | INTERSECT_HPOLY; qInfo.m_FilterFn = LTNULL; if (g_pLTServer->CastRay(&qInfo, &iInfo)) { LTVector vTemp; VEC_COPY(vPos, iInfo.m_Point); VEC_COPY(vDir, iInfo.m_Plane.m_Normal); // Place the sprite just above the surface... VEC_MULSCALAR(vTemp, vDir, 1.0f); VEC_ADD(vPos, vPos, vTemp); g_pLTServer->SetObjectPos(m_hObject, &vPos); } } return LTTRUE; }
// ----------------------------------------------------------------------- // // // ROUTINE: GunMount::StartFiring // // PURPOSE: Starts the firing state. // // ----------------------------------------------------------------------- // bool GunMount::StartFiring( ) { CWeapon* pWeapon = m_Arsenal.GetCurWeapon( ); if( !pWeapon ) return false; // Play the fire animation if they have it. HMODELANIM hAnim = pWeapon->GetFireAni( ); if( hAnim != INVALID_ANI ) { pWeapon->PlayAnimation( hAnim, true, false ); } // Fire the weapon. if( !FireWeapon( )) { return StartNotFiring( ); } m_eFiringState = eFiring; SetNextUpdate( UPDATE_NEXT_FRAME ); return true; }
void TextureFX::Load(ILTMessage_Read *pMsg, uint32 dwLoadFlags) { if (!pMsg) return; //read in the changed flag and the values for(uint32 nCurrStage = 0; nCurrStage < NUM_STAGES; nCurrStage++) { //read in the ID LOAD_DWORD(m_Stages[nCurrStage].m_nID); //read in the changed LOAD_BYTE(m_Stages[nCurrStage].m_nChanged); //read in the variables for(uint32 nCurrVar = 0; nCurrVar < NUM_VARS; nCurrVar++) { if(m_Stages[nCurrStage].m_nChanged & (1 << nCurrVar)) { //only read it in if it was flagges as being changed LOAD_FLOAT(m_Stages[nCurrStage].m_fVars[nCurrVar]); } } } m_bClientNeedsUpdate = true; SetNextUpdate(UPDATE_NEXT_FRAME); }
void Turret::InitialUpdate( ) { if( !CreateWeapon( )) return; // Set the base model diminsions... LTVector vDims; HMODELANIM hAnimBase = INVALID_MODEL_ANIM; g_pModelLT->GetCurAnim( m_hObject, MAIN_TRACKER, hAnimBase ); g_pModelLT->GetModelAnimUserDims (m_hObject, hAnimBase, &vDims); g_pPhysicsLT->SetObjectDims( m_hObject, &vDims, 0 ); if( g_pWeaponDB->GetBool( m_hTurret, WDB_TURRET_bHideBase )) g_pLTServer->SetObjectShadowLOD( m_hObject, eEngineLOD_Never ); // Make sure object starts on floor if the flag is set... if( m_bMoveToFloor ) { MoveObjectToFloor( m_hObject ); } // Do not remove the turret on death since the deactivation of the turret will be delayed... // The turret will be removed after the delay... m_Damage.m_DestructibleModelFlags = m_Damage.m_DestructibleModelFlags & ~CDestructibleModel::kDestructibleModelFlag_RemoveOnDeath; m_swtDestroyedDeactivationDelay.SetEngineTimer( SimulationTimer::Instance( )); CreateSpecialFX( false ); SetNextUpdate( UPDATE_NEXT_FRAME ); }
bool Spawner::InitialUpdate() { // Don't eat ticks please... SetNextUpdate(UPDATE_NEVER); return true; }
void Camera::Update() { LTVector vPos; g_pLTServer->GetObjectPos(m_hObject, &vPos); ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray; g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME,objArray); int numObjects = objArray.NumObjects(); for (int i = 0; i < numObjects; i++ ) { CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(objArray.GetObject(i)); if (pPlayer) { HCLIENT hClient = pPlayer->GetClient(); if (hClient) { g_pLTServer->SetClientViewPos(hClient, &vPos); } } } if (m_fActiveTime > 0.0f && g_pLTServer->GetTime() > m_fTurnOffTime) { TurnOff(); } else { SetNextUpdate(UPDATE_NEXT_FRAME); } }
void DecisionObject::InitialUpdate() { // Must be triggered on... SetNextUpdate(UPDATE_NEVER); }
bool DoomsDayDevice::BeginIdle( ) { TRACE( "DoomsDayDevice::BeginIdle\n" ); // Return to just the base model for now. if( !SetPropType( "Doomsday_base" )) { return false; } HMODELANIM hAnim = g_pLTServer->GetAnimIndex( m_hObject, "base" ); if( hAnim == INVALID_ANI ) { ASSERT( !"DoomsDayDevice::BeginIdle: Invalid animation." ); return false; } g_pLTServer->SetModelAnimation( m_hObject, hAnim ); g_pLTServer->SetModelLooping( m_hObject, LTFALSE ); g_pLTServer->ResetModelAnimation( m_hObject ); // Do one update. SetNextUpdate( UPDATE_NEXT_FRAME ); m_eDoomsDayDeviceState = kDoomsDayDeviceState_Idle; return true; }
void CinematicTrigger::HandleOn() { m_bOn = LTTRUE; if (m_bRemoveBadAI) { RemoveBadAI(); } // Turn on the camera... if (m_hCamera) { SendTriggerMsgToObject(this, m_hCamera, FALSE, "ON"); } // Turn on the keyframer... if (m_hKeyFramer) { SendTriggerMsgToObject(this, m_hKeyFramer, FALSE, "ON"); } // Make sure we're starting fresh... m_nCurMessage = 0; m_byDecision = 0; m_byLastReply = 0; m_bDialogueDone = LTFALSE; m_fNextDialogueStart = g_pLTServer->GetTime() + m_fDelay[0]; SetNextUpdate(m_hObject, 0.001f); }
void Turret::Activate( HOBJECT hSender ) { if( IsInUse( ) || m_Damage.IsDead( )) return; if( m_swtDestroyedDeactivationDelay.IsStarted( )) { g_pLTServer->CPrint( "Activated with deactivation delay" ); } // Activating turret... m_hOperatingObject = hSender; CreateSpecialFX( true ); if( IsPlayer( m_hOperatingObject )) { // Change the players weapon to the turret weapon... CPlayerObj *pPlayer = dynamic_cast<CPlayerObj*>(g_pLTServer->HandleToObject( m_hOperatingObject )); pPlayer->SetOperatingTurret( *this, true ); } // Process any activation command we may have... if( !m_sActivateCommand.empty( )) { g_pCmdMgr->QueueCommand( m_sActivateCommand.c_str( ), hSender, m_hObject ); } SetNextUpdate( UPDATE_NEXT_FRAME ); }
void DisplayTimer::HandleStart(LTFLOAT fTime) { if (fTime <= 0.0f) return; if (m_hstrStartCmd) { const char* pCmd = g_pLTServer->GetStringData(m_hstrStartCmd); if (pCmd && g_pCmdMgr->IsValidCmd(pCmd)) { g_pCmdMgr->Process(pCmd, m_hObject, m_hObject); } } m_Timer.Start(fTime); // Send message to clients telling them about the DisplayTimer... UpdateClients(); // Update the DisplayTimer... SetNextUpdate(UPDATE_NEXT_FRAME); }
void RotatingWorldModel::Update() { // Handle the first update if (m_bFirstUpdate) FirstUpdate(); LTFLOAT fUpdateDelta = RWM_UPDATE_DELTA; switch (m_eState) { case RWM_SPINUP: UpdateSpinUp(); break; case RWM_SPINDOWN: UpdateSpinDown(); break; case RWM_OFF: fUpdateDelta = 0.0f; break; case RWM_NORMAL: default: UpdateNormalRotation(); break; } SetNextUpdate(fUpdateDelta); }
void Camera::TurnOff(bool bSkip /* = false*/) { // Process the clean up command... if( !m_sCleanupCmd.empty() ) { g_pCmdMgr->QueueCommand( m_sCleanupCmd.c_str(), m_hObject, m_hObject ); } // [KLS 3/3/02] - If were skipping a cinematic and we're set to only do cleanup // we're done... if (bSkip && m_bOnSkipCleanupOnly) return; if (m_bOn) { if (sm_nActiveCamera > 0) { sm_nActiveCamera--; } m_bOn = false; } g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, 0, USRFLG_CAMERA_LIVE); SetNextUpdate(UPDATE_NEVER); if (m_bOneTime) { g_pLTServer->RemoveObject(m_hObject); } }
void WorldModel::OnObjectCreated( ) { uint32 dwFlags; uint32 dwUserFlags = 0; g_pCommonLT->GetObjectFlags( m_hObject, OFT_Flags, dwFlags ); // Set movable flag if we can be destroyed if( m_bIsKeyframed || (m_DamageModel.GetCanDamage() && !m_DamageModel.GetNeverDestroy()) ) { dwUserFlags |= USRFLG_MOVEABLE; } if( dwFlags & FLAG_VISIBLE ) { dwUserFlags |= USRFLG_VISIBLE; } g_pCommonLT->SetObjectFlags( m_hObject, OFT_User, dwUserFlags, USRFLG_MOVEABLE | USRFLG_VISIBLE ); if( m_bStartHidden ) { SendTriggerMsgToObject( this, m_hObject, LTFALSE, "Hidden 1" ); } // Don't update us yet SetNextUpdate( UPDATE_NEVER ); }
LTBOOL NoPlayerTrigger::Activate() { // Start the update SetNextUpdate( UPDATE_DELTA ); return LTTRUE; }
uint32 LightGroup::EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData) { switch(messageID) { case MID_PRECREATE: { ObjectCreateStruct *pOCS = (ObjectCreateStruct*)pData; if (!pOCS) break; if( fData == PRECREATE_WORLDFILE ) { ReadProp(pOCS); } PostReadProp(pOCS); } break; case MID_INITIALUPDATE: { if( fData != INITIALUPDATE_SAVEGAME ) { InitialUpdate(); } } break; case MID_SAVEOBJECT: { Save((ILTMessage_Write*)pData, (uint32)fData); } break; case MID_LOADOBJECT: { Load((ILTMessage_Read*)pData, (uint32)fData); } break; case MID_UPDATE: { // Send a new update if we were waiting for the client to do something if (m_bClientNeedsUpdate) { UpdateClients(); // Turn back off SetNextUpdate(m_hObject, UPDATE_NEVER); } } break; default : break; } return Engine_LightGroup::EngineMessageFn(messageID, pData, fData); }
void DisplayTimer::InitialUpdate() { // Must be triggered on... // Make sure our sfx message is told to the client. g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags, FLAG_FORCECLIENTUPDATE, FLAG_FORCECLIENTUPDATE ); SetNextUpdate(UPDATE_NEVER); }
void SpinningWorldModel::SetOn( LTBOOL bInitialize ) { ActiveWorldModel::SetOn( bInitialize ); m_fLastTime = g_pLTServer->GetTime(); // Keep spinning... SetNextUpdate( UPDATE_NEXT_FRAME ); }
void LightGroup::Load(ILTMessage_Read *pMsg, uint32 dwLoadFlags) { if (!pMsg) return; LOAD_bool(m_bOn); LOAD_VECTOR(m_vColor); m_bClientNeedsUpdate = true; SetNextUpdate(m_hObject, UPDATE_NEXT_FRAME); }