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

View File

@@ -0,0 +1,71 @@
---
-- NAVYGROUP: Passing Waypoints
--
-- Naval group "USS Normandy Group" has four waypoints set in the Mission editor:
-- 1.) Initial positon at speed 0 knots
-- 2.) Heading North at 25 knots.
-- 3.) Heading North-West at 15 knots.
-- 4.) Heading South at 30 knots (full speed).
--
-- After passing waypoint 4, the group will proceed eastwards to waypoint 1 and redo the route until all eternaty.
-- Note that usually a waypoint speed of zero is dangerous.
--
-- When a group passes a waypoint, it will trigger an event "PassingWaypoint" which can be captured by the OnAfterPassingWaypoint() function.
--
---
-- Create a NAVYGROUP object and activate the late activated group.
local navygroup=NAVYGROUP:New("USS Normandy Group")
navygroup:Activate()
--- Function called each time the group passes a waypoint.
function navygroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
-- Debug info.
local text=string.format("Group passed waypoint ID=%d (Index=%d) for the %d. time", waypoint.uid, navygroup:GetWaypointIndex(waypoint.uid), waypoint.npassed)
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the group is cruising. This is the "normal" state when the group follows its waypoints.
function navygroup:OnAfterCruise(From, Event, To)
local text="Group is cruising"
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the groups starts to turn.
function navygroup:OnAfterTurningStarted(From, Event, To)
local text="Group started turning"
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the group stopps to turn.
function navygroup:OnAfterTurningStopped(From, Event, To)
local text="Group stopped turning"
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
-- Monitor entering and leaving zones. There are four zones named "Zone Leg 1", "Zone Leg 2", ...
local ZoneSet=SET_ZONE:New():FilterPrefixes("Zone Leg"):FilterOnce()
-- Set zones which are checked if the group enters or leaves it.
navygroup:SetCheckZones(ZoneSet)
--- Function called when the group enteres a zone.
function navygroup:OnAfterEnterZone(From, Event, To, Zone)
local text=string.format("Group entered zone %s", Zone:GetName())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the group leaves a zone.
function navygroup:OnAfterLeaveZone(From, Event, To, Zone)
local text=string.format("Group left zone %s", Zone:GetName())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end

View File

@@ -0,0 +1,53 @@
---
-- NAVYGROUP: Steam Into Wind
--
-- This example shows how you let a group steam into the wind for a certain amount of time.
--
-- Naval group "USS Stennis Group" has two waypoint set in the Mission Editor. Mission starts at 0800 hours.
--
-- * At 0815 hours, the group will start to steam into the wind until 0830.
-- * Each time after reaching waypoint 2, the group will again steam into the wind.
-- * Each time after reaching waypoint 1, the group will steam into the wind.
---
-- Create a NAVYGROUP object.
local navygroup=NAVYGROUP:New("USS Stennis Group")
navygroup:Activate()
-- Mark waypoints on F10 map. The marks will be removed after 60 seconds.
navygroup:MarkWaypoints(60)
-- Set some parameters.
navygroup:SwitchTACAN(74, "XYZ")
navygroup:SwitchICLS(1, "ABC")
navygroup:SwitchRadio(130)
navygroup:SwitchAlarmstate(ENUMS.AlarmState.Red)
navygroup:SwitchROE(ENUMS.ROE.WeaponFree)
-- Group will turn into the wind at 8:15 hours until 8:30. Wind on deck is 15 knots. Afterwards, the group will return to the position where the turn started and go to the next waypoint.
navygroup:AddTurnIntoWind("8:15", "8:30", 15, true, -9)
--- Function called each time the group passes a waypoint.
function navygroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
-- Debug info.
local text=string.format("Group passed waypoint ID=%d, Index=%d for the %d time", waypoint.uid, navygroup:GetWaypointIndex(waypoint.uid), waypoint.npassed)
env.info(text)
if Waypoint.uid==1 then
-- Turn into wind 15 min after waypoint ID=1 is passed for 20 min. U-turn=false, i.e. after turn into wind is over, it will directly go to the next waypoint.
navygroup:AddTurnIntoWind(15*60, 20*60, 15, false, -9)
elseif Waypoint.uid==2 then
-- Turn into wind 15 minafter waypoint ID=2 is passed for 15 min. U-turn=true, i.e. group will resume its route at the position the turn started.
navygroup:AddTurnIntoWind(15*60, 15*60, 20, true, -9)
end
end
--- Function called each time the group starts turning into the wind.
function navygroup:OnAfterTurnIntoWind(From, Event, To, TurnIntoWind)
local tiw=TurnIntoWind --Ops.NavyGroup#NAVYGROUP.IntoWind
local text=string.format("Group is turning into the wind for %d seconds. Speed=%d knots. U-turn=%s", tiw.Tstop-tiw.Tstart, tiw.Speed, tostring(tiw.Uturn))
env.info(text)
end

View File

@@ -0,0 +1,88 @@
---
-- NAVYGROUP: Stopping and Removing Turns Into Wind
--
-- Naval group "USS Stennis Group" has two waypoint set in the Mission Editor. Mission starts at 0800 hours.
--
-- We add three "recovery windows", where the group turns into the wind for a given amount of time.
--
-- The first window, which is supposed to last for 25 min, is stopped already after 10 min.
-- The second window is removed from the queue as soon as it opens. That also stopps the window.
-- The third window is removed from the queue when the first window is started. It will never be executed.
--
-- There are also a couple of events created when the turn is starting, the group is directly facing the wind, the window was stopped and when it is over.
---
-- Create a NAVYGROUP object.
local navygroup=NAVYGROUP:New("USS Stennis Group")
navygroup:Activate()
-- Increase DCS log output.
navygroup:SetVerbosity(3)
-- Turn into the wind at 8:05 until 8:30 hours. Wind on deck is 15 knots. U-turn is false. Course offset is -9 degrees to account for the angled deck.
local tiw1=navygroup:AddTurnIntoWind("8:05", "8:30", 15, false, -9)
-- Turn into the wind at 8:45 for 30 min. Wind on deck is 25 knots. U-turn is true. Course offset is -9 degrees to account for the angled deck.
local tiw2=navygroup:AddTurnIntoWind("8:45", 30*60, 25, true, -9)
-- Turn into the wind at 9:30. Wind on deck is 5 knots. U-turn is off. Course offset is -9 degrees to account for the angled deck.
local tiw3=navygroup:AddTurnIntoWind("9:30", "9:45", 5, nil, -9)
--- Function called each time the group starts turning into the wind.
function navygroup:OnAfterTurnIntoWind(From, Event, To, TurnIntoWind)
local tiw=TurnIntoWind --Ops.NavyGroup#NAVYGROUP.IntoWind
-- Debug text.
local text=string.format("Group is turning into the wind (ID=%d) for %d seconds. Speed=%d knots. U-turn=%s", tiw.Id, tiw.Tstop-tiw.Tstart, tiw.Speed, tostring(tiw.Uturn))
MESSAGE:New(text, 360):ToAll()
env.info(text)
if tiw.Id==tiw1.Id then
-- After 10 min, stop this window. Group will resume its route.
navygroup:__TurnIntoWindStop(10*60)
-- We also changed our mind and remove the third window before it even started
navygroup:RemoveTurnIntoWind(tiw3)
elseif tiw.Id==tiw2.Id then
-- We also remove the second window when it starts. This automatically stops the turn into wind.
navygroup:RemoveTurnIntoWind(tiw)
end
end
--- Function called when the actual turn into the wind is over and the group is facing directly into the wind (apart from the given offset, if any).
function navygroup:OnAfterTurnedIntoWind(From, Event, To)
-- Info message.
local text=string.format("Group finished turn and is now steaming directly into the wind!")
MESSAGE:New(text, 360):ToAll()
env.info(text)
end
--- Function called when the current window is stopped.
function navygroup:OnAfterTurnIntoWindStop(From, Event, To)
-- Info message.
local text=string.format("Group will stop turning into the wind now!")
MESSAGE:New(text, 360):ToAll()
env.info(text)
end
--- Function called when the current window is over. Time was up or stopped.
function navygroup:OnAfterTurnIntoWindOver(From, Event, To, TurnIntoWind)
local tiw=TurnIntoWind --Ops.NavyGroup#NAVYGROUP.IntoWind
-- Info message.
local text=string.format("Turn into the wind (ID=%d) is over. Speed was %d knots. U-turn was %s", tiw.Id, tiw.Speed, tostring(tiw.Uturn))
MESSAGE:New(text, 360):ToAll()
env.info(text)
end

View File

@@ -0,0 +1,61 @@
---
-- NAVYGROUP: Waypoints: Passing, Adding and Removing
--
-- USS Normandy has four waypoints set in the Mission Editor.
-- After passing a waypoint, it is removed. So when the group has visited all waypoints, it will come to a full stop.
-- When the group reaches waypoint with unique ID=3, we add another waypoint at the zone Detour Alpha.
--
-- Note that UID counting for pre-defined waypoints in the ME start at one.
-- In paricular, the initial (spawn) position of the group is the waypoint with UID=1.
--
---
-- Create a new NAVYGROUP object.
local navygroup=NAVYGROUP:New("USS Normandy Group")
navygroup:Activate()
-- Increase verbosity to DCS log file.
navygroup:SetVerbosity(1)
--- Function called each time the group passes a waypoint.
function navygroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
-- Get uid of the passed waypoint.
local uid=navygroup:GetWaypointUID(waypoint)
-- Message
local text=string.format("Group passed waypoint with UID=%d!", uid)
MESSAGE:New(text, 360):ToAll()
env.info(text)
-- After passing waypoint 3, go to Zone Alpha at 20 knots.
if uid==3 then
-- Detour zone.
local zoneDetourAlpha=ZONE:New("Zone Detour Alpha")
local coordDetourAlpha=zoneDetourAlpha:GetCoordinate()
-- Add waypoint.
local newaypoint=navygroup:AddWaypoint(coordDetourAlpha, 20, waypoint.uid)
-- Message
local text=string.format("Alright, let's make a detour to %s. Waypoint UID=%d", zoneDetourAlpha:GetName(), newaypoint.uid)
MESSAGE:New(text, 360):ToAll()
env.info(text)
end
-- Remove the waypoint that has just been passed.
navygroup:RemoveWaypointByID(uid)
end
--- Function called each time the group comes to a full stop, e.g. when no more waypoints are left.
function navygroup:OnAfterFullStop(From, Event, To)
-- Send a message that we stopped.
local text=string.format("Group came to a full stop!")
MESSAGE:New(text, 360):ToAll()
env.info(text)
end

View File

@@ -0,0 +1,49 @@
---
-- NAVYGROUP: Goto Specific Waypoints.
--
-- USS Normandy has four waypoints set in the Mission Editor.
-- The normal route would be -->2-->3-->4-->1-->2... (ad infinitum)
--
-- Here, when the group passes a waypoint, we give a command to goto some other waypoint.
--
-- When reaching waypoint 2, we goto waypoint 4
-- When reaching waypoint 4, we goto waypoint 3
-- When reaching waypoint 3, we goto waypoint 1
-- When reaching waypoint 1, we goto waypoint 2.
--
-- So effectively, the route becomes -->2-->4-->3-->1-->2-->4-->3-->1... (ad infinitum)
---
-- Create a new NAVYGROUP object.
local navygroup=NAVYGROUP:New("USS Normandy Group")
navygroup:Activate()
-- Increase verbosity to DCS log file.
navygroup:SetVerbosity(1)
-- Put F10 marks on waypoints.
navygroup:MarkWaypoints()
--- Function called each time the group passes a waypoint.
function navygroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
-- Get uid of the passed waypoint.
local uid=navygroup:GetWaypointUID(waypoint)
-- Message
local text=string.format("Group passed waypoint with UID=%d!", uid)
MESSAGE:New(text, 360):ToAll()
env.info(text)
if uid==1 then
navygroup:GotoWaypoint(2)
elseif uid==2 then
navygroup:GotoWaypoint(4)
elseif uid==3 then
navygroup:GotoWaypoint(1)
elseif uid==4 then
navygroup:GotoWaypoint(3)
end
end

View File

@@ -0,0 +1,57 @@
---
-- NAVYGROUP: Submarine Dive & Surface.
--
-- A submarine has the following waypoint pre-defined in the mission editor:
--
-- UID=1: Spawnposition, speed 0 knots, depth 0 meters
-- UID=2: First waypoint, speed 15 knots, depth 0 meters,
-- UID=3: Second waypoint, speed 17 knots, depth 0 meters,
--
-- By default, the sub will then automatically go to its initial position (UID=1) and resume its route from there.
--
-- At the first waypoint (UID=2), we will let the submarine dive. If not ordered to surface again, the sub would remain under water for the remaining route.
-- At the second waypoint (UID=3), the submarine is ordered surface again.
-- When the sub reaches its initial position (UID=1), we set the cruise speed to 20 knots. This is the speed until the next waypoint (UID=2) is reached.
-- Once reaching the next waypoint, the speed is set according to the waypoint parameter (here 15 knots).
---
-- Create a NAVYGROUP object.
local Uboot=NAVYGROUP:New("Sub 093 Group")
Uboot:SetVerbosity(1)
Uboot:Activate(1)
--- Function called each time the group passes a waypoint.
function Uboot:OnAfterPassingWaypoint(From, Event, To, Waypoint)
if Waypoint.uid==2 then
-- At waypoint 2 we let the sub dive to 10 meters.
Uboot:Dive(10)
elseif Waypoint.uid==3 then
-- At waypoint 3 we let the sub come up to the surface again.
Uboot:Surface()
elseif Waypoint.uid==1 then
-- At waypoint 1 we order the sub to cruise at 20 knots. Note that this is the speed until the next waypoint is reached.
Uboot:Cruise(20)
end
end
--- Function called when sub is about to dive.
function Uboot:OnAfterDive(From, Event, To, Depth, Speed)
-- Message.
local text=string.format("Diving!")
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
--- Function called when sub is about surface.
function Uboot:OnAfterSurface(From, Event, To, Speed)
-- Message.
local text=string.format("Coming up to surface!")
MESSAGE:New(text, 120):ToAll()
env.info(text)
end

View File

@@ -0,0 +1,53 @@
---
-- NAVYGROUP: Scheduled "Fire At Point" Task
--
-- USS Lake Erie is ordered to engage two targets:
--
-- * First target is engaged with with 10 cannon shots at 0805 hours.
-- * Second target with two cruise missiles at 0815 hours.
--
-- Note that:
-- * For the DCS fire at point task to be executed, the group must be in firing range. This is not checked. If the group is NOT in firing range, the task will start but the group will not shoot!
---
-- Create a NAVYGROUP object.
local navygroup=NAVYGROUP:New("USS Lake Erie Group")
navygroup:Activate(1)
-- Increase output in DCS log file.
navygroup:SetVerbosity(3)
-- Set ROE to "Open Fire" or the task will not work.
navygroup:SwitchROE(ENUMS.ROE.OpenFire)
-- The target.
local TargetCoord1=GROUP:FindByName("Red Target X"):GetCoordinate()
local TargetCoord2=GROUP:FindByName("Red Target Poti"):GetCoordinate()
-- Add scheduled tasks.
navygroup:AddTaskFireAtPoint(TargetCoord1, "8:05", 100, 10, ENUMS.WeaponFlag.Cannons)
navygroup:AddTaskFireAtPoint(TargetCoord2, "8:15", 100, 2, ENUMS.WeaponFlag.CruiseMissile)
-- Add a waypoint.
local wp1=navygroup:AddWaypoint(ZONE:New("Zone Alpha"):GetCoordinate())
--- Function called when the group executes a DCS task.
function navygroup:OnAfterTaskExecute(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Message
local text=string.format("Executing task %s!", task.description)
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
--- Function called when the group executes a DCS task.
function navygroup:OnAfterTaskDone(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Message
local text=string.format("Done with task %s!", task.description)
MESSAGE:New(text, 120):ToAll()
env.info(text)
end

View File

@@ -0,0 +1,80 @@
---
-- NAVYGROUP: Waypoint "Fire At Point" Task
--
-- USS Lake Erie is ordered to engage two targets. The first target is engaged with with cannons, the second target with cruise missiles.
--
-- We add two waypoints for the group. The tasks are executed when the group reaches the waypoints. While the task is beeing executed, the group will stop at the given waypoint.
--
-- Note that:
-- * For the DCS fire at point task to be executed, the group must be in firing range. This is not checked. If the group is NOT in firing range, the task will start but the group will not shoot!
---
-- Create a NAVYGROUP object.
local navygroup=NAVYGROUP:New("USS Lake Erie Group")
navygroup:SetVerbosity(3)
navygroup:Activate(1)
-- Set ROE to "Open Fire" or the task will not work.
navygroup:SwitchROE(ENUMS.ROE.OpenFire)
-- The target.
local TargetCoord1=GROUP:FindByName("Red Target X"):GetCoordinate()
local TargetCoord2=GROUP:FindByName("Red Target Poti"):GetCoordinate()
-- The target coordinates (needed for the fire at point task).
local FirePoint1=ZONE:New("Zone Fireing Pos Alpha"):GetCoordinate()
local FirePoint2=ZONE:New("Zone Fireing Pos Bravo"):GetCoordinate()
-- Add waypoints where we want to execute the tasks.
local wp1=navygroup:AddWaypoint(FirePoint1)
local wp2=navygroup:AddWaypoint(FirePoint2)
-- Fire at point tasks.
local task1=navygroup:AddTaskWaypointFireAtPoint(FirePoint1, wp1, 500, 10, ENUMS.WeaponFlag.Cannons, nil, 10*60)
local task2=navygroup:AddTaskWaypointFireAtPoint(FirePoint2, wp2, 100, 10, ENUMS.WeaponFlag.CruiseMissile, nil, 10*60)
--- Function called when the group passes a waypoint.
function navygroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
if waypoint.uid==wp1.uid then
-- Message
local text=string.format("Reached waypoint UID=%d! Should now execute task %d", waypoint.uid, task1.id)
MESSAGE:New(text, 120):ToAll()
env.info(text)
elseif waypoint.uid==wp2.uid then
-- Message
local text=string.format("Reached waypoint UID=%d! Should now execute task %d", waypoint.uid, task2.id)
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
-- Remove waypoint.
navygroup:RemoveWaypointByID(waypoint.uid)
end
--- Function called when the group executes a DCS task.
function navygroup:OnAfterTaskExecute(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Message
local text=string.format("Executing task %s!", task.description)
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
--- Function called when the group executes a DCS task.
function navygroup:OnAfterTaskDone(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Message
local text=string.format("Done with task %s!", task.description)
MESSAGE:New(text, 120):ToAll()
env.info(text)
end

View File

@@ -0,0 +1,28 @@
---
-- NAVYGROUP: Collision Warning & Taking Actions
--
-- USS Lake Erie is send to a coordinate very close to the shore.
-- When a potential collision is detected, the group is send back to its inital position.
---
-- Create a NAVYGROUP object.
local navygroup=NAVYGROUP:New("USS Lake Erie Group")
navygroup:Activate(1)
-- Coordinate near shore at Kobuleti.
local Coordinate=ZONE:New("Zone Kobuleti Sea")
-- Add a waypoint new the shore.
navygroup:AddWaypoint(Coordinate)
--- Function called when a collision warning is issued.
function navygroup:OnAfterCollisionWarning(From, Event, To, Distance)
-- Message.
local text=string.format("Iceberg ahead in %.1f NM", UTILS.MetersToNM(Distance))
MESSAGE:New(text, 120):ToAll()
env.info(text)
-- Tell group to go back to its initial (spawn) position, i.e. waypoint with UID=1.
navygroup:GotoWaypoint(1)
end

View File

@@ -0,0 +1,29 @@
---
-- NAVYGROUP: Path Finding Islands
--
-- A group of two ships, USS Lake Erie and USS Ford, is send on a path which leads right through a couple of islands.
-- The standard DCS behaviour would be that the group gets stuck and there is no way to free them as ships cannot go backwards.
--
-- Moose has a build in path finding algorithm, which will route the group around the obstacles (islands) as soon as a collision is detected.
--
-- Note: This mission takes place on the Persion Gulf map.
---
-- Create a NAVYGROUP object.
local navygroup=NAVYGROUP:New("USS Lake Erie Group")
-- Increase output to DCS log file.
navygroup:SetVerbosity(1)
-- Enable pathfinding. (Pathfinding is off by default as this could lead to high CPU usage).
navygroup:SetPathfindingOn(1700)
--- Function called when a collision warning is issued.
function navygroup:OnAfterCollisionWarning(From, Event, To, Distance)
-- Message.
local text=string.format("Iceberg ahead in %.1f NM", UTILS.MetersToNM(Distance))
MESSAGE:New(text, 120):ToAll()
env.info(text)
end

View File

@@ -0,0 +1,30 @@
---
-- NAVYGROUP: Path Finding
--
-- CVN-74 USS Stennis is supposed to drive through the Strait of Hormuz. The waypoints lead through a big chuck of land mass.
-- However, the build in path finding algorithm will guide the ship to its destination.
--
-- Note: This mission takes place on the Persion Gulf map.
---
-- Create a NAVYGROUP object.
local navygroup=NAVYGROUP:New("Strike Group")
-- Do not go back.
navygroup:SetPatrolAdInfinitum(false)
-- Increase output to DCS log file.
navygroup:SetVerbosity(1)
-- Enable pathfinding. (Pathfinding is off by default as this could lead to high CPU usage).
navygroup:SetPathfindingOn()
--- Function called when a collision warning is issued.
function navygroup:OnAfterCollisionWarning(From, Event, To, Distance)
-- Message.
local text=string.format("Iceberg ahead in %.1f NM", UTILS.MetersToNM(Distance))
MESSAGE:New(text, 120):ToAll()
env.info(text)
end