Updated Moose.lua

This commit is contained in:
funkyfranky
2022-10-11 19:30:16 +00:00
parent 192d4710a2
commit 9f91de26ca
982 changed files with 22665 additions and 22625 deletions

View File

@@ -1,72 +1,72 @@
---
-- ARMYGROUP: Basics
--
-- A group of two TPz Fuchs are located near the old airfield at Kobuleti.
-- We add two waypoints on road to guide them to the airfield.
--
-- When the group passes a waypoint, a message is displayed. Also when the group enters a given zone.
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("TPz Fuchs Group")
armygroup:Activate()
-- Increase verbosity of DCS log file a bit for debugging.
armygroup:SetVerbosity(1)
-- Enable patrol ad infinitum.
armygroup:SetPatrolAdInfinitum()
-- 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.
armygroup:SetCheckZones(AllZones)
-- Some zone.
local zoneWP1=ZONE:New("Zone Waypoint 1")
local zoneWP2=ZONE:New("Zone Waypoint 2")
-- Add waypoints
local wp1=armygroup:AddWaypoint(zoneWP1:GetCoordinate(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
local wp2=armygroup:AddWaypoint(zoneWP2:GetCoordinate(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
--- Function called when the group passes a waypoint.
function armygroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
-- Get unique ID of this waypoint.
local uid=armygroup:GetWaypointUID(waypoint)
-- Is this the final waypoint?
local final=armygroup:HasPassedFinalWaypoint()
-- Info message.
local text=string.format("Group passed waypoint UID=%d for the %d. time. Final=%s", uid, waypoint.npassed, tostring(final))
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
--- Function called when the group enteres a zone.
function armygroup:OnAfterEnterZone(From, Event, To, Zone)
local zone=Zone --Core.Zone#ZONE
-- Message.
local text=string.format("Group %s entered zone %s", armygroup:GetName(), zone:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
--- Function called when the group leaves a zone.
function armygroup:OnAfterLeaveZone(From,Event,To,Zone)
local zone=Zone --Core.Zone#ZONE
-- Message.
local text=string.format("Group %s left zone %s", armygroup:GetName(), zone:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
---
-- ARMYGROUP: Basics
--
-- A group of two TPz Fuchs are located near the old airfield at Kobuleti.
-- We add two waypoints on road to guide them to the airfield.
--
-- When the group passes a waypoint, a message is displayed. Also when the group enters a given zone.
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("TPz Fuchs Group")
armygroup:Activate()
-- Increase verbosity of DCS log file a bit for debugging.
armygroup:SetVerbosity(1)
-- Enable patrol ad infinitum.
armygroup:SetPatrolAdInfinitum()
-- 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.
armygroup:SetCheckZones(AllZones)
-- Some zone.
local zoneWP1=ZONE:New("Zone Waypoint 1")
local zoneWP2=ZONE:New("Zone Waypoint 2")
-- Add waypoints
local wp1=armygroup:AddWaypoint(zoneWP1:GetCoordinate(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
local wp2=armygroup:AddWaypoint(zoneWP2:GetCoordinate(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
--- Function called when the group passes a waypoint.
function armygroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
-- Get unique ID of this waypoint.
local uid=armygroup:GetWaypointUID(waypoint)
-- Is this the final waypoint?
local final=armygroup:HasPassedFinalWaypoint()
-- Info message.
local text=string.format("Group passed waypoint UID=%d for the %d. time. Final=%s", uid, waypoint.npassed, tostring(final))
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
--- Function called when the group enteres a zone.
function armygroup:OnAfterEnterZone(From, Event, To, Zone)
local zone=Zone --Core.Zone#ZONE
-- Message.
local text=string.format("Group %s entered zone %s", armygroup:GetName(), zone:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
--- Function called when the group leaves a zone.
function armygroup:OnAfterLeaveZone(From,Event,To,Zone)
local zone=Zone --Core.Zone#ZONE
-- Message.
local text=string.format("Group %s left zone %s", armygroup:GetName(), zone:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end

View File

@@ -1,82 +1,82 @@
---
-- ARMYGROUP: Zone Hopping
--
-- A couple of trigger zones were created in the mission editor.
--
-- A TPz Fuchs group is ordered to go to a random zone. Once it enters the zone, another random zone is selected as next waypoint.
---
-- Create ARMYGROUP object.
local armygroup=ARMYGROUP:New("TPz Fuchs Group")
armygroup:Activate()
-- Set of all zones defined in the ME.
local AllZones=SET_ZONE:New():FilterOnce()
-- Trigger events when group enters or leaves zhe defined zones.
armygroup:SetCheckZones(AllZones)
-- Zones where to go to.
local zones={
ZONE:New("Zone Kobuleti X"),
ZONE:New("Zone Poti"),
ZONE:New("Zone Sukhumi"),
ZONE:New("Zone Batumi"),
ZONE:New("Zone Kutaisi"),
ZONE:New("Zone Zugdidi"),
ZONE:New("Zone Honi"),
ZONE:New("Zone Lanchhuti"),
ZONE:New("Zone Vani"),
}
-- Get a random zone and remove it.
local function GetRandomZone()
local N=#zones
if N>0 then
local i=math.random(N)
local zone=zones[i]
table.remove(zones, i)
return zone
else
return nil
end
end
-- Get a random zone.
local zonenext=GetRandomZone() --Core.Zone#ZONE
-- Add waypoint.
armygroup:AddWaypoint(zonenext:GetCoordinate():GetClosestPointToRoad(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
--- Function called when the group enteres a zone.
function armygroup:OnAfterEnterZone(From, Event, To, Zone)
local zone=Zone --Core.Zone#ZONE
-- Get a random zone.
local zonenext=GetRandomZone() --Core.Zone#ZONE
if zonenext then
-- Add waypoint.
armygroup:AddWaypoint(zonenext:GetCoordinate():GetClosestPointToRoad(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
-- Message.
local text=string.format("Group %s entered zone %s. Next stop zone %s", armygroup:GetName(), zone:GetName(), zonenext:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
end
--- Function called when the group leaves a zone.
function armygroup:OnAfterLeaveZone(From,Event,To,Zone)
local zone=Zone --Core.Zone#ZONE
-- Message.
local text=string.format("Group %s left zone %s", armygroup:GetName(), zone:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
---
-- ARMYGROUP: Zone Hopping
--
-- A couple of trigger zones were created in the mission editor.
--
-- A TPz Fuchs group is ordered to go to a random zone. Once it enters the zone, another random zone is selected as next waypoint.
---
-- Create ARMYGROUP object.
local armygroup=ARMYGROUP:New("TPz Fuchs Group")
armygroup:Activate()
-- Set of all zones defined in the ME.
local AllZones=SET_ZONE:New():FilterOnce()
-- Trigger events when group enters or leaves zhe defined zones.
armygroup:SetCheckZones(AllZones)
-- Zones where to go to.
local zones={
ZONE:New("Zone Kobuleti X"),
ZONE:New("Zone Poti"),
ZONE:New("Zone Sukhumi"),
ZONE:New("Zone Batumi"),
ZONE:New("Zone Kutaisi"),
ZONE:New("Zone Zugdidi"),
ZONE:New("Zone Honi"),
ZONE:New("Zone Lanchhuti"),
ZONE:New("Zone Vani"),
}
-- Get a random zone and remove it.
local function GetRandomZone()
local N=#zones
if N>0 then
local i=math.random(N)
local zone=zones[i]
table.remove(zones, i)
return zone
else
return nil
end
end
-- Get a random zone.
local zonenext=GetRandomZone() --Core.Zone#ZONE
-- Add waypoint.
armygroup:AddWaypoint(zonenext:GetCoordinate():GetClosestPointToRoad(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
--- Function called when the group enteres a zone.
function armygroup:OnAfterEnterZone(From, Event, To, Zone)
local zone=Zone --Core.Zone#ZONE
-- Get a random zone.
local zonenext=GetRandomZone() --Core.Zone#ZONE
if zonenext then
-- Add waypoint.
armygroup:AddWaypoint(zonenext:GetCoordinate():GetClosestPointToRoad(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
-- Message.
local text=string.format("Group %s entered zone %s. Next stop zone %s", armygroup:GetName(), zone:GetName(), zonenext:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
end
--- Function called when the group leaves a zone.
function armygroup:OnAfterLeaveZone(From,Event,To,Zone)
local zone=Zone --Core.Zone#ZONE
-- Message.
local text=string.format("Group %s left zone %s", armygroup:GetName(), zone:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end

View File

@@ -1,61 +1,61 @@
---
-- ARMYGROUP: Task "Fire At Point" (Scheduled)
--
-- A group of rocked launchers is ordered to fire 20 shots at a target near the old airfield at Kobuleti.
-- Attack is scheduled for 0805 hours local time. Mission starts at 0800.
--
-- Note that the fire at point task is only executed if the group is in range (not too far and not too close).
-- This information is not available via scripting. So YOU need to make sure, that this is the case!
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("MLRS M270")
armygroup:Activate()
-- Ammo table.
local ammo0=armygroup:GetAmmoTot()
-- Target GROUP object.
local target=GROUP:FindByName("Red Target X")
-- Fire at point task. Fire 20 shots at 0805 hours.
local fireatpoint=armygroup:AddTaskFireAtPoint(target:GetCoordinate(), "8:05", 500, 20)
--- Function called when a DCS task is executed.
function armygroup:OnAfterTaskExecute(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Check that this is the task we want.
if task.id==fireatpoint.id then
-- Message.
local text=string.format("Executing task %s!", task.description)
env.info(text)
MESSAGE:New(text, 60):ToAll()
-- Update ammo table at the beginning of the task.
ammo0=armygroup:GetAmmoTot()
end
end
--- Function called when a DCS task is over.
function armygroup:OnAfterTaskDone(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Check that this is the right task.
if task.id==fireatpoint.id then
-- Get current ammo table.
local ammo=armygroup:GetAmmoTot()
-- Calculate diff used during the task.
local nshots=ammo0.Total-ammo.Total
-- Message.
local text=string.format("Task DONE! Fired %d shots", nshots)
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
end
---
-- ARMYGROUP: Task "Fire At Point" (Scheduled)
--
-- A group of rocked launchers is ordered to fire 20 shots at a target near the old airfield at Kobuleti.
-- Attack is scheduled for 0805 hours local time. Mission starts at 0800.
--
-- Note that the fire at point task is only executed if the group is in range (not too far and not too close).
-- This information is not available via scripting. So YOU need to make sure, that this is the case!
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("MLRS M270")
armygroup:Activate()
-- Ammo table.
local ammo0=armygroup:GetAmmoTot()
-- Target GROUP object.
local target=GROUP:FindByName("Red Target X")
-- Fire at point task. Fire 20 shots at 0805 hours.
local fireatpoint=armygroup:AddTaskFireAtPoint(target:GetCoordinate(), "8:05", 500, 20)
--- Function called when a DCS task is executed.
function armygroup:OnAfterTaskExecute(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Check that this is the task we want.
if task.id==fireatpoint.id then
-- Message.
local text=string.format("Executing task %s!", task.description)
env.info(text)
MESSAGE:New(text, 60):ToAll()
-- Update ammo table at the beginning of the task.
ammo0=armygroup:GetAmmoTot()
end
end
--- Function called when a DCS task is over.
function armygroup:OnAfterTaskDone(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Check that this is the right task.
if task.id==fireatpoint.id then
-- Get current ammo table.
local ammo=armygroup:GetAmmoTot()
-- Calculate diff used during the task.
local nshots=ammo0.Total-ammo.Total
-- Message.
local text=string.format("Task DONE! Fired %d shots", nshots)
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
end

View File

@@ -1,50 +1,50 @@
---
-- ARMYGROUP: Task "Fire At Point" at Waypoints
--
-- A group of two M109 Paladin is ordered to fire at two targets.
-- Each target is out of range. We create two waypoints. At each of the waypoint a "Fire at Point" task is executed.
--
-- Note that the fire at point task is only executed if the group is in range (not too far and not too close).
-- This information is not available via scripting. So YOU need to make sure, that this is the case!
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("M109 Paladin")
armygroup:Activate()
-- Increase DCS log output.
armygroup:SetVerbosity(3)
-- Targets.
local target1=GROUP:FindByName("Red Target X")
local target2=ZONE:New("Zone Poti")
-- Waypoints where the tasks are executed. Not that the group will stop at the waypoints until all waypoint tasks are over.
local wpAlpha=armygroup:AddWaypoint(ZONE:New("Zone Firepoint Alpha"))
local wpBravo=armygroup:AddWaypoint(ZONE:New("Zone Firepoint Bravo"), nil, nil, ENUMS.Formation.Vehicle.OnRoad)
-- Fire at point task.
local fireatpoint1=armygroup:AddTaskWaypointFireAtPoint(target1, wpAlpha, 250, 10)
local fireatpoint2=armygroup:AddTaskWaypointFireAtPoint(target2, wpBravo, 500, 15)
--- Function called when a DCS task is executed.
function armygroup:OnAfterTaskExecute(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Message.
local text=string.format("Executing task %s!", task.description)
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
--- Function called when a DCS task is over.
function armygroup:OnAfterTaskDone(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Message.
local text=string.format("Task %s DONE!", task.description)
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
---
-- ARMYGROUP: Task "Fire At Point" at Waypoints
--
-- A group of two M109 Paladin is ordered to fire at two targets.
-- Each target is out of range. We create two waypoints. At each of the waypoint a "Fire at Point" task is executed.
--
-- Note that the fire at point task is only executed if the group is in range (not too far and not too close).
-- This information is not available via scripting. So YOU need to make sure, that this is the case!
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("M109 Paladin")
armygroup:Activate()
-- Increase DCS log output.
armygroup:SetVerbosity(3)
-- Targets.
local target1=GROUP:FindByName("Red Target X")
local target2=ZONE:New("Zone Poti")
-- Waypoints where the tasks are executed. Not that the group will stop at the waypoints until all waypoint tasks are over.
local wpAlpha=armygroup:AddWaypoint(ZONE:New("Zone Firepoint Alpha"))
local wpBravo=armygroup:AddWaypoint(ZONE:New("Zone Firepoint Bravo"), nil, nil, ENUMS.Formation.Vehicle.OnRoad)
-- Fire at point task.
local fireatpoint1=armygroup:AddTaskWaypointFireAtPoint(target1, wpAlpha, 250, 10)
local fireatpoint2=armygroup:AddTaskWaypointFireAtPoint(target2, wpBravo, 500, 15)
--- Function called when a DCS task is executed.
function armygroup:OnAfterTaskExecute(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Message.
local text=string.format("Executing task %s!", task.description)
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
--- Function called when a DCS task is over.
function armygroup:OnAfterTaskDone(From, Event, To, Task)
local task=Task --Ops.OpsGroup#OPSGROUP.Task
-- Message.
local text=string.format("Task %s DONE!", task.description)
env.info(text)
MESSAGE:New(text, 60):ToAll()
end

View File

@@ -1,36 +1,36 @@
---
-- ARMYGROUP: Switch Formation
--
-- A group ten Abrams tanks is conducting an exercise in the desert.
-- They are practicing to seemlessly change formations when certain waypoints are passed.
--
-- When reaching waypoint 7 (the first waypoint is the initial (spawn) position), the
-- group searches the closest road and will drive to Palmyra airbase.
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("M1A2 Abrams")
armygroup:Activate(1)
-- Default formation is Echelon Left. We switch to this right after the group is activated.
armygroup:SetDefaultFormation(ENUMS.Formation.Vehicle.EchelonLeft)
--- Function called when a group passes a waypoint.
function armygroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
if waypoint.uid==2 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.EchelonRight)
elseif waypoint.uid==3 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.Vee)
elseif waypoint.uid==4 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.Rank)
elseif waypoint.uid==5 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.Cone)
elseif waypoint.uid==6 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.Diamond)
elseif waypoint.uid==7 then
armygroup:AddWaypoint(ZONE:New("Zone Palmyra Airport"):GetCoordinate(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
end
---
-- ARMYGROUP: Switch Formation
--
-- A group ten Abrams tanks is conducting an exercise in the desert.
-- They are practicing to seemlessly change formations when certain waypoints are passed.
--
-- When reaching waypoint 7 (the first waypoint is the initial (spawn) position), the
-- group searches the closest road and will drive to Palmyra airbase.
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("M1A2 Abrams")
armygroup:Activate(1)
-- Default formation is Echelon Left. We switch to this right after the group is activated.
armygroup:SetDefaultFormation(ENUMS.Formation.Vehicle.EchelonLeft)
--- Function called when a group passes a waypoint.
function armygroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
if waypoint.uid==2 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.EchelonRight)
elseif waypoint.uid==3 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.Vee)
elseif waypoint.uid==4 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.Rank)
elseif waypoint.uid==5 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.Cone)
elseif waypoint.uid==6 then
armygroup:SwitchFormation(ENUMS.Formation.Vehicle.Diamond)
elseif waypoint.uid==7 then
armygroup:AddWaypoint(ZONE:New("Zone Palmyra Airport"):GetCoordinate(), 30, nil, ENUMS.Formation.Vehicle.OnRoad)
end
end

View File

@@ -1,112 +1,114 @@
---
-- ARMYGROUP: Rearming
--
-- A group of rocket launchers is ordered to fire all it has at a target near the old airfield at Kobuleti at 0805 hours.
--
-- Once it has fired all its rockets, it is ordered to drive to a rearming truck located nearby.
--
-- When the rearming is finished, the group is send to its initial position where it will start another attack on the target coordinates.
-- (We do not check if the target has already been destroyed here.)
--
-- Firing and rearming will go on "forever".
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("MLRS M270")
armygroup:Activate()
-- Increase output to DCS log file.
armygroup:SetVerbosity(3)
-- Initial amount of ammo.
local ammo0=armygroup:GetAmmo0()
-- Target GROUP object.
local target=GROUP:FindByName("Red Target X")
-- The target coordinate.
local targetCoordinate=target:GetCoordinate()
-- Fire at point task.
local fireatpoint=armygroup:AddTaskFireAtPoint(targetCoordinate, "8:05", 500, ammo0.Rockets)
-- Rearming truck zone.
local RearmingTruck=ZONE_UNIT:New("Rearming Truck", UNIT:FindByName("M818-1"), 25)
--- Function called when the group is completely out of ammo.
function armygroup:OnAfterOutOfAmmo()
-- Message.
local text=string.format("Group is completely out of ammo!")
env.info(text)
MESSAGE:New(text, 60):ToAll()
-- Get a coordinate near the rearming truck.
local coordinate=RearmingTruck:GetRandomCoordinate(10, 25)
-- Order group to rearm at a specific coordinate.
self:Rearm(coordinate)
end
--- Function called when the group is out of rockets.
function armygroup:OnAfterOutOfRockets()
-- Message.
local text=string.format("Group is out of rockets!")
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
--- Function called when the group is completely out of ammo.
function armygroup:OnAfterRearm(Coordinate)
-- Message.
local text=string.format("Group is send to rearm")
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
--- Function called when the group has arrived at the rearming location.
function armygroup:OnAfterRearming()
-- Message.
local text=string.format("Group waiting to be rearmed")
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
--- Function called when the group was rearmed.
function armygroup:OnAfterRearmed()
-- Get current ammo.
local ammo=armygroup:GetAmmoTot()
-- Message.
local text=string.format("Group is rearmed. Number of rockets %d", ammo.Rockets)
env.info(text)
MESSAGE:New(text, 60):ToAll()
-- Get first waypoint (initial position).
local wp=armygroup:GetWaypointByID(1)
-- Fire at point task when waypoint 1 is reached.
local fireatpoint=armygroup:AddTaskWaypointFireAtPoint(targetCoordinate, wp, 500, ammo0.Rockets)
-- Goto first waypoint at default speed in Vee formation.
armygroup:GotoWaypoint(1, nil, ENUMS.Formation.Vehicle.Vee)
end
-- Monitor ammo status every 30 sec.
local function CheckAmmo()
local ammo=armygroup:GetAmmoTot()
local text=string.format("Rockets %d/%d [%s]", ammo.Rockets, ammo0.Rockets, armygroup:GetState())
MESSAGE:New(text, 25, armygroup:GetName()):ToAll()
end
local timer=TIMER:New(CheckAmmo):Start(30, 30)
---
-- ARMYGROUP: Rearming
--
-- A group of rocket launchers is ordered to fire all it has at a target near the old airfield at Kobuleti at 0805 hours.
--
-- Once it has fired all its rockets, it is ordered to drive to a rearming truck located nearby.
--
-- When the rearming is finished, the group is send to its initial position where it will start another attack on the target coordinates.
-- (We do not check if the target has already been destroyed here.)
--
-- Firing and rearming will go on "forever".
---
PROFILER.Start()
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("MLRS M270")
armygroup:Activate()
-- Increase output to DCS log file.
armygroup:SetVerbosity(3)
-- Initial amount of ammo.
local ammo0=armygroup:GetAmmo0()
-- Target GROUP object.
local target=GROUP:FindByName("Red Target X")
-- The target coordinate.
local targetCoordinate=target:GetCoordinate()
-- Fire at point task.
local fireatpoint=armygroup:AddTaskFireAtPoint(targetCoordinate, "8:05", 500, ammo0.Rockets)
-- Rearming truck zone.
local RearmingTruck=ZONE_UNIT:New("Rearming Truck", UNIT:FindByName("M818-1"), 25)
--- Function called when the group is completely out of ammo.
function armygroup:OnAfterOutOfAmmo()
-- Message.
local text=string.format("Group is completely out of ammo!")
env.info(text)
MESSAGE:New(text, 60):ToAll()
-- Get a coordinate near the rearming truck.
local coordinate=RearmingTruck:GetRandomCoordinate(10, 25)
-- Order group to rearm at a specific coordinate.
self:Rearm(coordinate)
end
--- Function called when the group is out of rockets.
function armygroup:OnAfterOutOfRockets()
-- Message.
local text=string.format("Group is out of rockets!")
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
--- Function called when the group is completely out of ammo.
function armygroup:OnAfterRearm(Coordinate)
-- Message.
local text=string.format("Group is send to rearm")
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
--- Function called when the group has arrived at the rearming location.
function armygroup:OnAfterRearming()
-- Message.
local text=string.format("Group waiting to be rearmed")
env.info(text)
MESSAGE:New(text, 60):ToAll()
end
--- Function called when the group was rearmed.
function armygroup:OnAfterRearmed()
-- Get current ammo.
local ammo=armygroup:GetAmmoTot()
-- Message.
local text=string.format("Group is rearmed. Number of rockets %d", ammo.Rockets)
env.info(text)
MESSAGE:New(text, 60):ToAll()
-- Get first waypoint (initial position).
local wp=armygroup:GetWaypointByID(1)
-- Fire at point task when waypoint 1 is reached.
local fireatpoint=armygroup:AddTaskWaypointFireAtPoint(targetCoordinate, wp, 500, ammo0.Rockets)
-- Goto first waypoint at default speed in Vee formation.
armygroup:GotoWaypoint(1, nil, ENUMS.Formation.Vehicle.Vee)
end
-- Monitor ammo status every 30 sec.
local function CheckAmmo()
local ammo=armygroup:GetAmmoTot()
local text=string.format("Rockets %d/%d [%s]", ammo.Rockets, ammo0.Rockets, armygroup:GetState())
MESSAGE:New(text, 25, armygroup:GetName()):ToAll()
end
local timer=TIMER:New(CheckAmmo):Start(30, 30)

View File

@@ -1,60 +1,60 @@
---
-- ARMYGROUP: Detection Groups
--
-- A Humvee is located at the old airfield at Kobuleti and will report all enemy groups it detects.
--
-- A couple of different red groups will pass along. All have ROE=Weapon Hold.
--
-- PS: Keep in mind that DCS detection works in mysterious ways.
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("JTAC Hmmwv")
armygroup:Activate()
-- Switch detection on.
armygroup:SetDetection(true)
--- Function called whenever a group has been detected for the first time.
function armygroup:OnAfterDetectedGroupNew(From, Event, To, Group)
local group=Group --Wrapper.Group#GROUP
local text=string.format("Detected NEW group %s", group:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
--- Function called whenever a dected group could not be detected anymore.
function armygroup:OnAfterDetectedGroupLost(From, Event, To, Group)
local group=Group --Wrapper.Group#GROUP
local text=string.format("LOST detected group %s", group:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
-- Info on LASER target and code.
local function CheckDetection()
-- Set of detected units.
local detectedset=armygroup:GetDetectedGroups()
-- Cound number of alive detected units.
local ndetected=detectedset:CountAlive()
-- Info on detected units.
local text=string.format("Detected groups (%d):", ndetected)
if ndetected>0 then
for _,_group in pairs(detectedset:GetSet()) do
local group=_group --Wrapper.Group#GROUP
text=text..string.format("\n- %s [threat level=%d]", group:GetName(), group:GetThreatLevel())
end
else
text=text.." None"
end
-- Info message.
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
-- Timer to check threats every 30 sec.
---
-- ARMYGROUP: Detection Groups
--
-- A Humvee is located at the old airfield at Kobuleti and will report all enemy groups it detects.
--
-- A couple of different red groups will pass along. All have ROE=Weapon Hold.
--
-- PS: Keep in mind that DCS detection works in mysterious ways.
---
-- Create an ARMYGROUP object.
local armygroup=ARMYGROUP:New("JTAC Hmmwv")
armygroup:Activate()
-- Switch detection on.
armygroup:SetDetection(true)
--- Function called whenever a group has been detected for the first time.
function armygroup:OnAfterDetectedGroupNew(From, Event, To, Group)
local group=Group --Wrapper.Group#GROUP
local text=string.format("Detected NEW group %s", group:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
--- Function called whenever a dected group could not be detected anymore.
function armygroup:OnAfterDetectedGroupLost(From, Event, To, Group)
local group=Group --Wrapper.Group#GROUP
local text=string.format("LOST detected group %s", group:GetName())
MESSAGE:New(text, 120):ToAll()
env.info(text)
end
-- Info on LASER target and code.
local function CheckDetection()
-- Set of detected units.
local detectedset=armygroup:GetDetectedGroups()
-- Cound number of alive detected units.
local ndetected=detectedset:CountAlive()
-- Info on detected units.
local text=string.format("Detected groups (%d):", ndetected)
if ndetected>0 then
for _,_group in pairs(detectedset:GetSet()) do
local group=_group --Wrapper.Group#GROUP
text=text..string.format("\n- %s [threat level=%d]", group:GetName(), group:GetThreatLevel())
end
else
text=text.." None"
end
-- Info message.
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
-- Timer to check threats every 30 sec.
TIMER:New(CheckDetection):Start(10, 30)

View File

@@ -1,79 +1,79 @@
---
-- ARMYGROUP: Lase Unit
--
-- A JTAC infantry group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
-- The target is a group of two BTR-80s. In this exercise, we want to lase a specific unit.
--
-- After 10 min, we switch the laser code from the default 1688 to 1711.
-- After 20 min, the laser is switched off.
--
-- PS: You can choose the JTAC/Operator slot and jump into a Bradley (RALT+J) or an A-10C client and turn on the night vision goggles to observe the LASER (or better the IR-pointer).
---
-- Create and ARMYGROUP.
local jtac=ARMYGROUP:New("JTAC Batcher")
-- Get a specific unit.
local Target=UNIT:FindByName("Red Target X-1")
-- Switch LASER on in one sec.
jtac:__LaserOn(1, Target)
-- Switch LASER code to 1711 after 10 min.
jtac:__LaserCode(10*60, 1711)
-- Turn LASER off after 20 min.
jtac:__LaserOff(20*60)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d)", jtac:GetLaserCode())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER code is changed.
function jtac:OnAfterLaserCode(From, Event, To, Code)
local text=string.format("Switching to LASER code %d", Code)
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit gotline of sight.
function jtac:OnAfterLaserGotLOS(From, Event, To)
local text=string.format("Got line of sight to target!")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit lost line of sight.
function jtac:OnAfterLaserLostLOS(From, Event, To)
local text=string.format("Lost Line of Sight to target. Switching laser off temporarily until we regrain LOS")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
---
-- Unrelated helper stuff.
---
-- Info on LASER target and code.
local function jtactarget()
local unit=jtac:GetLaserTarget()
local text="No target"
if unit then
text=string.format("Lasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
---
-- ARMYGROUP: Lase Unit
--
-- A JTAC infantry group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
-- The target is a group of two BTR-80s. In this exercise, we want to lase a specific unit.
--
-- After 10 min, we switch the laser code from the default 1688 to 1711.
-- After 20 min, the laser is switched off.
--
-- PS: You can choose the JTAC/Operator slot and jump into a Bradley (RALT+J) or an A-10C client and turn on the night vision goggles to observe the LASER (or better the IR-pointer).
---
-- Create and ARMYGROUP.
local jtac=ARMYGROUP:New("JTAC Batcher")
-- Get a specific unit.
local Target=UNIT:FindByName("Red Target X-1")
-- Switch LASER on in one sec.
jtac:__LaserOn(1, Target)
-- Switch LASER code to 1711 after 10 min.
jtac:__LaserCode(10*60, 1711)
-- Turn LASER off after 20 min.
jtac:__LaserOff(20*60)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d)", jtac:GetLaserCode())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER code is changed.
function jtac:OnAfterLaserCode(From, Event, To, Code)
local text=string.format("Switching to LASER code %d", Code)
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit gotline of sight.
function jtac:OnAfterLaserGotLOS(From, Event, To)
local text=string.format("Got line of sight to target!")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit lost line of sight.
function jtac:OnAfterLaserLostLOS(From, Event, To)
local text=string.format("Lost Line of Sight to target. Switching laser off temporarily until we regrain LOS")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
---
-- Unrelated helper stuff.
---
-- Info on LASER target and code.
local function jtactarget()
local unit=jtac:GetLaserTarget()
local text="No target"
if unit then
text=string.format("Lasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
TIMER:New(jtactarget):Start(30, 30)

View File

@@ -1,76 +1,76 @@
---
-- ARMYGROUP: Lase Group
--
-- A JTAC infantry group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
-- The target is a group of two BTR-80s. The JTAC will start to lase the unit in the group with the highest threat level (not important here).
-- When the lased unit is dead, the JTAC will automatically switch to the next highest threat of the group until the whole group is dead.
--
-- PS: You can choose the JTAC/Operator slot and jump into a Bradley (RALT+J) or an A-10C client and turn on the night vision goggles to observe the LASER (or better the IR-pointer).
---
-- Create and ARMYGROUP.
local jtac=ARMYGROUP:New("JTAC Batcher")
-- Get first unit.
local Target=GROUP:FindByName("Red Target X")
-- Switch LASER on after 5 seconds.
jtac:__LaserOn(5, Target)
-- Turn LASER off after 25 min.
jtac:__LaserOff(25*60)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d)", jtac:GetLaserCode())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit gotline of sight.
function jtac:OnAfterLaserGotLOS(From, Event, To)
local text=string.format("Got line of sight to target!")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit lost line of sight.
function jtac:OnAfterLaserLostLOS(From, Event, To)
local text=string.format("Lost Line of Sight to target. Switching laser off temporarily until we regrain LOS")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
---
-- Unrelated helper stuff.
---
-- Destroy target a unit of the target group every 5 min.
local function destroy()
local unit=jtac:GetLaserTarget()
if unit then
unit:Explode()
end
end
TIMER:New(destroy):SetMaxFunctionCalls(#Target:GetUnits()):Start(5*60, 5*60)
-- Info on LASER target and code.
local function jtactarget()
local unit=jtac:GetLaserTarget()
local text="No target"
if unit then
text=string.format("Lasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
---
-- ARMYGROUP: Lase Group
--
-- A JTAC infantry group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
-- The target is a group of two BTR-80s. The JTAC will start to lase the unit in the group with the highest threat level (not important here).
-- When the lased unit is dead, the JTAC will automatically switch to the next highest threat of the group until the whole group is dead.
--
-- PS: You can choose the JTAC/Operator slot and jump into a Bradley (RALT+J) or an A-10C client and turn on the night vision goggles to observe the LASER (or better the IR-pointer).
---
-- Create and ARMYGROUP.
local jtac=ARMYGROUP:New("JTAC Batcher")
-- Get first unit.
local Target=GROUP:FindByName("Red Target X")
-- Switch LASER on after 5 seconds.
jtac:__LaserOn(5, Target)
-- Turn LASER off after 25 min.
jtac:__LaserOff(25*60)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d)", jtac:GetLaserCode())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit gotline of sight.
function jtac:OnAfterLaserGotLOS(From, Event, To)
local text=string.format("Got line of sight to target!")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit lost line of sight.
function jtac:OnAfterLaserLostLOS(From, Event, To)
local text=string.format("Lost Line of Sight to target. Switching laser off temporarily until we regrain LOS")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
---
-- Unrelated helper stuff.
---
-- Destroy target a unit of the target group every 5 min.
local function destroy()
local unit=jtac:GetLaserTarget()
if unit then
unit:Explode()
end
end
TIMER:New(destroy):SetMaxFunctionCalls(#Target:GetUnits()):Start(5*60, 5*60)
-- Info on LASER target and code.
local function jtactarget()
local unit=jtac:GetLaserTarget()
local text="No target"
if unit then
text=string.format("Lasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
TIMER:New(jtactarget):Start(30, 30)

View File

@@ -1,71 +1,69 @@
---
-- ARMYGROUP: Lase Static
--
-- A JTAC infantry group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
-- The target is a watch tower in the vicinity. We use 1689 as laser code.
--
-- The target is destroyed after 10 min. Then the laser is switched off automatically.
--
-- PS: You can choose the JTAC/Operator slot and jump into a Bradley (RALT+J) or an A-10C client and turn on the night vision goggles to observe the LASER (or better the IR-pointer).
---
-- Create and ARMYGROUP.
local jtac=ARMYGROUP:New("JTAC Batcher")
-- Set LASER code. Default is 1688, which would NOT need to be set explicitly.
jtac:SetLaser(1689)
-- Get static target.
local Target=STATIC:FindByName("Static Watch Tower")
-- The target is destroyed.
Target:GetCoordinate():Explosion(1000, 10*60)
-- Switch LASER on.
jtac:LaserOn(Target)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d)", jtac:GetLaserCode())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit gotline of sight.
function jtac:OnAfterLaserGotLOS(From, Event, To)
local text=string.format("Got line of sight to target!")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit lost line of sight.
function jtac:OnAfterLaserLostLOS(From, Event, To)
local text=string.format("Lost Line of Sight to target. Switching laser off temporarily until we regrain LOS")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
---
-- Unrelated helper stuff.
---
-- Info on LASER target and code.
local function jtactarget()
local unit=jtac:GetLaserTarget()
local text="No target"
if unit then
text=string.format("Lasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
---
-- ARMYGROUP: Lase Static
--
-- A JTAC infantry group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
-- The target is a watch tower in the vicinity. We use 1689 as laser code.
--
-- The target is destroyed after 10 min. Then the laser is switched off automatically.
---
-- Create and ARMYGROUP.
local jtac=ARMYGROUP:New("JTAC Batcher")
-- Set LASER code. Default is 1688, which would NOT need to be set explicitly.
jtac:SetLaser(1689)
-- Get static target.
local Target=STATIC:FindByName("Static Watch Tower")
-- The target is destroyed.
Target:GetCoordinate():Explosion(1000, 10*60)
-- Switch LASER on.
jtac:LaserOn(Target)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d)", jtac:GetLaserCode())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit gotline of sight.
function jtac:OnAfterLaserGotLOS(From, Event, To)
local text=string.format("Got line of sight to target!")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the lasing unit lost line of sight.
function jtac:OnAfterLaserLostLOS(From, Event, To)
local text=string.format("Lost Line of Sight to target. Switching laser off temporarily until we regrain LOS")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
---
-- Unrelated helper stuff.
---
-- Info on LASER target and code.
local function jtactarget()
local unit=jtac:GetLaserTarget()
local text="No target"
if unit then
text=string.format("Lasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
TIMER:New(jtactarget):Start(30, 30)

View File

@@ -1,58 +1,58 @@
---
-- ARMYGROUP: Lase Coordinate
--
-- A JTAC infantry group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
-- The target is a watch tower in the vicinity. We use its coordinate and lase it at the top of the building. We use the default 1688 as laser code.
--
-- PS: You can choose the JTAC/Operator slot and jump into a Bradley (RALT+J) or an A-10C client and turn on the night vision goggles to observe the LASER (or better the IR-pointer).
---
-- Create and ARMYGROUP.
local jtac=ARMYGROUP:New("JTAC Batcher")
-- Get the coordinate of a static target. We lase 5 meters above ground.
local Watchtower=STATIC:FindByName("Static Watch Tower")
-- Get dimensions of the target.
local sizemax, length, height, width=Watchtower:GetObjectSize()
-- Specify the target coordinate of the laser.
local Target=Watchtower:GetCoordinate():SetAltitude(height)
-- Switch LASER on.
jtac:LaserOn(Target)
-- Switch LASER on.
jtac:__LaserOff(20*60)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d)", jtac:GetLaserCode())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
---
-- Unrelated helper stuff.
---
-- Info on LASER target and code.
local function jtactarget()
local unit=jtac:GetLaserTarget()
local text="No target"
if unit then
text=string.format("Lasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
---
-- ARMYGROUP: Lase Coordinate
--
-- A JTAC infantry group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
-- The target is a watch tower in the vicinity. We use its coordinate and lase it at the top of the building. We use the default 1688 as laser code.
--
-- PS: You can choose the JTAC/Operator slot and jump into a Bradley (RALT+J) or an A-10C client and turn on the night vision goggles to observe the LASER (or better the IR-pointer).
---
-- Create and ARMYGROUP.
local jtac=ARMYGROUP:New("JTAC Batcher")
-- Get the coordinate of a static target. We lase 5 meters above ground.
local Watchtower=STATIC:FindByName("Static Watch Tower")
-- Get dimensions of the target.
local sizemax, length, height, width=Watchtower:GetObjectSize()
-- Specify the target coordinate of the laser.
local Target=Watchtower:GetCoordinate():SetAltitude(height)
-- Switch LASER on.
jtac:LaserOn(Target)
-- Switch LASER on.
jtac:__LaserOff(20*60)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d)", jtac:GetLaserCode())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
---
-- Unrelated helper stuff.
---
-- Info on LASER target and code.
local function jtactarget()
local unit=jtac:GetLaserTarget()
local text="No target"
if unit then
text=string.format("Lasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
TIMER:New(jtactarget):Start(30, 30)

View File

@@ -1,109 +1,105 @@
---
-- ARMYGROUP: Lase Detected Units
--
-- A JTAC Humvee group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
-- Only targets that are detected by the group are lased. If the detected target is lost, the laser is switched off.
-- If a new target with a higher threat level is detected, the JTAC will automatically switch to that target.
--
-- The first target the group detects should be a rather harmless group of BTRs.
-- Later in the mission, some T-90 tanks enter the battlefield. These are a higher threat and the JTAC will switch the laser to the tanks.
---
-- Create and ARMYGROUP.
local jtac=ARMYGROUP:New("JTAC Hmmwv")
-- Switch detection on.
jtac:SetDetection(true)
-- Activate highter threat after 10 min.
local T90=GROUP:FindByName("T-90")
T90:Activate(10*60)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d) at target %s", jtac:GetLaserCode(), Target:GetName())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
-- Info on LASER target and code.
local function CheckThreats()
-- Get the highst (detected) threat to the group.
local threatunit,threatlevel=jtac:GetHighestThreat()
-- Set of detected units.
local detectedset=jtac:GetDetectedUnits()
-- Cound number of alive detected units.
local ndetected=detectedset:CountAlive()
-- Info on detected units.
local text=string.format("Detected units (%d):", ndetected)
if ndetected>0 then
for _,_unit in pairs(detectedset:GetSet()) do
local unit=_unit --Wrapper.Unit#UNIT
text=text..string.format("\n- %s [threat level=%d]", unit:GetName(), unit:GetThreatLevel())
end
else
text=text.." None"
end
-- We got a threat to the group.
if threatunit then
text=text..string.format("\nHighest detected threat %s with threat level %d", threatunit:GetName(), threatlevel)
-- Current laser target.
local target=jtac:GetLaserTarget()
local newtarget=nil --Wrapper.Unit#UNIT
if target then
local currentthreatlevel=target:GetThreatLevel()
if threatlevel>currentthreatlevel then
env.info("FF higher threat detected!")
newtarget=threatunit
end
else
env.info("FF no current target using this one")
newtarget=threatunit
end
if newtarget then
if jtac:IsLasing() then
jtac:LaserOff()
end
env.info("FF New target "..newtarget:GetName())
jtac:LaserOn(newtarget)
end
end
-- Get current laser target.
local unit=jtac:GetLaserTarget()
if unit then
text=text..string.format("\nLasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
else
text=text.."\nNot lasing any target"
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
-- Info message.
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
-- Timer to check threats every 30 sec.
TIMER:New(CheckThreats):Start(10, 10)
---
-- ARMYGROUP: Lase Detected Units
--
-- A JTAC infantry group is located on the roof of a building new the old airfield at Kobuleti and practicing to lase targets.
--
---
-- Create and ARMYGROUP.
--local jtac=ARMYGROUP:New("JTAC Hmmwv")
local jtac=ARMYGROUP:New("JTAC Batcher")
-- Switch detection on.
jtac:SetDetection(true)
-- Activate highter threat after 10 min.
local T90=GROUP:FindByName("T-90")
T90:Activate(10*60)
--- Function called when the LASER is switched on.
function jtac:OnAfterLaserOn(From, Event, To, Target)
local text=string.format("Switching LASER On (code %d) at target %s", jtac:GetLaserCode(), Target:GetName())
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
--- Function called when the LASER is switched off.
function jtac:OnAfterLaserOff(From, Event, To)
local text=string.format("Switching LASER Off")
MESSAGE:New(text, 60):ToAll()
env.info(text)
end
-- Info on LASER target and code.
local function CheckThreats()
-- Get the highst (detected) threat to the group.
local threatunit,threatlevel=jtac:GetHighestThreat()
-- Set of detected units.
local detectedset=jtac:GetDetectedUnits()
-- Cound number of alive detected units.
local ndetected=detectedset:CountAlive()
-- Info on detected units.
local text=string.format("Detected units (%d):", ndetected)
if ndetected>0 then
for _,_unit in pairs(detectedset:GetSet()) do
local unit=_unit --Wrapper.Unit#UNIT
text=text..string.format("\n- %s [threat level=%d]", unit:GetName(), unit:GetThreatLevel())
end
else
text=text.." None"
end
-- We got a threat to the group.
if threatunit then
text=text..string.format("\nHighest detected threat %s with threat level %d", threatunit:GetName(), threatlevel)
-- Current laser target.
local target=jtac:GetLaserTarget()
local newtarget=nil --Wrapper.Unit#UNIT
if target then
local currentthreatlevel=target:GetThreatLevel()
if threatlevel>currentthreatlevel then
env.info("FF higher threat detected!")
newtarget=threatunit
end
else
env.info("FF no current target using this one")
newtarget=threatunit
end
if newtarget then
if jtac:IsLasing() then
jtac:LaserOff()
end
env.info("FF New target "..newtarget:GetName())
jtac:LaserOn(newtarget)
end
end
-- Get current laser target.
local unit=jtac:GetLaserTarget()
if unit then
text=text..string.format("\nLasing target %s at code %d", unit:GetName(), jtac:GetLaserCode())
else
text=text.."\nNot lasing any target"
end
text=text..string.format(" (ON=%s, LOS=%s)", tostring(jtac:IsLasing()), tostring(jtac.spot.LOS))
-- Info message.
MESSAGE:New(text, 25):ToAll()
env.info(text)
end
-- Timer to check threats every 30 sec.
TIMER:New(CheckThreats):Start(10, 10)