MOOSE demonstration missions [skip ci]

This commit is contained in:
FlightControl-User
2020-11-25 22:07:48 +00:00
parent a56e5bc901
commit cbf619f311
490 changed files with 2198 additions and 0 deletions
@@ -0,0 +1,30 @@
---
-- AUFTRAG: Anti-ship
--
-- A Hornet and a Viggen group get the mission to destroy the Grisha.
---
-- The target ship.
local navygroup=NAVYGROUP:New("Red Grisha Group")
navygroup:SetDefaultROE(ENUMS.ROE.WeaponHold)
navygroup:Activate()
-- Ship need to be spawned into the game first.
function navygroup:OnAfterSpawned(From, Event, To)
-- Create an ANTI-SHIP mission.
local auftrag=AUFTRAG:NewANTISHIP(navygroup:GetGroup(), 1500)
auftrag:SetMissionAltitude(3000)
-- Assign mission to Hornet pilot.
local hornet=FLIGHTGROUP:New("F/A-18 Anti-Ship Group")
hornet:AddMission(auftrag)
-- Assign mission to Viggen pilot.
local viggen=FLIGHTGROUP:New("Viggen Anti-Ship Group")
viggen:AddMission(auftrag)
end
@@ -0,0 +1,25 @@
---
-- AUFTRAG: AWACS
--
-- An AWACS, Callsign Darkstar 5-1, is on a mission patrolling Zone Alpha form 8:02 to 8:30.
-- Mission starts at 8:00 so the AWACS will appear after 2 min.
--
-- Radio 225 MHz AM
-- TACAN 29Y (DXS)
---
-- Patrol zone.
local zoneAlpha=ZONE:New("Zone Alpha")
-- AWACS mission. Orbit at 15000 ft, 350 KIAS, heading 270 for 20 NM.
local auftrag=AUFTRAG:NewAWACS(zoneAlpha:GetCoordinate(), 15000, 350, 270, 20)
auftrag:SetTime("8:02", "8:45")
auftrag:SetTACAN(29, "DXS") -- Set TACAN to 29Y.
auftrag:SetRadio(225) -- Set radio to 225 MHz AM.
-- Create a flightgroup and set default callsign to Darkstar 5-1
local flightgroup=FLIGHTGROUP:New("E-3A Kobuleti")
flightgroup:SetDefaultCallsign(CALLSIGN.AWACS.Darkstar, 5)
-- Assign mission to pilot.
flightgroup:AddMission(auftrag)
@@ -0,0 +1,37 @@
---
-- AUFTRAG: Battlefield Air Interdiction (BAI)
--
-- Viggen flight is assigned a mission to destroy a group of three BTRs at the old airfield new Kobuleti.
-- Mission is a success if 1/3 of the targets (i.e. one unit) is destroyed.
---
-- Target group.
local target=GROUP:FindByName("Red Target X")
-- Create a BAI mission. Engage altitude is 5000 ft.
local auftrag=AUFTRAG:NewBAI(target, 5000)
auftrag:SetMissionAltitude(2000) -- Mission waypoint alitude is 2000 ft.
--- Function returns true, if the target of a mission was damaged by more than X %. Default 50 %.
local function MissionDamage(Mission, DamageInPercent)
local mission=Mission --Ops.Auftrag#AUFTRAG
return mission:GetTargetDamage() > (DamageInPercent or 50)
end
-- Add a success condition that 30% life point damage of the group is sufficient for a successful mission.
auftrag:AddConditionSuccess(MissionDamage, auftrag, 30)
--- Function called, when mission was successful.
function auftrag:OnAfterSuccess(From, Event, To)
MESSAGE:New(string.format("Mission %s accomplished!", auftrag:GetName()), 300):ToAll()
end
--- Function called when mission was a failure.
function auftrag:OnAfterFailed(From, Event, To)
MESSAGE:New(string.format("Mission %s failed!", auftrag:GetName()), 300):ToAll()
end
-- Assign mission to pilot.
local flightgroup=FLIGHTGROUP:New("Viggen BAI Group")
flightgroup:AddMission(auftrag)
@@ -0,0 +1,42 @@
---
-- AUFTRAG: Bombing
--
-- B-52 group (late activated in air) is ordered to bomb two targets. A static TV tower and a group of BTRs.
-- As the group has no home or destination base, it will wait (orbit) once the two missions are over.
---
-- The targets.
local Target1=STATIC:FindByName("Red TV Tower")
local Target2=GROUP:FindByName("Red Target X")
-- Create a flight group and activate it. It will wait until the mission starts.
local bomber=FLIGHTGROUP:New("B-52 Air Group")
bomber:SetFuelLowThreshold(30) -- Default is 25%.
bomber:SetFuelCriticalThreshold(15) -- Default is 10%.
bomber:Activate()
-- First bombing mission at 25000 ft. This will be carried out after the other mission as it has a lower prio!
local mission1=AUFTRAG:NewBOMBING(Target1, 25000)
mission1:SetWeaponExpend(AI.Task.WeaponExpend.HALF)
mission1:SetTime("8:05")
mission1:SetPriority(20)
-- Second bombing mission at 30000 ft.
local mission2=AUFTRAG:NewBOMBING(Target2, 30000)
-- Interestingly, setting expend to ALL does NOT work. Looks like as half of the bombs is already gone in mission1, the task cannot be executed any more.
mission2:SetWeaponExpend(AI.Task.WeaponExpend.HALF)
mission1:SetTime("8:05")
mission2:SetPriority(10)
-- Assign missions to bomber crew.
bomber:AddMission(mission1)
bomber:AddMission(mission2)
--- Function called when group is low on fuel.
function bomber:OnAfterFuelLow(From,Event,To)
MESSAGE:New("We are low on fuel. Can we go home boss?"):ToAll()
end
function bomber:OnAfterFuelCritical(From,Event,To)
MESSAGE:New("We are CRITICAL on fuel. We really need to land somewhere!"):ToAll()
end
@@ -0,0 +1,45 @@
---
-- AUFTRAG: Bomb Runway
--
-- B-52 4-ship group is tasks to bomb the runway at Gudauta. Once the mission is done, we send the flight back to Batumi.
--
-- As Batumi is a small airbase, it has only parking space for one B-52. The other three B-52s would be automatically despawned by DCS shortly after landing.
-- While this would be properly handled by the code, we set :SetDespawnAfterLanding() so that all units will be despawned when they land. This can also be useful to avoid DCS taxiing issues.
-- (Unfortunately, there is no way (via scripting) to tell whether an aircraft unit can takeoff or land at an airbase (in terms of its size).
-- The only way is to try to place it on the airbase in the mission editor. If the group snaps to another airbase, it cannot takeoff or land there.)
---
-- Target airbase.
local Target=AIRBASE:FindByName(AIRBASE.Caucasus.Gudauta)
-- Create flight group. The group will be despawned after landing to avoid potential taxi problems.
local bomber=FLIGHTGROUP:New("B-52 Air Group")
bomber:SetDespawnAfterLanding()
-- Drop half of all bombs on the runway at Gudauta.
local mission=AUFTRAG:NewBOMBRUNWAY(Target, 10000)
mission:SetWeaponExpend(AI.Task.WeaponExpend.HALF)
mission:SetFormation(ENUMS.Formation.FixedWing.LineAbreast.Close)
mission:SetMissionAltitude(10000)
-- Assign mission to bomber crew.
bomber:AddMission(mission)
--- Function called when the mission is over.
function mission:OnAfterDone()
-- Loop over all assigned groups. In this case only one.
for _,opsgroup in pairs(mission:GetOpsGroups()) do
local flightgroup=opsgroup --Ops.FlightGroup#FLIGHTGROUP
flightgroup:RTB(AIRBASE:FindByName("Batumi"))
end
end
--- Function called when the mission was successful.
function mission:OnAfterSuccess()
MESSAGE:New("Runway destroyed!", 300):ToAll()
end
--- Function called if the mission failed.
function mission:OnAfterFailed()
MESSAGE:New("Runway was NOT destroyed!", 300):ToAll()
end
@@ -0,0 +1,17 @@
---
-- AUFTRAG: Carpet Bombing
---
-- Target.
local Target=GROUP:FindByName("Red Target X")
-- Flight group.
local bomber=FLIGHTGROUP:New("B-52 Air Group")
bomber:SetDefaultFormation(ENUMS.Formation.FixedWing.Wedge.Group)
-- Carpet bombing mission. Altitude is 15000 ft. Carpet length is 1000 meters.
local mission=AUFTRAG:NewBOMBCARPET(Target, 15000, 1000)
mission:SetFormation(ENUMS.Formation.FixedWing.LineAbreast.Open) -- We take an open line abreast formation for the attack.
-- Assign mission to bomber crew.
bomber:AddMission(mission)
@@ -0,0 +1,35 @@
---
-- Mission: Close Air Support (CAS)
--
-- A-10 will perform a DCS CAS in zone Charlie and attack all targets it detects automatically.
--
-- This mission type uses the DCS enroute task engageTargetsInZone https://wiki.hoggitworld.com/view/DCS_task_engageTargetsInZone
-- Therefore, the CAS zone needs to be a circular zone. Polygon zones are unfortunately not supported by DCS.
--
-- We also enable the detection and send a message if an unknown unit was detected by the group.
-- NOTE that this is not necessary for the CAS mission to work. It is only to keep track on which units are actually detected.
---
-- The CAS zone.
local zoneCharlie=ZONE:New("Zone Charlie")
-- Create a flight group.
local flightgroup=FLIGHTGROUP:New("A-10C CAS Group")
flightgroup:SetDetection(true)
--- Function called when the group detectes a previously unkwown unit.
function flightgroup:OnAfterDetectedUnitNew(From, Event, To, Unit)
local unit=Unit --Wrapper.Unit#UNIT
-- Message to everybody and in the DCS log file.
local text=string.format("Detected unit %s", unit:GetName())
MESSAGE:New(text, 120,flightgroup:GetName()):ToAll()
env.info(text)
end
-- Create a CAS mission.
local mission=AUFTRAG:NewCAS(zoneCharlie)
-- Assign mission to pilot.
flightgroup:AddMission(mission)
@@ -0,0 +1,34 @@
---
-- Mission: Combat Air Patrol (CAP)
--
-- An F-16 group will perform a DCS CAP in zone Delta and attack all targets it detects automatically.
--
-- At 08:15 two enemy groups will fly into the CAP zone and should be engaged.
-- The enemies will not attack as they are on a simple orbit mission where the ROE prohibit any engagement.
---
-- CAP zone.
local zoneDelta=ZONE:New("Zone Delta")
--Create a new CAP mission.
local missionCAP=AUFTRAG:NewCAP(zoneDelta, 10000, 350)
missionCAP:SetTime("8:00", "9:00")
-- Create a flightgroup and assign mission to pilot.
local f16=FLIGHTGROUP:New("F-16 CAP Group")
f16:AddMission(missionCAP)
---
-- Intruders
---
-- Create an orbit mission for the intruder.
local missionORBIT=AUFTRAG:NewORBIT(zoneDelta:GetRandomCoordinate(), 6000, 350, 180, 10)
missionORBIT:SetTime("8:15", "9:00")
-- Add intruder flight.
local mig29=FLIGHTGROUP:New("MiG-29 Air Group")
local tu22=FLIGHTGROUP:New("Tu-22 Air Group")
mig29:AddMission(missionORBIT)
tu22:AddMission(missionORBIT)
@@ -0,0 +1,31 @@
---
-- AUFTRAG: Escort
--
-- B-52s will take off from Senaki and fly to zone Alpha and Bravo.
-- A group of F-16s will escort them until they land at Batumi and then return to Senaki.
--
-- A group of enemy MiG-29s is also around...
---
local zoneAlpha=ZONE:New("Zone Alpha")
local zoneBravo=ZONE:New("Zone Bravo")
-- Create flight plan for the bomber group.
local b52=FLIGHTGROUP:New("B-52 Kobuleti")
b52:AddWaypoint(zoneAlpha:GetCoordinate():SetAltitude(7000))
b52:AddWaypoint(zoneBravo:GetCoordinate():SetAltitude(5000))
b52:Activate()
-- Once the final waypoint is passed
function b52:OnAfterPassingWaypoint(From, Event, To, Waypoint)
if b52:HasPassedFinalWaypoint() then
b52:RTB(AIRBASE:FindByName("Batumi"))
end
end
-- The escort group.
local f16=FLIGHTGROUP:New("F-16 CAP Group")
-- Escort the bombers. Engage all air threats withing 32 NM.
local escort=AUFTRAG:NewESCORT(b52:GetGroup(), nil, 32)
f16:AddMission(escort)
@@ -0,0 +1,16 @@
---
-- AUFTRAG: Forward Air Controller Airborne (FACA)
--
-- Kiowa gets a FACA mission. It will be orbiting around the target and JTAC menu entry is created.
---
-- The target.
local Target=GROUP:FindByName("Red Target X")
-- Create a FACA mission. This uses the default settings: Datalink on, designation auto, radio 133 MHz AM.
local mission=AUFTRAG:NewFACA(Target)
mission:SetMissionAltitude(2000)
-- Create a flight group and assign mission.
local afac=FLIGHTGROUP:New("OH-58 Group")
afac:AddMission(mission)
@@ -0,0 +1,30 @@
---
-- Mission: INTERCEPT
--
-- F-16s are send to intercept a group of Tu-22s.
---
local zoneAlpha=ZONE:New("Zone Alpha")
local zoneBravo=ZONE:New("Zone Bravo")
-- Intruder group.
local tu22=FLIGHTGROUP:New("Tu-22 Air Group")
tu22:AddWaypoint(zoneAlpha:GetCoordinate():SetAltitude(7000))
tu22:AddWaypoint(zoneBravo:GetCoordinate():SetAltitude(10000))
tu22:Activate()
-- If the intruder makes it to zone Bravo, we send it RTB.
function tu22:OnAfterEnterZone(From, Event, To, zone)
if zone:GetName()==zoneBravo:GetName() then
tu22:RTB(AIRBASE:FindByName(AIRBASE.Caucasus.Gudauta))
end
end
-- Create an Intercept mission.
local mission=AUFTRAG:NewINTERCEPT(tu22:GetGroup())
-- Interceptor group.
local f16=FLIGHTGROUP:New("F-16 CAP Group")
f16:AddMission(mission)
@@ -0,0 +1,62 @@
---
-- AUFTRAG: Orbit
--
-- Hornet group is assigned missions to orbit at different zones.
-- Adding, cancelling Missions and setting priorities and importance.
--
-- 1.) Flight will first orbit at zone Charlie as this has the highest priority (lowest value). 5 min after the mission is executed, it is cancelled.
-- 2.) Flight will then orbit at zone Delta. But the mission starts at 8:15. So the flight will wait at its current position until the mission starts.
-- 3.) At 8:30 the previous mission ends and the flight proceeds to zone Bravo. Note that this mission has a lower importances than mission Delta and will therefore only be executed when mission Delta is finished.
-- 4.) When mission Bravo is executed, mission Alpha is added. It has a higher prio AND is urgent. So when mission Alpha starts at 8:45
---
-- Orbit zones.
local zoneAlpha=ZONE:New("Zone Alpha")
local zoneBravo=ZONE:New("Zone Bravo")
local zoneCharlie=ZONE:New("Zone Charlie")
local zoneDelta=ZONE:New("Zone Delta")
-- Create a flight group.
local flightgroup=FLIGHTGROUP:New("F/A-18 Batumi")
flightgroup:SetVerbosity(2)
-- Table of missions.
local mission={}
-- Create orbit missions at different zones.
mission.Alpha=AUFTRAG:NewORBIT_CIRCLE(zoneAlpha:GetCoordinate(), 5000, 350):SetName("Orbit Alpha")
mission.Bravo=AUFTRAG:NewORBIT_RACETRACK(zoneBravo:GetCoordinate(), 10000, 400, 090, 20):SetName("Orbit Bravo")
mission.Charlie=AUFTRAG:NewORBIT_CIRCLE(zoneCharlie:GetCoordinate(), 12000, 450):SetName("Orbit Charlie")
mission.Delta=AUFTRAG:NewORBIT_CIRCLE(zoneDelta:GetCoordinate(), 20000, 420):SetName("Orbit Delta")
mission.Foxtrot=AUFTRAG:NewORBIT_CIRCLE(zoneAlpha:GetCoordinate(), 20000, 420):SetName("Orbit Foxtrot")
mission.Charlie:SetPriority(10)
mission.Delta:SetPriority(20, nil, 1)
mission.Delta:SetTime("8:15", "8:30")
mission.Bravo:SetPriority(30, nil, 2)
mission.Alpha:SetPriority(25, true)
mission.Alpha:SetTime("8:45", "9:15")
--- Function called when mission Charlie is executed, i.e. the orbit task is started.
function mission.Charlie:OnAfterExecuting(From, Event, To)
-- Mission is cancelled 5 min after it is executed.
mission.Charlie:__Cancel(5*60)
end
--- Function called when mission Bravo is executed.
function mission.Bravo:OnAfterExecuting(From,Event,To)
-- Add mission Alpha.
flightgroup:AddMission(mission.Alpha)
end
-- Mission is cancelled after 10 min. It will never be started.
mission.Foxtrot:__Cancel(10*60)
-- Add all missions execpt
for _,auftrag in pairs(mission) do
if auftrag:GetName()~="Orbit Alpha" then
flightgroup:AddMission(auftrag)
end
end
@@ -0,0 +1,23 @@
---
-- AUFTRAG: Rescue Helo
---
-- Name of the carrier unit.
local CarrierName="USS Stennis"
local navygroup=NAVYGROUP:New("Stennis Group")
navygroup:Activate()
function navygroup:OnAfterSpawned()
local function spawned(group)
local flightgroup=FLIGHTGROUP:New(group)
local mission=AUFTRAG:NewRESCUEHELO(UNIT:FindByName(CarrierName))
flightgroup:AddMission(mission)
end
local spawn=SPAWN:New("SH-60 Group")
spawn:OnSpawnGroup(spawned)
spawn:SpawnAtAirbase(AIRBASE:FindByName(CarrierName))
end
@@ -0,0 +1,16 @@
---
-- AUFTRAG: SEAD
--
-- JF-17 2-ship group is tasks to destroy the search radar of an SA-2 site.
---
-- The target unit.
local Target=UNIT:FindByName("Red SA-2 #010")
-- Create a flightgroup.
local jf17=FLIGHTGROUP:New("JF-17 SEAD Group")
-- SEAD mission.
local auftrag=AUFTRAG:NewSEAD(Target, 5000)
jf17:AddMission(auftrag)
@@ -0,0 +1,30 @@
---
-- AUFTRAG: Strike
--
-- Task is to destroy a strategically important bridge at the mouth of the Enguri river.
--
-- We assign two flights, one Viggen and one A-10C, for this job.
--
-- The Viggen pilot is a nugget and tends to drop bombs long. So it is always good to have a more experienced pilot as backup.
--
-- NOTE:
-- * In order to get the scenery object, you can right click on the map in the mission editor and use the "assign as..." function to create a zone.
-- * The STRIKE auftrag uses the AttackMapObject DCS task https://wiki.hoggitworld.com/view/DCS_task_attackMapObject
---
-- To get the scenery object of the bridge, we create a zone in the mission editor.
local TargetCoord=ZONE:New("Zone Bridge"):GetCoordinate()
-- The bridge should be the closest scenery object.
local Bridge=TargetCoord:FindClosestScenery(200)
-- Create a strike mission.
local auftrag=AUFTRAG:NewSTRIKE(Bridge)
-- Assign Viggen group.
local viggen=FLIGHTGROUP:New("Viggen BAI Group")
viggen:AddMission(auftrag)
-- Assign A-10 group.
local a10c=FLIGHTGROUP:New("A-10C CAS Group")
a10c:AddMission(auftrag)
@@ -0,0 +1,34 @@
---
-- AUFTRAG: Tanker
--
-- A KC-135, callsign Arco 5-1, is tasked to refuel our units at two different locations.
--
-- First assignment is to orbit in zone Alpha from 8:05 to 8:45. TACAN channel is 80Y ("ARC"), radio 225 MHz.
-- At 9:00 it will move to zone Delta for half an our. TACAN channel is 81Y ("XYZ"), radio 230 MHz.
---
-- Orbit zones.
local zoneAlpha=ZONE:New("Zone Alpha")
local zoneDelta=ZONE:New("Zone Delta")
-- Create Tanker mission.
local auftrag1=AUFTRAG:NewTANKER(zoneAlpha:GetCoordinate(), 10000, 350, 270, 25)
auftrag1:SetTime("8:05", "8:45")
auftrag1:SetTACAN(80, "ARC")
auftrag1:SetRadio(225)
-- Create Tanker mission.
local auftrag2=AUFTRAG:NewTANKER(zoneDelta:GetCoordinate(), 15000, 400, 180, 50)
auftrag2:SetTime("9:00", "9:30")
auftrag2:SetTACAN(81, "XYZ")
auftrag2:SetRadio(230)
-- Create a flight group.
local flightgroup=FLIGHTGROUP:New("KC-135 Kobuleti")
flightgroup:SetDefaultCallsign(CALLSIGN.Tanker.Arco, 5)
flightgroup:SetDefaultRadio(251)
flightgroup:Activate()
-- Assign missions.
flightgroup:AddMission(auftrag1)
flightgroup:AddMission(auftrag2)
@@ -0,0 +1,27 @@
---
-- Mission: Transport Troops
--
-- A UH-1H is assigned to pick up infantry groups and transport them to the drop zone.
---
-- Troops to be transported from A to B.
local TroopSet=SET_GROUP:New():FilterPrefixes("Infantry Transport"):FilterOnce()
-- Carrier.
local helo=FLIGHTGROUP:New("UH-1H Group")
-- Drop off zone.
local zoneDrop=ZONE:New("Zone Dropoff")
-- Transport mission.
local mission=AUFTRAG:NewTROOPTRANSPORT(TroopSet, zoneDrop:GetCoordinate())
-- Assign mission to the flight group.
helo:AddMission(mission)
-- Smoke transported groups after they disembarked.
function mission:OnAfterDone(From,Event,To)
for _,group in pairs(mission.transportGroupSet:GetSet()) do
group:SmokeRed()
end
end