mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
AUFTRAG
- Recon Mission
This commit is contained in:
parent
ed402e2f5f
commit
629c5e7739
@ -265,6 +265,18 @@ do -- SET_BASE
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sort the set by name.
|
||||||
|
-- @param #SET_BASE self
|
||||||
|
-- @return Core.Base#BASE The added BASE Object.
|
||||||
|
function SET_BASE:SortByName()
|
||||||
|
|
||||||
|
local function sort(a, b)
|
||||||
|
return a<b
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(self.Index)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- Get the *union* of two sets.
|
--- Get the *union* of two sets.
|
||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
|
|||||||
@ -1219,6 +1219,31 @@ function AUFTRAG:NewPATROLZONE(Zone, Speed, Altitude)
|
|||||||
return mission
|
return mission
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Create a RECON mission.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @param Core.Set#SET_ZONE ZoneSet The recon zones.
|
||||||
|
-- @param #number Speed Speed in knots.
|
||||||
|
-- @param #number Altitude Altitude in feet. Only for airborne units. Default 2000 feet ASL.
|
||||||
|
-- @return #AUFTRAG self
|
||||||
|
function AUFTRAG:NewRECON(ZoneSet, Speed, Altitude)
|
||||||
|
|
||||||
|
local mission=AUFTRAG:New(AUFTRAG.Type.RECON)
|
||||||
|
|
||||||
|
mission:_TargetFromObject(ZoneSet)
|
||||||
|
|
||||||
|
mission.optionROE=ENUMS.ROE.WeaponHold
|
||||||
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
mission.optionAlarm=ENUMS.AlarmState.Auto
|
||||||
|
|
||||||
|
mission.missionFraction=0.5
|
||||||
|
mission.missionSpeed=Speed and UTILS.KnotsToKmph(Speed) or nil
|
||||||
|
mission.missionAltitude=Altitude and UTILS.FeetToMeters(Altitude) or UTILS.FeetToMeters(2000)
|
||||||
|
|
||||||
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
|
return mission
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Create a mission to attack a group. Mission type is automatically chosen from the group category.
|
--- Create a mission to attack a group. Mission type is automatically chosen from the group category.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
@ -3071,7 +3096,8 @@ function AUFTRAG:GetTargetCoordinate()
|
|||||||
|
|
||||||
elseif self.engageTarget then
|
elseif self.engageTarget then
|
||||||
|
|
||||||
return self.engageTarget:GetCoordinate()
|
local coord=self.engageTarget:GetCoordinate()
|
||||||
|
return coord
|
||||||
|
|
||||||
else
|
else
|
||||||
self:E(self.lid.."ERROR: Cannot get target coordinate!")
|
self:E(self.lid.."ERROR: Cannot get target coordinate!")
|
||||||
@ -3453,8 +3479,21 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
|
|||||||
-------------------
|
-------------------
|
||||||
-- RECON Mission --
|
-- RECON Mission --
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
-- TODO: What? Table of coordinates?
|
local DCStask={}
|
||||||
|
|
||||||
|
DCStask.id="ReconMission"
|
||||||
|
|
||||||
|
-- We create a "fake" DCS task and pass the parameters to the OPSGROUP.
|
||||||
|
local param={}
|
||||||
|
param.target=self.engageTarget
|
||||||
|
param.altitude=self.missionAltitude
|
||||||
|
param.speed=self.missionSpeed
|
||||||
|
param.lastindex=nil
|
||||||
|
|
||||||
|
DCStask.params=param
|
||||||
|
|
||||||
|
table.insert(DCStasks, DCStask)
|
||||||
|
|
||||||
elseif self.type==AUFTRAG.Type.SEAD then
|
elseif self.type==AUFTRAG.Type.SEAD then
|
||||||
|
|
||||||
@ -3517,7 +3556,7 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
|
|||||||
|
|
||||||
-- We create a "fake" DCS task and pass the parameters to the FLIGHTGROUP.
|
-- We create a "fake" DCS task and pass the parameters to the FLIGHTGROUP.
|
||||||
local param={}
|
local param={}
|
||||||
param.unitname=self:GetTargetName() --self.carrier:GetName()
|
param.unitname=self:GetTargetName()
|
||||||
param.offsetX=200
|
param.offsetX=200
|
||||||
param.offsetZ=240
|
param.offsetZ=240
|
||||||
param.altitude=70
|
param.altitude=70
|
||||||
|
|||||||
@ -2060,7 +2060,9 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n)
|
|||||||
|
|
||||||
if task then
|
if task then
|
||||||
if task.dcstask.id=="PatrolZone" then
|
if task.dcstask.id=="PatrolZone" then
|
||||||
-- For patrol zone, we need to allow the update.
|
-- For patrol zone, we need to allow the update as we insert new waypoints.
|
||||||
|
elseif task.dcstask.id=="ReconMission" then
|
||||||
|
-- For recon missions, we need to allow the update as we insert new waypoints.
|
||||||
else
|
else
|
||||||
local taskname=task and task.description or "No description"
|
local taskname=task and task.description or "No description"
|
||||||
self:E(self.lid..string.format("WARNING: Update route denied because taskcurrent=%d>0! Task description = %s", self.taskcurrent, tostring(taskname)))
|
self:E(self.lid..string.format("WARNING: Update route denied because taskcurrent=%d>0! Task description = %s", self.taskcurrent, tostring(taskname)))
|
||||||
|
|||||||
@ -556,7 +556,6 @@ function OPSGROUP:New(group)
|
|||||||
self:AddTransition("*", "Damaged", "*") -- Someone in the group took damage.
|
self:AddTransition("*", "Damaged", "*") -- Someone in the group took damage.
|
||||||
|
|
||||||
self:AddTransition("*", "UpdateRoute", "*") -- Update route of group. Only if airborne.
|
self:AddTransition("*", "UpdateRoute", "*") -- Update route of group. Only if airborne.
|
||||||
self:AddTransition("*", "PassingWaypoint", "*") -- Passing waypoint.
|
|
||||||
|
|
||||||
self:AddTransition("*", "Wait", "*") -- Group will wait for further orders.
|
self:AddTransition("*", "Wait", "*") -- Group will wait for further orders.
|
||||||
|
|
||||||
@ -3031,8 +3030,13 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
|
|
||||||
-- Parameters.
|
-- Parameters.
|
||||||
local zone=Task.dcstask.params.zone --Core.Zone#ZONE
|
local zone=Task.dcstask.params.zone --Core.Zone#ZONE
|
||||||
|
|
||||||
|
-- Random coordinate in zone.
|
||||||
local Coordinate=zone:GetRandomCoordinate()
|
local Coordinate=zone:GetRandomCoordinate()
|
||||||
Coordinate:MarkToAll("Random Patrol Zone Coordinate")
|
|
||||||
|
--Coordinate:MarkToAll("Random Patrol Zone Coordinate")
|
||||||
|
|
||||||
|
-- Speed and altitude.
|
||||||
local Speed=UTILS.KmphToKnots(Task.dcstask.params.speed or self.speedCruise)
|
local Speed=UTILS.KmphToKnots(Task.dcstask.params.speed or self.speedCruise)
|
||||||
local Altitude=Task.dcstask.params.altitude and UTILS.MetersToFeet(Task.dcstask.params.altitude) or nil
|
local Altitude=Task.dcstask.params.altitude and UTILS.MetersToFeet(Task.dcstask.params.altitude) or nil
|
||||||
|
|
||||||
@ -3045,6 +3049,37 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif Task.dcstask.id=="ReconMission" then
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Task recon.
|
||||||
|
---
|
||||||
|
|
||||||
|
-- Target
|
||||||
|
local target=Task.dcstask.params.target --Ops.Target#TARGET
|
||||||
|
Task.dcstask.params.lastindex=1
|
||||||
|
|
||||||
|
local object=target.targets[1] --Ops.Target#TARGET.Object
|
||||||
|
local zone=object.Object --Core.Zone#ZONE
|
||||||
|
|
||||||
|
-- Random coordinate in zone.
|
||||||
|
local Coordinate=zone:GetRandomCoordinate()
|
||||||
|
|
||||||
|
-- Speed and altitude.
|
||||||
|
local Speed=UTILS.KmphToKnots(Task.dcstask.params.speed or self.speedCruise)
|
||||||
|
local Altitude=Task.dcstask.params.altitude and UTILS.MetersToFeet(Task.dcstask.params.altitude) or nil
|
||||||
|
|
||||||
|
--Coordinate:MarkToAll("Next waypoint", ReadOnly,Text)
|
||||||
|
|
||||||
|
-- New waypoint.
|
||||||
|
if self.isFlightgroup then
|
||||||
|
FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
||||||
|
elseif self.isNavygroup then
|
||||||
|
ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation)
|
||||||
|
elseif self.isArmygroup then
|
||||||
|
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- If task is scheduled (not waypoint) set task.
|
-- If task is scheduled (not waypoint) set task.
|
||||||
@ -3135,6 +3170,8 @@ function OPSGROUP:onafterTaskCancel(From, Event, To, Task)
|
|||||||
done=true
|
done=true
|
||||||
elseif Task.dcstask.id=="PatrolZone" then
|
elseif Task.dcstask.id=="PatrolZone" then
|
||||||
done=true
|
done=true
|
||||||
|
elseif Task.dcstask.id=="ReconMission" then
|
||||||
|
done=true
|
||||||
elseif stopflag==1 or (not self:IsAlive()) or self:IsDead() or self:IsStopped() then
|
elseif stopflag==1 or (not self:IsAlive()) or self:IsDead() or self:IsStopped() then
|
||||||
-- Manual call TaskDone if setting flag to one was not successful.
|
-- Manual call TaskDone if setting flag to one was not successful.
|
||||||
done=true
|
done=true
|
||||||
@ -4000,8 +4037,13 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
-- Remove old waypoint.
|
-- Remove old waypoint.
|
||||||
self:RemoveWaypointByID(Waypoint.uid)
|
self:RemoveWaypointByID(Waypoint.uid)
|
||||||
|
|
||||||
|
-- Zone object.
|
||||||
local zone=task.dcstask.params.zone --Core.Zone#ZONE
|
local zone=task.dcstask.params.zone --Core.Zone#ZONE
|
||||||
|
|
||||||
|
-- Random coordinate in zone.
|
||||||
local Coordinate=zone:GetRandomCoordinate()
|
local Coordinate=zone:GetRandomCoordinate()
|
||||||
|
|
||||||
|
-- Speed and altitude.
|
||||||
local Speed=UTILS.KmphToKnots(task.dcstask.params.speed or self.speedCruise)
|
local Speed=UTILS.KmphToKnots(task.dcstask.params.speed or self.speedCruise)
|
||||||
local Altitude=task.dcstask.params.altitude and UTILS.MetersToFeet(task.dcstask.params.altitude) or nil
|
local Altitude=task.dcstask.params.altitude and UTILS.MetersToFeet(task.dcstask.params.altitude) or nil
|
||||||
|
|
||||||
@ -4012,6 +4054,59 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
elseif self.isArmygroup then
|
elseif self.isArmygroup then
|
||||||
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif task and task.dcstask.id=="ReconMission" then
|
||||||
|
|
||||||
|
local target=task.dcstask.params.target --Ops.Target#TARGET
|
||||||
|
|
||||||
|
local n=task.dcstask.params.lastindex+1
|
||||||
|
|
||||||
|
if n<=#target.targets then
|
||||||
|
|
||||||
|
-- Zone object.
|
||||||
|
local object=target.targets[n] --Ops.Target#TARGET.Object
|
||||||
|
local zone=object.Object --Core.Zone#ZONE
|
||||||
|
|
||||||
|
-- Random coordinate in zone.
|
||||||
|
local Coordinate=zone:GetRandomCoordinate()
|
||||||
|
|
||||||
|
-- Speed and altitude.
|
||||||
|
local Speed=UTILS.KmphToKnots(task.dcstask.params.speed or self.speedCruise)
|
||||||
|
local Altitude=task.dcstask.params.altitude and UTILS.MetersToFeet(task.dcstask.params.altitude) or nil
|
||||||
|
|
||||||
|
-- Debug.
|
||||||
|
--Coordinate:MarkToAll("Recon Waypoint n="..tostring(n))
|
||||||
|
|
||||||
|
if self.isFlightgroup then
|
||||||
|
FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
||||||
|
elseif self.isNavygroup then
|
||||||
|
ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation)
|
||||||
|
elseif self.isArmygroup then
|
||||||
|
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Increase counter.
|
||||||
|
task.dcstask.params.lastindex=task.dcstask.params.lastindex+1
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Get waypoint index.
|
||||||
|
local wpindex=self:GetWaypointIndex(Waypoint.uid)
|
||||||
|
|
||||||
|
-- Final waypoint reached?
|
||||||
|
if wpindex==nil or wpindex==#self.waypoints then
|
||||||
|
|
||||||
|
-- Set switch to true.
|
||||||
|
if not self.adinfinitum or #self.waypoints<=1 then
|
||||||
|
self.passedfinalwp=true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Final zone reached ==> task done.
|
||||||
|
self:TaskDone(task)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
|||||||
@ -260,6 +260,17 @@ function TARGET:AddObject(Object)
|
|||||||
self:AddObject(object)
|
self:AddObject(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif Object:IsInstanceOf("SET_ZONE") then
|
||||||
|
|
||||||
|
local set=Object --Core.Set#SET_ZONE
|
||||||
|
|
||||||
|
set:SortByName()
|
||||||
|
|
||||||
|
for index,ZoneName in pairs(set.Index) do
|
||||||
|
local zone=set.Set[ZoneName] --Core.Zone#ZONE
|
||||||
|
self:_AddObject(zone)
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -971,6 +982,12 @@ function TARGET:GetTargetName(Target)
|
|||||||
local coord=Target.Object --Core.Point#COORDINATE
|
local coord=Target.Object --Core.Point#COORDINATE
|
||||||
|
|
||||||
return coord:ToStringMGRS()
|
return coord:ToStringMGRS()
|
||||||
|
|
||||||
|
elseif Target.Type==TARGET.ObjectType.ZONE then
|
||||||
|
|
||||||
|
local Zone=Target.Object --Core.Zone#ZONE
|
||||||
|
|
||||||
|
return Zone:GetName()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user