Updated Moose.lua

This commit is contained in:
funkyfranky
2024-02-25 02:21:54 +00:00
parent 37709df11d
commit 6ee157d018
51 changed files with 867 additions and 867 deletions

View File

@@ -1,33 +1,33 @@
---
-- Author: FlightControl
-- Created: 21.02.2017
-- Contributors: kaltokri
-- Modified: 23.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
--
-- # Description:
--
-- In this demo mission we will show how to use the method IsAlive() on group level.
-- Two ground forces GROUPS are shooting each other (T-80 vs M2A2).
--
-- # Guide:
--
-- 1. Run the mission and check the messages.
-- 2. If a unit is dead the returned value will be nil
-- Create Spawn Groups:
local GroupBlue = GROUP:FindByName( "Blue" )
local GroupRed = GROUP:FindByName( "Red" )
local GroupObserver = GROUP:FindByName( "Observer" )
-- Start a scheduler to test every second if the groups are alive and post a status message.
local Schedule, ScheduleID = SCHEDULER:New( nil,
function( GroupBlue, GroupRed )
local IsAliveBlue = GroupBlue:IsAlive()
local IsAliveRed = GroupRed:IsAlive()
GroupObserver:MessageToAll( "IsAliveBlue=" .. tostring(IsAliveBlue) .. " ----- IsAliveRed=" .. tostring(IsAliveRed), 1 )
end, { GroupBlue, GroupRed }, 1, 1
)
---
-- Author: FlightControl
-- Created: 21.02.2017
-- Contributors: kaltokri
-- Modified: 23.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
--
-- # Description:
--
-- In this demo mission we will show how to use the method IsAlive() on group level.
-- Two ground forces GROUPS are shooting each other (T-80 vs M2A2).
--
-- # Guide:
--
-- 1. Run the mission and check the messages.
-- 2. If a unit is dead the returned value will be nil
-- Create Spawn Groups:
local GroupBlue = GROUP:FindByName( "Blue" )
local GroupRed = GROUP:FindByName( "Red" )
local GroupObserver = GROUP:FindByName( "Observer" )
-- Start a scheduler to test every second if the groups are alive and post a status message.
local Schedule, ScheduleID = SCHEDULER:New( nil,
function( GroupBlue, GroupRed )
local IsAliveBlue = GroupBlue:IsAlive()
local IsAliveRed = GroupRed:IsAlive()
GroupObserver:MessageToAll( "IsAliveBlue=" .. tostring(IsAliveBlue) .. " ----- IsAliveRed=" .. tostring(IsAliveRed), 1 )
end, { GroupBlue, GroupRed }, 1, 1
)

View File

@@ -1,51 +1,51 @@
---
-- Author: FlightControl
-- Created: 20.10.2018
-- Contributors: kaltokri
-- Modified: 24.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
--
-- # Description:
--
-- In this mission one Ka-50 (HeliGroup) will attack a group of trucks.
-- As you can see below the code to accomplish this is not trivial.
-- But it is good way to understand the details of task assignment in DCS.
-- A better way is to use new new Ops.Auftrag class.
--
-- # Test cases:
--
-- 1. Start the mission and watch the APC driving trough the zone.
-- 2. A red smoke will be deployed within the zone.
-- Get objects of the groups we need:
local HeliGroup = GROUP:FindByName( "Helicopter" )
local TargetGroup = GROUP:FindByName( "Targets" )
-- Get all units of the target group
local TargetUnits = TargetGroup:GetUnits()
-- Create an empty list of tasks for the HeliGroup.
local HeliTasks = {}
-- Loop through all units of TargetGroup.
-- #TargetUnits is the number of elements of TargetUnits.
for i = 1, #TargetUnits do
local TargetUnit = TargetGroup:GetUnit( i )
-- Add an attack task to the HeliTasks table for each target unit.
HeliTasks[#HeliTasks+1] = HeliGroup:TaskAttackUnit( TargetUnit )
end
-- As the last task add a function
HeliTasks[#HeliTasks+1] = HeliGroup:TaskFunction( "_Resume", { "''" } )
-- This is a very simple function, which only prints only a message.
-- But you can do very complex things in such a method.
-- @param Wrapper.Group#GROUP HeliGroup
function _Resume( HeliGroup )
HeliGroup:MessageToAll( "All tasks completed.", 10, "Info") -- Show an info message for 10 seconds.
end
-- Push the list with all tasks to the HeliGroup with a delay of 10 seconds.
HeliGroup:PushTask( HeliGroup:TaskCombo( HeliTasks ), 10 )
---
-- Author: FlightControl
-- Created: 20.10.2018
-- Contributors: kaltokri
-- Modified: 24.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
--
-- # Description:
--
-- In this mission one Ka-50 (HeliGroup) will attack a group of trucks.
-- As you can see below the code to accomplish this is not trivial.
-- But it is good way to understand the details of task assignment in DCS.
-- A better way is to use new new Ops.Auftrag class.
--
-- # Test cases:
--
-- 1. Start the mission and watch the APC driving trough the zone.
-- 2. A red smoke will be deployed within the zone.
-- Get objects of the groups we need:
local HeliGroup = GROUP:FindByName( "Helicopter" )
local TargetGroup = GROUP:FindByName( "Targets" )
-- Get all units of the target group
local TargetUnits = TargetGroup:GetUnits()
-- Create an empty list of tasks for the HeliGroup.
local HeliTasks = {}
-- Loop through all units of TargetGroup.
-- #TargetUnits is the number of elements of TargetUnits.
for i = 1, #TargetUnits do
local TargetUnit = TargetGroup:GetUnit( i )
-- Add an attack task to the HeliTasks table for each target unit.
HeliTasks[#HeliTasks+1] = HeliGroup:TaskAttackUnit( TargetUnit )
end
-- As the last task add a function
HeliTasks[#HeliTasks+1] = HeliGroup:TaskFunction( "_Resume", { "''" } )
-- This is a very simple function, which only prints only a message.
-- But you can do very complex things in such a method.
-- @param Wrapper.Group#GROUP HeliGroup
function _Resume( HeliGroup )
HeliGroup:MessageToAll( "All tasks completed.", 10, "Info") -- Show an info message for 10 seconds.
end
-- Push the list with all tasks to the HeliGroup with a delay of 10 seconds.
HeliGroup:PushTask( HeliGroup:TaskCombo( HeliTasks ), 10 )

View File

@@ -1,36 +1,36 @@
---
-- Author: FlightControl
-- Created: 20.10.2018
-- Contributors: kaltokri
-- Modified: 24.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Point.html
--
-- # Description:
--
-- In this two planes will be spawned.
-- The second one will follow the first one.
--
-- # Guide:
--
-- 1. Start the mission and watch the planes moving.
-- Create spawn objects from groups:
local SpawnPlane1 = SPAWN:New("Plane 1")
local SpawnPlane2 = SPAWN:New("Plane 2")
-- Spawn the groups into the world:
local GroupPlane1 = SpawnPlane1:Spawn()
local GroupPlane2 = SpawnPlane2:Spawn()
--Create a task for Plane 2 (follow GroupPlane1 at Vec3 offset):
local PointVec3 = POINT_VEC3:New( 100, 0, -100 ) -- This is a Vec3 class.
local FollowDCSTask = GroupPlane2:TaskFollow( GroupPlane1, PointVec3:GetVec3() )
-- Activate Task with SetTask.
-- PushTask will push a task on the execution queue of the group.
-- SetTask will delete all tasks from the current group queue and executes this task.
-- We use SetTask this time:
GroupPlane2:SetTask( FollowDCSTask, 1 )
---
-- Author: FlightControl
-- Created: 20.10.2018
-- Contributors: kaltokri
-- Modified: 24.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Point.html
--
-- # Description:
--
-- In this two planes will be spawned.
-- The second one will follow the first one.
--
-- # Guide:
--
-- 1. Start the mission and watch the planes moving.
-- Create spawn objects from groups:
local SpawnPlane1 = SPAWN:New("Plane 1")
local SpawnPlane2 = SPAWN:New("Plane 2")
-- Spawn the groups into the world:
local GroupPlane1 = SpawnPlane1:Spawn()
local GroupPlane2 = SpawnPlane2:Spawn()
--Create a task for Plane 2 (follow GroupPlane1 at Vec3 offset):
local PointVec3 = POINT_VEC3:New( 100, 0, -100 ) -- This is a Vec3 class.
local FollowDCSTask = GroupPlane2:TaskFollow( GroupPlane1, PointVec3:GetVec3() )
-- Activate Task with SetTask.
-- PushTask will push a task on the execution queue of the group.
-- SetTask will delete all tasks from the current group queue and executes this task.
-- We use SetTask this time:
GroupPlane2:SetTask( FollowDCSTask, 1 )

View File

@@ -1,33 +1,33 @@
---
-- Author: FlightControl
-- Created: 20.10.2018
-- Contributors: kaltokri
-- Modified: 24.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
--
-- # Description:
--
-- In this mission one Ka-50 (HeliGroup) will start from a FARP.
-- Normally it would fly a big polygon shaped patrol around the FARP.
-- At the end it will land back on the FARP.
-- But in the code below we change the route dynamically.
-- So instead of flying to waypoint 2, it will fly to the last waypoint 7.
--
-- # Guide:
--
-- 1. Start the mission and watch the Ka-50 flying around.
-- Get a group object of the Ka-50:
HeliGroup = GROUP:FindByName( "Helicopter" )
-- Route it back to the FARP after 60 seconds.
-- We use the SCHEDULER class to do this.
SCHEDULER:New( nil,
function( HeliGroup )
local CommandRTB = HeliGroup:CommandSwitchWayPoint( 2, 7 )
HeliGroup:SetCommand( CommandRTB )
HeliGroup:MessageToAll("We lose fuel: RTB.", 20)
end, { HeliGroup }, 60
)
---
-- Author: FlightControl
-- Created: 20.10.2018
-- Contributors: kaltokri
-- Modified: 24.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
--
-- # Description:
--
-- In this mission one Ka-50 (HeliGroup) will start from a FARP.
-- Normally it would fly a big polygon shaped patrol around the FARP.
-- At the end it will land back on the FARP.
-- But in the code below we change the route dynamically.
-- So instead of flying to waypoint 2, it will fly to the last waypoint 7.
--
-- # Guide:
--
-- 1. Start the mission and watch the Ka-50 flying around.
-- Get a group object of the Ka-50:
HeliGroup = GROUP:FindByName( "Helicopter" )
-- Route it back to the FARP after 60 seconds.
-- We use the SCHEDULER class to do this.
SCHEDULER:New( nil,
function( HeliGroup )
local CommandRTB = HeliGroup:CommandSwitchWayPoint( 2, 7 )
HeliGroup:SetCommand( CommandRTB )
HeliGroup:MessageToAll("We lose fuel: RTB.", 20)
end, { HeliGroup }, 60
)

View File

@@ -1,46 +1,46 @@
---
-- Author: FlightControl
-- Created: 25.03.2017
-- Contributors: kaltokri
-- Modified: 24.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Scheduler.html
--
-- # Description:
--
-- A ground unit is moving.
-- Using the command CommandStopRoute it will be stopped and starts moving again.
--
-- # Guide:
--
-- 1. Start the mission
-- 2. Observe the group is moving
-- 3. After 10 seconds it will stop.
-- 4. After additional 10 seconds it will move again.
-- 5. This will be repeated endless.
-- Function to stop movement.
--- @param Wrapper.Group#GROUP MyGroup
function StopMove( MyGroup )
MyGroup:MessageToAll("StopMove")
local Command = MyGroup:CommandStopRoute( true )
MyGroup:SetCommand(Command)
end
-- Function to start movement.
--- @param Wrapper.Group#GROUP MyGroup
function StartMove( MyGroup )
MyGroup:MessageToAll("StartMove")
local Command = MyGroup:CommandStopRoute( false )
MyGroup:SetCommand(Command)
end
-- Get an object of the group:
GroundGroup = GROUP:FindByName( "Ground" )
-- Run two schedulers every 20 seconds, but with different start delays:
Scheduler = SCHEDULER:New( nil )
ScheduleIDStop = Scheduler:Schedule(nil, StopMove, { GroundGroup }, 10, 20 ) -- 10 seconds delay from mission start
ScheduleIDStart = Scheduler:Schedule(nil, StartMove, { GroundGroup }, 20, 20 ) -- 20 seconds delay from mission start
---
-- Author: FlightControl
-- Created: 25.03.2017
-- Contributors: kaltokri
-- Modified: 24.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Scheduler.html
--
-- # Description:
--
-- A ground unit is moving.
-- Using the command CommandStopRoute it will be stopped and starts moving again.
--
-- # Guide:
--
-- 1. Start the mission
-- 2. Observe the group is moving
-- 3. After 10 seconds it will stop.
-- 4. After additional 10 seconds it will move again.
-- 5. This will be repeated endless.
-- Function to stop movement.
--- @param Wrapper.Group#GROUP MyGroup
function StopMove( MyGroup )
MyGroup:MessageToAll("StopMove")
local Command = MyGroup:CommandStopRoute( true )
MyGroup:SetCommand(Command)
end
-- Function to start movement.
--- @param Wrapper.Group#GROUP MyGroup
function StartMove( MyGroup )
MyGroup:MessageToAll("StartMove")
local Command = MyGroup:CommandStopRoute( false )
MyGroup:SetCommand(Command)
end
-- Get an object of the group:
GroundGroup = GROUP:FindByName( "Ground" )
-- Run two schedulers every 20 seconds, but with different start delays:
Scheduler = SCHEDULER:New( nil )
ScheduleIDStop = Scheduler:Schedule(nil, StopMove, { GroundGroup }, 10, 20 ) -- 10 seconds delay from mission start
ScheduleIDStart = Scheduler:Schedule(nil, StartMove, { GroundGroup }, 20, 20 ) -- 20 seconds delay from mission start