This commit is contained in:
Frank
2020-03-20 23:11:29 +01:00
parent 4dd8e53c1c
commit c2257729d5
3 changed files with 141 additions and 90 deletions
+19
View File
@@ -510,6 +510,25 @@ function AIRWING:AddPatrolPointTANKER(Coordinate, Heading, LegLength, Altitude,
return self return self
end end
--- Add a patrol Point for AWACS missions.
-- @param #AIRWING self
-- @param Core.Point#COORDINATE Coordinate Coordinate of the patrol point.
-- @param #number Heading Heading in degrees.
-- @param #number LegLength Length of race-track orbit in NM.
-- @param #number Altitude Orbit altitude in feet.
-- @param #number Speed Orbit speed in knots.
-- @return #AIRWING self
function AIRWING:AddPatrolPointAWACS(Coordinate, Heading, LegLength, Altitude, Speed)
local cappoint=self:NewPatrolPoint(Coordinate, Heading, LegLength, Altitude, Speed)
cappoint.coord:MarkToAll(string.format("AWACS Point alt=%d", cappoint.altitude))
table.insert(self.pointsAWACS, cappoint)
return self
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Start & Status -- Start & Status
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+38 -10
View File
@@ -614,7 +614,7 @@ end
--- Add a *waypoint* task. --- Add a *waypoint* task.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @param #table task DCS task table structure. -- @param #table task DCS task table structure.
-- @param #number waypointindex Number of waypoint. Counting starts at one! -- @param #number waypointindex Number of waypoint. Counting starts at one! Default is the as *next* waypoint.
-- @param #string description Brief text describing the task, e.g. "Attack SAM". -- @param #string description Brief text describing the task, e.g. "Attack SAM".
-- @param #number prio Priority of the task. Number between 1 and 100. Default is 50. -- @param #number prio Priority of the task. Number between 1 and 100. Default is 50.
-- @param #number duration Duration before task is cancelled in seconds counted after task started. Default never. -- @param #number duration Duration before task is cancelled in seconds counted after task started. Default never.
@@ -655,10 +655,26 @@ end
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @param #table task DCS task table structure. -- @param #table task DCS task table structure.
function FLIGHTGROUP:AddTaskEnroute(task) function FLIGHTGROUP:AddTaskEnroute(task)
if not self.taskenroute then if not self.taskenroute then
self.taskenroute={} self.taskenroute={}
end end
-- Check not to add the same task twice!
local gotit=false
for _,Task in pairs(self.taskenroute) do
if Task.id==task.id then
gotit=true
break
end
end
if not gotit then
table.insert(self.taskenroute, task) table.insert(self.taskenroute, task)
end
end end
--- Add an *enroute* task to attack targets in a certain **circular** zone. --- Add an *enroute* task to attack targets in a certain **circular** zone.
@@ -1090,6 +1106,12 @@ end
function FLIGHTGROUP:SetTask(DCSTask) function FLIGHTGROUP:SetTask(DCSTask)
if self:IsAlive() then if self:IsAlive() then
if self.taskcurrent>0 then
local task=self:GetTaskCurrent()
self:RemoveTask(task)
self.taskcurrent=0
end
-- Inject enroute tasks. -- Inject enroute tasks.
if self.taskenroute and #self.taskenroute>0 then if self.taskenroute and #self.taskenroute>0 then
if tostring(DCSTask.id)=="ComboTask" then if tostring(DCSTask.id)=="ComboTask" then
@@ -1366,15 +1388,16 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
local nMissions=self:CountRemainingMissison() local nMissions=self:CountRemainingMissison()
-- Short info. -- Short info.
if self.verbose>0 then
local text=string.format("Status %s [%d/%d]: Tasks=%d (%d,%d) Current=%d. Missions=%s. Waypoint=%d/%d. Detected=%d. Destination=%s, FC=%s", local text=string.format("Status %s [%d/%d]: Tasks=%d (%d,%d) Current=%d. Missions=%s. Waypoint=%d/%d. Detected=%d. Destination=%s, FC=%s",
fsmstate, #self.elements, #self.elements, nTaskTot, nTaskSched, nTaskWP, self.taskcurrent, nMissions, self.currentwp or 0, self.waypoints and #self.waypoints or 0, fsmstate, #self.elements, #self.elements, nTaskTot, nTaskSched, nTaskWP, self.taskcurrent, nMissions, self.currentwp or 0, self.waypoints and #self.waypoints or 0,
self.detectedunits:Count(), self.destbase and self.destbase:GetName() or "unknown", self.flightcontrol and self.flightcontrol.airbasename or "none") self.detectedunits:Count(), self.destbase and self.destbase:GetName() or "unknown", self.flightcontrol and self.flightcontrol.airbasename or "none")
if self.verbose>0 then
self:I(self.lid..text) self:I(self.lid..text)
end end
-- Element status. -- Element status.
text="Elements:" if self.verbose>1 then
local text="Elements:"
for i,_element in pairs(self.elements) do for i,_element in pairs(self.elements) do
local element=_element --#FLIGHTGROUP.Element local element=_element --#FLIGHTGROUP.Element
@@ -1402,7 +1425,6 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
if #self.elements==0 then if #self.elements==0 then
text=text.." none!" text=text.." none!"
end end
if self.verbose>1 then
self:I(self.lid..text) self:I(self.lid..text)
end end
@@ -1411,7 +1433,8 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
--- ---
-- Task queue. -- Task queue.
text=string.format("Tasks #%d", #self.taskqueue) if #self.taskqueue>0 and self.verbose>1 then
local text=string.format("Tasks #%d", #self.taskqueue)
for i,_task in pairs(self.taskqueue) do for i,_task in pairs(self.taskqueue) do
local task=_task --#FLIGHTGROUP.Task local task=_task --#FLIGHTGROUP.Task
local name=task.description local name=task.description
@@ -1438,7 +1461,6 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
text=text..string.format("\n[%d] %s (%s): status=%s, waypoint=%d, started=%s, duration=%d, stopflag=%d", i, taskid, name, status, task.waypoint, started, duration, task.stopflag:Get()) text=text..string.format("\n[%d] %s (%s): status=%s, waypoint=%d, started=%s, duration=%d, stopflag=%d", i, taskid, name, status, task.waypoint, started, duration, task.stopflag:Get())
end end
end end
if #self.taskqueue>0 and self.verbose>1 then
self:I(self.lid..text) self:I(self.lid..text)
end end
@@ -1447,6 +1469,7 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
--- ---
-- Current mission name. -- Current mission name.
if self.verbose>0 then
local Mission=self:GetMissionByID(self.currentmission) local Mission=self:GetMissionByID(self.currentmission)
-- Current status. -- Current status.
@@ -1458,7 +1481,6 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
text=text..string.format("\n[%d] %s (%s) status=%s (%s), Time=%s-%s, prio=%d targets=%d", text=text..string.format("\n[%d] %s (%s) status=%s (%s), Time=%s-%s, prio=%d targets=%d",
i, tostring(mission.name), mission.type, mission:GetFlightStatus(self), tostring(mission.status), Cstart, Cstop, mission.prio, mission:CountMissionTargets()) i, tostring(mission.name), mission.type, mission:GetFlightStatus(self), tostring(mission.status), Cstart, Cstop, mission.prio, mission:CountMissionTargets())
end end
if self.verbose>0 then
self:I(self.lid..text) self:I(self.lid..text)
end end
@@ -2544,7 +2566,8 @@ function FLIGHTGROUP:_CheckFlightDone(delay)
self:I(self.lid..string.format("Passed Final WP but still have current Tasks (%s) or Missions (%s) left to do", tostring(self.taskcurrent), tostring(self.currentmission))) self:I(self.lid..string.format("Passed Final WP but still have current Tasks (%s) or Missions (%s) left to do", tostring(self.taskcurrent), tostring(self.currentmission)))
end end
else else
self:I(self.lid.."Did NOT pass the final waypoint yet") self:I(self.lid.."Did NOT pass the final waypoint yet ==> update route")
self:UpdateRoute()
end end
end end
end end
@@ -3357,9 +3380,10 @@ function FLIGHTGROUP:onafterTaskDone(From, Event, To, Task)
-- Check if this task was the task of the current mission ==> Mission Done! -- Check if this task was the task of the current mission ==> Mission Done!
local Mission=self:GetMissionByTaskID(Task.id) local Mission=self:GetMissionByTaskID(Task.id)
if Mission then
local status=Mission:GetFlightStatus(self) local status=Mission:GetFlightStatus(self)
if Mission then
if status~=AUFTRAG.FlightStatus.PAUSED then if status~=AUFTRAG.FlightStatus.PAUSED then
env.info("FF Task Done ==> Mission Done!") env.info("FF Task Done ==> Mission Done!")
self:MissionDone(Mission) self:MissionDone(Mission)
@@ -3496,7 +3520,11 @@ end
-- @param #string To To state. -- @param #string To To state.
function FLIGHTGROUP:onafterUnpauseMission(From, Event, To) function FLIGHTGROUP:onafterUnpauseMission(From, Event, To)
self:MissionStart(self.missionpaused) self:I(self.lid..string.format("Unpausing mission"))
local mission=self:GetMissionByID(self.missionpaused.auftragsnummer)
self:MissionStart(mission)
self.missionpaused=nil self.missionpaused=nil
+4
View File
@@ -466,6 +466,8 @@ function UNIT:IsTanker()
local system=nil local system=nil
if tanker then
local Desc=self:GetDesc() local Desc=self:GetDesc()
if Desc and Desc.tankerType then if Desc and Desc.tankerType then
system=Desc.tankerType system=Desc.tankerType
@@ -485,6 +487,8 @@ function UNIT:IsTanker()
system=1 --probe system=1 --probe
end end
end
env.info(string.format("unit %s type=%s: tanker=%s system=%s", tostring(self.UnitName), tostring(typename), tostring(tanker), tostring(system))) env.info(string.format("unit %s type=%s: tanker=%s system=%s", tostring(self.UnitName), tostring(typename), tostring(tanker), tostring(system)))
return tanker, system return tanker, system