MOOSE demonstration missions [skip ci]

This commit is contained in:
FlightControl-User
2020-10-04 10:50:50 +00:00
parent 8227d1510c
commit 8f84ac6067
403 changed files with 303 additions and 0 deletions

View File

@@ -0,0 +1,138 @@
---
-- FLIGHTGROUP: Basics
--
-- 4-ship Hornet group is stationed at Batumi.
-- * Add waypoints manually.
-- * Check when entering and leaving zones.
-- * Change formation when passing waypoints.
-- * Test FSM events.
---
-- Create flight group.
local flightgroup=FLIGHTGROUP:New("F/A-18 Batumi")
flightgroup:Activate()
-- Set of all zones defined in the ME.
local AllZones=SET_ZONE:New():FilterOnce()
-- Set a set of zones which are checked and trigger FSM events when the group enters or leaves the zones.
flightgroup:SetCheckZones(AllZones)
-- Common zones.
local Zone={}
Zone.Alpha = ZONE:New("Zone Alpha") --Core.Zone#ZONE
Zone.Bravo = ZONE:New("Zone Bravo") --Core.Zone#ZONE
Zone.Charlie = ZONE:New("Zone Charlie") --Core.Zone#ZONE
Zone.Delta = ZONE:New("Zone Delta") --Core.Zone#ZONE
-- Add a couple of waypoints.
local wp1=flightgroup:AddWaypoint(Zone.Alpha:GetCoordinate(), 350, nil, 5000)
local wp2=flightgroup:AddWaypoint(Zone.Bravo:GetCoordinate(), 300, nil, 2000)
local wp3=flightgroup:AddWaypoint(Zone.Delta:GetCoordinate(), 450, nil, 7000)
local wp4=flightgroup:AddWaypoint(Zone.Charlie:GetCoordinate(), 300, nil, 5000)
--- Function called when the group passes a waypoint.
function flightgroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
-- Get the unique ID of this waypoint.
-- NOTE that the UID does not change when new waypoints are added or removed.
local uid=flightgroup:GetWaypointUID(waypoint)
-- Debug message.
local text=string.format("Group passed waypoint UID=%d", uid)
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
-- Check which waypoint was passed.
if uid==wp1.uid then
-- Switch radio and activate TACAN at this waypoint.
flightgroup:SwitchRadio(255)
flightgroup:SwitchTACAN(64, "ABC")
elseif uid==wp2.uid then
flightgroup:SwitchFormation(ENUMS.Formation.FixedWing.LineAbreast.Open)
elseif uid==wp3.uid then
flightgroup:SwitchFormation(ENUMS.Formation.FixedWing.FingerFour.Close)
end
end
--- Function called when the group enteres a zone.
function flightgroup:OnAfterEnterZone(From, Event, To, zone)
local text=string.format("Group entered zone %s", zone:GetName())
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when the group leaves a zone.
function flightgroup:OnAfterLeaveZone(From, Event, To, zone)
local text=string.format("Group left zone %s", zone:GetName())
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when an element of the group is parking at an airbase.
function flightgroup:OnAfterElementParking(From, Event, To, Element, Spot)
local element=Element --Ops.FlightGroup#FLIGHTGROUP.Element
local spot=Spot --Wrapper.Airbase#AIRBASE.ParkingSpot
local text=string.format("Element %s is parking at spot %d", element.name, spot.TerminalID)
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when the group started taxiing to the runway.
function flightgroup:OnAfterTaxiing(From,Event,To)
local text=string.format("Group is taxiing")
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when the group took off.
function flightgroup:OnAfterTakeoff(From, Event, To, airbase)
local text=string.format("Group took off at %s", airbase and airbase:GetName() or "unknown place")
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when the group is airborne.
function flightgroup:OnAfterAirborne(From, Event, To)
local text=string.format("Group is airborn")
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when the group is ordered to return to an airbase.
function flightgroup:OnAfterRTB(From, Event, To, airbase)
local text=string.format("Group is RTB to %s", airbase:GetName())
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when the group is ordered to land (after holding at an airbase).
function flightgroup:OnAfterLanding(From, Event, To)
local text=string.format("Group is landing")
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when the group landed.
function flightgroup:OnAfterLanded(From, Event, To, airbase)
local text=string.format("Group landed at %s", airbase and airbase:GetName() or "unknown place")
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when the group arrived at its parking spot.
function flightgroup:OnAfterArrived(From, Event, To)
local text=string.format("Group arrived at its destination")
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end
--- Function called when the group is dead, i.e. killed or despawned. Will be called after the group has arrived at its parking location.
function flightgroup:OnAfterDead(From, Event, To)
local text=string.format("Group is dead")
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end

View File

@@ -0,0 +1,20 @@
---
-- FLIGHGROUP: Set Destination
--
-- The group has no pre-defined waypoints in the Mission editor.
-- We set the destination to Kobuleti. So the group will take of from Batumi and land there.
---
-- Create a FLIGHTGROUP object.
local flightgroup=FLIGHTGROUP:New("F/A-18 Batumi")
flightgroup:Activate()
-- Set the destination base. Once the group passes the last waypoint and has no more missions it will go there.
flightgroup:SetDestinationbase(AIRBASE:FindByName("Kobuleti"))
--- Function called when the group is ordered to return to an airbase.
function flightgroup:OnAfterRTB(From, Event, To, airbase)
local text=string.format("Group is RTB to %s", airbase:GetName())
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end

View File

@@ -0,0 +1,35 @@
---
-- FLIGHTGROUP: Divert
--
-- Just like in example mission "Flightgroup - 030 - Destination" we set the destination to Kobuleti.
-- However, when the group has passed the final waypoint, we let the group divert to Senaki.
-- Note that the group needs to have at least one waypoint to have the OnAfterPassingWaypoint function to be called.
---
-- Create a FLIGHTGROUP object.
local flightgroup=FLIGHTGROUP:New("F/A-18 Batumi")
flightgroup:Activate()
-- Set Kobuleti as destination.
flightgroup:SetDestinationbase(AIRBASE:FindByName("Kobuleti"))
-- Add a waypoint at zone Alpha.
flightgroup:AddWaypoint(ZONE:New("Zone Alpha"):GetCoordinate(), 350, nil, 5000)
--- Function called when the group has passed a waypoint.
function flightgroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
-- At final waypoint, divert to Senaki instead of going to Kobuleti.
if flightgroup:HasPassedFinalWaypoint() then
flightgroup:RTB(AIRBASE:FindByName(AIRBASE.Caucasus.Senaki_Kolkhi))
end
end
--- Function called when the group is ordered to return to an airbase.
function flightgroup:OnAfterRTB(From, Event, To, airbase)
local text=string.format("Group is RTB to %s", airbase:GetName())
MESSAGE:New(text, 10, flightgroup:GetName()):ToAll()
flightgroup:I(text)
end

View File

@@ -0,0 +1,50 @@
---
-- FLIGHTGROUP: Land at coordinate
--
-- A helo group is ordered to go to a waypoint at zone Bravo.
-- After 10 min, it is ordered to land at a drop off zone. It will stay there for 5 min and then resume its route to zone Bravo.
--
---
local flightgroup=FLIGHTGROUP:New("UH-1H Group")
flightgroup:Activate()
local zoneBravo=ZONE:New("Zone Bravo")
-- Add a waypoint.
flightgroup:AddWaypoint(zoneBravo:GetCoordinate():SetAltitude(500), 100)
-- After 10 min give the command to land at the drop off zone for 5 min.
flightgroup:__LandAt(10*60, ZONE:New("Zone Dropoff"):GetCoordinate(), 5*60)
--- Function called when the group has passed a waypoint.
function flightgroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
if flightgroup:HasPassedFinalWaypoint() then
flightgroup:RTB(AIRBASE:FindByName(AIRBASE.Caucasus.Senaki_Kolkhi))
end
end
--- Function called after helo is ordered to land at a coordinate.
function flightgroup:OnAfterLandAt(From, Event, To, Coordinate, Duration)
-- Note that the coordinate must not be passed like in this example. If it is not given in the :LandAt() command the helo will land at is current position.
if Coordinate then
-- Send a message.
local mgrs=Coordinate:ToStringMGRS()
local text=string.format("We are landing at %s and will remain there for %d seconds", mgrs, Duration or 600)
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
end
--- Function called after helo landed at a coordinate.
function flightgroup:OnAfterLandedAt(From, Event, To)
-- Smoke group organge.
flightgroup:GetCoordinate():SmokeOrange()
end

View File

@@ -0,0 +1,22 @@
---
-- FLIGHTGROUP: Airboss
--
-- A Hornet 4-ship group takes of from Batumi with destination USS Stennis.
-- It will be put into the Marshal stack until the recovery window opens at 8:20.
--
-- NOTE that in the DEVELOPMENT version, the AIRBOSS handles FLIGHTGROUPS which are inbound to the carrier.
-- The AIRBOSS function :SetExcludeAI() is deprecated.
--
---
-- Create a very basic AIRBOSS. We open a recovery window at 8:30 for 30 min.
local airboss=AIRBOSS:New("USS Stennis")
airboss:AddRecoveryWindow("8:20", 30*60)
airboss:Start()
-- Create a FLIGHTGROUP object.
local flightgroup=FLIGHTGROUP:New("F/A-18 Batumi")
flightgroup:Activate()
-- Set destination to USS Stennis.
flightgroup:SetDestinationbase(AIRBASE:FindByName("USS Stennis"))

View File

@@ -0,0 +1,38 @@
---
-- FLIHGTGROUP: Refuel
--
-- A KC-135 is set up as a tanker and a Viper group is ordered to refuel.
-- Both groups start in air and the Viper groups has only 60% fuel initially.
-- FSM events OnAfterRefuel() and OnAfterRefueled() are triggered, when the refueling task is started and ended.
--
-- Note that the AUFTRAG class offers more convenient methods to achieve the same thing.
---
-- Define donor flight.
local tanker=FLIGHTGROUP:New("KC-135 Air Group")
tanker:SwitchRadio(255)
tanker:Activate()
-- Add enroute task TANKER.
tanker:AddTaskEnroute(CONTROLLABLE.EnRouteTaskTanker(nil))
-- Add task to orbit.
local taskOrbit=CONTROLLABLE.TaskOrbit(nil, ZONE:New("Zone Alpha"):GetCoordinate(), 8000, 250)
tanker:AddTask(taskOrbit)
-- Define acceptor flight.
local viper=FLIGHTGROUP:New("Viper Air Group")
viper:Activate()
--- Function called when group is ordered to refuel.
function viper:OnAfterRefuel()
MESSAGE:New("Viper is tasked to refuel. Let's hope there is a tanker...", 120):ToAll()
end
--- Function called when refueling task is over.
function viper:OnAfterRefueled(From,Event,To)
MESSAGE:New("Viper finished refueling", 120):ToAll()
end
-- Order Viper to refuel at the nearest tanker after 60 seconds.
viper:__Refuel(60)