void AircraftClass::SwitchINSToInFLT(void) { /*if(INSState(INS_PowerOff)) { INSAlignmentTimer = 0.0F; HasAligned = FALSE; }*/ if(OnGround()) return; INSOn(INS_AlignFlight); INSOff(INS_AlignNorm); INSOff(INS_PowerOff); INSOff(INS_Nav); INSAlignmentStart = vuxGameTime; INSAlign = TRUE; INSAlignmentTimer = 0.0F; HasAligned = FALSE; INSStatus = 99; INSTimeDiff = 0.0F; //Set the UFC if(OTWDriver.pCockpitManager && OTWDriver.pCockpitManager->mpIcp) { OTWDriver.pCockpitManager->mpIcp->ClearStrings(); OTWDriver.pCockpitManager->mpIcp->LeaveCNI(); OTWDriver.pCockpitManager->mpIcp->SetICPFlag(ICPClass::MODE_LIST); OTWDriver.pCockpitManager->mpIcp->SetICPSecondaryMode(23); //SIX Button, INS Page OTWDriver.pCockpitManager->mpIcp->INSLine = 3; } }
//apply a friction for the speeds void TCompCharacterController::UpdateFriction(float dt) { PROFILE_FUNCTION("update: friction"); //update speeds with friction assert(isValid(m_speed)); float friction = OnGround() ? m_friction : m_friction_air; if (m_speed.x != 0.0f) m_speed.x -= m_speed.x*friction*dt; if (m_speed.z != 0.0f) m_speed.z -= m_speed.z*friction*dt; assert(isValid(m_speed)); }
void AircraftClass::RunINS(void) { if(INSAlign && INSState(INS_AlignNorm) || INSState(INS_AlignFlight)) { if((OnGround() && GetKias() <= 2.0F && !INS60kts) || INSState(INS_AlignFlight)) DoINSAlign(); else INSAlign = FALSE; } else if(INSState(INS_AlignNorm) && !INS60kts) { INSAlign = TRUE; } if(INSStatus <= 90) { //ADI OFF Flag goes away INSOn(AircraftClass::INS_ADI_OFF_IN); INSOn(AircraftClass::INS_HUD_STUFF); INSOn(AircraftClass::INS_HSI_OFF_IN); INSOn(AircraftClass::INS_HSD_STUFF); } else if(!HasAligned) { //ADI OFF Flag goes away INSOff(AircraftClass::INS_ADI_OFF_IN); INSOff(AircraftClass::INS_HUD_STUFF); INSOff(AircraftClass::INS_HSI_OFF_IN); INSOff(AircraftClass::INS_HSD_STUFF); } if(INSStatus <= 79) { //ADI AUX Flag goes away INSOn(AircraftClass::INS_ADI_AUX_IN); } else INSOff(AircraftClass::INS_ADI_AUX_IN); if(INSStatus <= 70) HasAligned = TRUE; else HasAligned = FALSE; if(INSStatus <= 10) INSOn(INS_Aligned); else INSOff(INS_Aligned); CheckINSStatus(); if(INSState(INS_Nav)) CalcINSDrift(); else INSLatDrift = 0.0F; if(GetKias() >= 60 && OnGround() && INSState(INS_AlignNorm)) INS60kts = TRUE; //needs to be turned off //Check for power if(currentPower == PowerNone) //Emergency bus { //SwitchINSToOff(); INSAlignmentTimer = 0.0F; INSAlignmentStart = vuxGameTime; INSAlign = FALSE; HasAligned = FALSE; INSStatus = 99; INSTimeDiff = 0.0F; INS60kts = FALSE; HasAligned = FALSE; CheckUFC = TRUE; } }
//Update the position based off the most recent movement and direction vectors bool ActorPlayer::Update() { // If the weapon is null, don't do shit if(currentWeapon == NULL) return PhysicsActor::Update(); // Get the movement vector from the first person controller vec2 moveVector = Game()->FirstPerson->GetMoveVector(); // Calculate the direction we are facing facingDirection = atan2(moveVector.y, moveVector.x); // Calculate the magnitude of the movement vector (are we sprinting) float magnitude = glm::length(moveVector); // Check if we should switch weapons if(Game()->FirstPerson->GetSwitchWeaponRequested()) { //switch weapons to the next weapon which has been purchased for (int i = (currentWeaponId+1) % weapons.size(); i != currentWeaponId; i = (i+1) % weapons.size()) { //A damage factor of <= 0 indicates the weapon is currently locked if (weapons[i]->Modifiers.DamageFactor > 0) { setWeapon(i); break; } } } // Update the weapon currentWeapon->Update(Game()->FirstPerson->GetLookVector(), weaponPos); // Forward whether or not we want to shoot to the player's weapon animation controller bool r = currentWeapon->HoldingTrigger(Game()->FirstPerson->GetTriggerPulled()); model->Controller()->SetBoolean("firing", r); // if we fired the weapon, update the state machine //but only if its not the pulseLaser, no idea why if(r && (currentWeaponId == 0)) model->Update(SIMULATION_DELTA, Game()->Now()); // Forward the weapon mode to the controller model->Controller()->SetBoolean("mode", (currentWeaponId == 0) ? true : false); // Forward the movement speed to the player's weapon animation controller model->Controller()->SetFloat("speed", OnGround() ? magnitude : 0.0f); // Use the movement vector to set the velocity of the player's physics object Velocity.x = moveVector.x * movementSpeed; Velocity.y = moveVector.y * movementSpeed; // Have we walked more than 200 units? if(deltaPosition > 200 && OnGround()) { // Fire the actor walked event Game()->Actors.ActorWalked.Fire([this](function<void(ActorPlayer*)> subscriber) { subscriber(this); }); //cout << "Player Position: " << Position.x << "," << Position.y << "," << Position.z << endl; deltaPosition -=200; } // If we haven't, check if we should add more distance to our odometer else { if(OnGround()) { deltaPosition+= sqrt(pow(Velocity.x,2)+pow(Velocity.y,2)); } } // Lets check if the controller wants us to jump if(Game()->FirstPerson->GetJumpRequested()) { // Check that the user is on the ground //and does not have any velocity upwards if (OnGround() && (Velocity.z < .025)) { // Apply upwards velocity Velocity.z += jumpVelocity; // First the event that we'e Game()->Actors.ActorJumped.Fire([this](function<void(ActorPlayer*)> subscriber) { subscriber(this); }); } } //Run autojump? if (VoxEngine::SavedDeviceData.GameOptions.Autojump > 0) { //Autojump if (glm::length(moveVector) > .15) { //Only jump if you're touching ground bool touchingGround = (OnGround() && Velocity.z < .2); //Check if you've got terrain (cliff/hill) directly in front of you //Check just a bit above your feet float feetHeight = Position.z-Size.z/2.0f; float checkHeight = feetHeight+.5f; float rayLength; vec3 surfaceNormal; vec3 traceDirection = vec3(moveVector,0); if (Game()->Voxels.RaytraceToTerrain(vec3(Position.x,Position.y,checkHeight),traceDirection,rayLength,surfaceNormal)) { if (rayLength < 1.5) { //Check the height of the given location //add .15 to go pas the surface and onto the voxel itself vec3 upcomingTerrain = vec3(Position.x,Position.y,checkHeight) + traceDirection*(rayLength+.15f); float upcomingHeight = Game()->Voxels.GetPositionHeight(vec2(upcomingTerrain)); //Now check if you're too low if (feetHeight+.15 < upcomingHeight) { if (touchingGround) { //Ok lets jump up //Playing some kind of jump animation would be A+ Velocity.z += min(15*(upcomingHeight-feetHeight),20.0f); //jump! } } } } } } // Return the result of the update of the super class return PhysicsActor::Update(); }
void HelicopterClass::RunExplosion (void) { int i; Tpoint pos; Falcon4EntityClassType *classPtr; SimBaseClass *tmpSimBase; Tpoint tp = Origin; Trotation tr = IMatrix; // F4PlaySound (SFX_DEF[SFX_OWNSHIP_BOOM].handle); //F4SoundFXSetPos( SFX_BOOMA1 + PRANDInt5(), TRUE, XPos(), YPos(), ZPos(), 1.0f ); SoundPos.Sfx( SFX_BOOMA1 + PRANDInt5() ); // MLR 5/16/2004 - // 1st do primary explosion pos.x = XPos(); pos.y = YPos(); pos.z = ZPos(); if ( OnGround( ) ) { pos.z = OTWDriver.GetGroundLevel( pos.x, pos.y ) - 4.0f; SetDelta( XDelta() * 0.1f, YDelta() * 0.1f, -50.0f ); OTWDriver.AddSfxRequest( new SfxClass (SFX_GROUND_EXPLOSION, // type &pos, // world pos 1.2f, // time to live 100.0f ) ); // scale } else { OTWDriver.AddSfxRequest( new SfxClass (SFX_AIR_HANGING_EXPLOSION, // type &pos, // world pos 2.0f, // time to live 200.0f + 200 * PRANDFloatPos() ) ); // scale } classPtr = (Falcon4EntityClassType*)EntityType(); // Add the parts (appairently hardcoded at 4) // Recoded by KCK on 6/23 to remove damage station BS for (i=0; i<4; i++) { tmpSimBase = new SimBaseClass(Type()); CalcTransformMatrix (tmpSimBase); OTWDriver.CreateVisualObject(tmpSimBase, classPtr->visType[i+2], &tp, &tr, OTWDriver.Scale()); tmpSimBase->SetPosition (pos.x, pos.y, pos.z); if (!i) { tmpSimBase->SetDelta (XDelta(), YDelta(), ZDelta()); } if (!OnGround()) { tmpSimBase->SetDelta ( XDelta() + 50.0f * PRANDFloat(), YDelta() + 50.0f * PRANDFloat(), ZDelta() + 50.0f * PRANDFloat() ); } else { tmpSimBase->SetDelta ( XDelta() + 50.0f * PRANDFloat(), YDelta() + 50.0f * PRANDFloat(), ZDelta() - 50.0f * PRANDFloatPos() ); } tmpSimBase->SetYPR (Yaw(), Pitch(), Roll()); if (!i) { // First peice is more steady and is flaming tmpSimBase->SetYPRDelta ( 0.0F, 0.0F, 10.0F + PRANDFloat() * 30.0F * DTR); OTWDriver.AddSfxRequest( new SfxClass (SFX_FLAMING_PART, // type SFX_MOVES | SFX_USES_GRAVITY | SFX_EXPLODE_WHEN_DONE, tmpSimBase, // sim base * 3.0f + PRANDFloatPos() * 4.0F, // time to live 1.0F ) ); // scale } else { // spin piece a random amount tmpSimBase->SetYPRDelta ( PRANDFloat() * 30.0F * DTR, PRANDFloat() * 30.0F * DTR, PRANDFloat() * 30.0F * DTR); OTWDriver.AddSfxRequest( new SfxClass (SFX_SMOKING_PART, // type SFX_MOVES | SFX_USES_GRAVITY | SFX_BOUNCES | SFX_EXPLODE_WHEN_DONE, tmpSimBase, // sim base * 4.0f * PRANDFloatPos() + (float)((i+1)*(i+1)), // time to live 1.0 ) ); // scale } } }