void CAirCAI::BuggerOff(float3 pos, float radius) { AAirMoveType* myPlane = dynamic_cast<AAirMoveType*>(owner->moveType); if(myPlane) { myPlane->Takeoff(); } else { CMobileCAI::BuggerOff(pos, radius); } }
void CMobileCAI::GiveCommandReal(const Command &c, bool fromSynced) { if (!AllowedCommand(c, fromSynced)) return; if (owner->unitDef->canfly && c.id == CMD_AUTOREPAIRLEVEL) { if (c.params.empty()) { return; } AAirMoveType* airMT = GetAirMoveType<AAirMoveType>(owner); if (!airMT) return; switch ((int) c.params[0]) { case 0: { airMT->repairBelowHealth = 0.0f; break; } case 1: { airMT->repairBelowHealth = 0.3f; break; } case 2: { airMT->repairBelowHealth = 0.5f; break; } case 3: { airMT->repairBelowHealth = 0.8f; break; } } for (vector<CommandDescription>::iterator cdi = possibleCommands.begin(); cdi != possibleCommands.end(); ++cdi) { if (cdi->id == CMD_AUTOREPAIRLEVEL) { char t[10]; SNPRINTF(t, 10, "%d", (int) c.params[0]); cdi->params[0] = t; break; } } selectedUnits.PossibleCommandChange(owner); return; } if (owner->unitDef->canfly && c.id == CMD_IDLEMODE) { if (c.params.empty()) { return; } AAirMoveType* airMT = GetAirMoveType<AAirMoveType>(owner); if (!airMT) return; switch ((int) c.params[0]) { case 0: { airMT->autoLand = false; airMT->Takeoff(); break; } case 1: { airMT->autoLand = true; break; } } for (vector<CommandDescription>::iterator cdi = possibleCommands.begin(); cdi != possibleCommands.end(); ++cdi) { if (cdi->id == CMD_IDLEMODE) { char t[10]; SNPRINTF(t, 10, "%d", (int) c.params[0]); cdi->params[0] = t; break; } } selectedUnits.PossibleCommandChange(owner); return; } if (!(c.options & SHIFT_KEY) && nonQueingCommands.find(c.id) == nonQueingCommands.end()) { tempOrder = false; StopSlowGuard(); } CCommandAI::GiveAllowedCommand(c); }
void CAirCAI::SlowUpdate() { // Commands issued may invoke SlowUpdate when paused if (gs->paused) return; if (!commandQue.empty() && (commandQue.front().timeOut < gs->frameNum)) { FinishCommand(); return; } // avoid the invalid (CStrafeAirMoveType*) cast if (owner->UsingScriptMoveType()) return; const bool wantToRefuel = (LandRepairIfNeeded() || RefuelIfNeeded()); #if (AUTO_GENERATE_ATTACK_ORDERS == 1) if (commandQue.empty()) { if (!AirAutoGenerateTarget(GetStrafeAirMoveType(owner))) { // if no target found, queue is still empty so bail now return; } } #endif // FIXME: check owner->UsingScriptMoveType() and skip rest if true? AAirMoveType* myPlane = GetStrafeAirMoveType(owner); Command& c = commandQue.front(); if (c.GetID() == CMD_WAIT) { if ((myPlane->aircraftState == AAirMoveType::AIRCRAFT_FLYING) && !owner->unitDef->DontLand() && myPlane->autoLand) { StopMove(); } return; } if (c.GetID() != CMD_STOP && c.GetID() != CMD_AUTOREPAIRLEVEL && c.GetID() != CMD_IDLEMODE && c.GetID() != CMD_SET_WANTED_MAX_SPEED) { myPlane->Takeoff(); } if (wantToRefuel) { switch (c.GetID()) { case CMD_AREA_ATTACK: case CMD_ATTACK: case CMD_FIGHT: return; } } switch (c.GetID()) { case CMD_AREA_ATTACK: { ExecuteAreaAttack(c); return; } default: { CMobileCAI::Execute(); return; } } }