void Player::SetFlightControlState(enum FlightControlState s) { m_flightControlState = s; if (m_flightControlState == CONTROL_AUTOPILOT) { AIClearInstructions(); } else if (m_flightControlState == CONTROL_FIXSPEED) { AIClearInstructions(); m_setSpeed = m_setSpeedTarget ? GetVelocityRelTo(m_setSpeedTarget).Length() : GetVelocity().Length(); } else { AIClearInstructions(); } Pi::onPlayerChangeFlightControlState.emit(); }
void Ship::AIOrbit(Body *target, double alt) { AIClearInstructions(); SetFuelReserve((GetFuel() < 0.5) ? GetFuel() / 2 : 0.25); m_curAICmd = new AICmdFlyAround(this, target, alt); }
void Ship::AIDock(SpaceStation *target) { AIClearInstructions(); SetFuelReserve((GetFuel() < 0.5) ? GetFuel() / 2 : 0.25); m_curAICmd = new AICmdDock(this, target); }
void Ship::AIKill(Ship *target) { AIClearInstructions(); SetFuelReserve((GetFuel() < 0.5) ? GetFuel() / 2 : 0.25); m_curAICmd = new AICmdKill(this, target); }
void Ship::AIFlyTo(Body *target) { AIClearInstructions(); SetFuelReserve((GetFuel() < 0.5) ? GetFuel() / 2 : 0.25); if (target->IsType(Object::SHIP)) { // test code vector3d posoff(-1000.0, 0.0, 1000.0); m_curAICmd = new AICmdFormation(this, static_cast<Ship*>(target), posoff); } else m_curAICmd = new AICmdFlyTo(this, target); }
// returns true if command is complete bool Ship::AITimeStep(float timeStep) { // allow the launch thruster thing to happen if (m_launchLockTimeout > 0.0) return false; if (!m_curAICmd) { if (this == Pi::player) return true; // just in case the AI left it on ClearThrusterState(); for (int i=0; i<ShipType::GUNMOUNT_MAX; i++) SetGunState(i,0); return true; } if (m_curAICmd->TimeStepUpdate()) { AIClearInstructions(); // ClearThrusterState(); // otherwise it does one timestep at 10k and gravity is fatal Pi::luaOnAICompleted->Queue(this); return true; } else return false; }
// returns true if command is complete bool Ship::AITimeStep(float timeStep) { // allow the launch thruster thing to happen if (m_launchLockTimeout > 0.0) return false; m_decelerating = false; if (!m_curAICmd) { if (this == Pi::player) return true; // just in case the AI left it on ClearThrusterState(); for (int i=0; i<ShipType::GUNMOUNT_MAX; i++) SetGunState(i,0); return true; } if (m_curAICmd->TimeStepUpdate()) { AIClearInstructions(); // ClearThrusterState(); // otherwise it does one timestep at 10k and gravity is fatal LuaEvent::Queue("onAICompleted", this, EnumStrings::GetString("ShipAIError", AIMessage())); return true; } else return false; }
void Ship::AIHoldPosition() { AIClearInstructions(); m_curAICmd = new AICmdHoldPosition(this); }
void Ship::AIKamikaze(Body *target) { AIClearInstructions(); m_curAICmd = new AICmdKamikaze(this, target); }
void Ship::AIOrbit(Body *target, double alt) { AIClearInstructions(); m_curAICmd = new AICmdFlyTo(this, target, alt); }
void Ship::AIDock(SpaceStation *target) { AIClearInstructions(); m_curAICmd = new AICmdDock(this, target); }
void Ship::AIFlyTo(Body *target) { AIClearInstructions(); m_curAICmd = new AICmdFlyTo(this, target); }
void Ship::AIKill(Ship *target) { AIClearInstructions(); m_curAICmd = new AICmdKill(this, target); }