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 ); }
void PlayerVehicle::Respawn() { LTFLOAT fRespawnTime = m_fRespawnTime; if (fRespawnTime >= 0.0f) { g_pLTServer->SetObjectPos(m_hObject, &m_vOriginalPos); g_pLTServer->SetObjectRotation(m_hObject, &m_rOriginalRot); LTVector vZero(0, 0, 0); g_pLTServer->SetVelocity(m_hObject, &vZero); g_pLTServer->SetAcceleration(m_hObject, &vZero); } else { fRespawnTime = 0.0f; } // Try to set our dims (make sure we fit where we were placed)... LTVector vDims = m_vOriginalDims; if (g_pLTServer->SetObjectDims2(m_hObject, &vDims) == LT_ERROR) { g_pLTServer->SetObjectDims2(m_hObject, &vDims); } LTVector vVec(0, 0, 0); g_pLTServer->SetAcceleration(m_hObject, &vVec); g_pLTServer->SetVelocity(m_hObject, &vVec); uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject); dwFlags &= ~FLAG_VISIBLE; dwFlags &= ~FLAG_GRAVITY; g_pLTServer->SetObjectFlags(m_hObject, dwFlags); m_RespawnTimer.Start(fRespawnTime); SetNextUpdate(0.001f); MoveObjectToFloor(m_hObject); }
void PlayerVehicle::Respawn() { LTFLOAT fRespawnTime = m_fRespawnTime; if (fRespawnTime >= 0.0f) { g_pLTServer->SetObjectPos(m_hObject, &m_vOriginalPos); g_pLTServer->SetObjectRotation(m_hObject, &m_rOriginalRot); LTVector vZero(0, 0, 0); g_pPhysicsLT->SetVelocity(m_hObject, &vZero); } else { fRespawnTime = 0.0f; } // Try to set our dims (make sure we fit where we were placed)... LTVector vDims = m_vOriginalDims; if (g_pPhysicsLT->SetObjectDims(m_hObject, &vDims, SETDIMS_PUSHOBJECTS) == LT_ERROR) { g_pPhysicsLT->SetObjectDims(m_hObject, &vDims, 0); } LTVector vVec(0, 0, 0); g_pPhysicsLT->SetVelocity(m_hObject, &vVec); g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE ); m_RespawnTimer.Start(fRespawnTime); SetNextUpdate(UPDATE_NEXT_FRAME); MoveObjectToFloor(m_hObject); }
LTBOOL PickupItem::InitialUpdate() { SetNextUpdate(UPDATE_NEVER); if (!g_RespawnScaleTrack.IsInitted()) { g_RespawnScaleTrack.Init(GetServerDE(), "RespawnScale", LTNULL, 1.0f); } // Set up our user flags... g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, m_dwUserFlags, m_dwUserFlags); // set a special fx message so that the client knows about the pickup item... // (so it can handle bouncing, rotating, and displaying the proper targeting text...) CreateSpecialFX(); g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, m_dwFlags, m_dwFlags); // Look for an animation specified in DEdit... uint32 dwAni = INVALID_ANI; if( !m_sWorldAniName.empty()) { dwAni = g_pLTServer->GetAnimIndex(m_hObject, m_sWorldAniName.c_str()); } if (dwAni != INVALID_ANI) { g_pLTServer->SetModelAnimation(m_hObject, dwAni); } else { // If we couldn't find the ani look for the world ani. ALL PickUps should have a "World" ani... dwAni = g_pLTServer->GetAnimIndex( m_hObject, "World" ); if( dwAni != INVALID_ANI ) { g_pLTServer->SetModelAnimation( m_hObject, dwAni ); } } // Set the dims based on the current animation... LTVector vDims; g_pCommonLT->GetModelAnimUserDims(m_hObject, &vDims, g_pLTServer->GetModelAnimation(m_hObject)); // Set object dims based on scale value... LTVector vNewDims; vNewDims.x = m_vScale.x * vDims.x; vNewDims.y = m_vScale.y * vDims.y; vNewDims.z = m_vScale.z * vDims.z; g_pLTServer->ScaleObject(m_hObject, &m_vScale); g_pPhysicsLT->SetObjectDims(m_hObject, &vNewDims, 0); // Make sure object starts on floor if the gravity flag is set... if(m_bMoveToFloor) { MoveObjectToFloor(m_hObject); } return LTTRUE; }
void Prop::Update() { if (m_bFirstUpdate && m_bMoveToFloor) { // Make sure object starts on floor... m_bFirstUpdate = LTFALSE; MoveObjectToFloor(m_hObject); SetNextUpdate(UPDATE_NEXT_FRAME); } else if( m_pDisturb && (m_eState == kState_PropTouching) ) { HandleTouch(LTNULL); } else if( m_pDisturb && (m_eState == kState_PropHit) ) { HandleHit(LTNULL); } else if( m_bRotating ) { if( m_fPitchVel != 0 || m_fYawVel != 0 || m_fRollVel != 0 ) { float fDeltaTime = g_pLTServer->GetFrameTime(); m_fPitch += m_fPitchVel * fDeltaTime; m_fYaw += m_fYawVel * fDeltaTime; m_fRoll += m_fRollVel * fDeltaTime; LTRotation rRot( m_fPitch, m_fYaw, m_fRoll ); g_pLTServer->SetObjectRotation( m_hObject, &rRot ); SetNextUpdate(UPDATE_NEXT_FRAME); } } else if ( m_bFading ) { UpdateFade(); } else if ( m_bCanDeactivate ) { // At this point the model only needs to get updates if we're playing // a non-looping animation so we can deactivate the object when the animation // is done playing. However, if the model is playing a looping animation // we'll stop updating but leave the object active (so it will continue to // animate and get key strings)... // See if we're animating... HMODELANIM hAnim = g_pLTServer->GetModelAnimation(m_hObject); if (hAnim != INVALID_ANI) { if (g_pLTServer->GetModelLooping(m_hObject)) { // We're playing a looping animation that is long enough, don't deactivate, // just stop updating the object (since the state can only be changed // externally)...NOTE: Short animations are default anis that you can't // see so we'll deactivate in those cases... uint32 nLength = 0; g_pModelLT->GetAnimLength(m_hObject, hAnim, nLength); if (nLength > 200) { SetNextUpdate(UPDATE_NEVER, eControlUpdateOnly); } else { SetNextUpdate(UPDATE_NEVER); } } else // Playing a non-looping animation... { bool bAniDone = !!(MS_PLAYDONE & g_pLTServer->GetModelPlaybackState(m_hObject)); if (bAniDone) { // Cool we can stop updating SetNextUpdate(UPDATE_NEVER); } else { // Keep updating until the animation is done... SetNextUpdate(UPDATE_NEXT_FRAME); } } } else // Not animating so no reason to update... { SetNextUpdate(UPDATE_NEVER); } } else { // Just keep updating SetNextUpdate(UPDATE_NEXT_FRAME); } }
uint32 Prop::EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData) { switch(messageID) { case MID_TOUCHNOTIFY: { HandleTouch((HOBJECT)pData); } break; case MID_UPDATE: { // Make sure object starts on floor... if (m_bFirstUpdate && m_bMoveToFloor) { m_bFirstUpdate = LTFALSE; MoveObjectToFloor(m_hObject); } } break; case MID_PRECREATE: { if (fData == PRECREATE_WORLDFILE || fData == PRECREATE_STRINGPROP) { ObjectCreateStruct* pStruct = (ObjectCreateStruct*)pData; ReadProp(pStruct); // If this prop is spawned, assume it should be visible (if they // specify Visible 0, our parent class will handle it ;) if (fData == PRECREATE_STRINGPROP) { m_dwFlags |= FLAG_VISIBLE; } } uint32 dwRet = GameBase::EngineMessageFn(messageID, pData, fData); PostPropRead((ObjectCreateStruct*)pData); CacheFiles(); return dwRet; } break; case MID_INITIALUPDATE: { if (fData != INITIALUPDATE_SAVEGAME) { InitialUpdate(); } } break; case MID_SAVEOBJECT: { Save((HMESSAGEWRITE)pData, (uint32)fData); } break; case MID_LOADOBJECT: { Load((HMESSAGEREAD)pData, (uint32)fData); } break; default : break; } return GameBase::EngineMessageFn(messageID, pData, fData); }