diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index fb5d28510..ce641b949 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -194,7 +194,7 @@ FLIGHTGROUP.Attribute = { --- FLIGHTGROUP class version. -- @field #string version -FLIGHTGROUP.version="0.6.0" +FLIGHTGROUP.version="0.6.1" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -935,7 +935,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To) -- Distance travelled --- - if self.verbose>=3 and self:IsAlive() then + if self.verbose>=4 and self:IsAlive() then -- Travelled distance since last check. local ds=self.travelds @@ -1025,8 +1025,11 @@ function FLIGHTGROUP:onafterStatus(From, Event, To) self:ClearToLand() end end - - if self:IsAirborne() and self.detectionOn and self.engagedetectedOn then + + --- + -- Engage Detected Targets + --- + if self:IsAirborne() and self.detectionOn and self.engagedetectedOn and not (self.fuellow or self.fuelcritical) then -- Target. local targetgroup=nil --Wrapper.Group#GROUP @@ -1038,16 +1041,20 @@ function FLIGHTGROUP:onafterStatus(From, Event, To) if group and group:IsAlive() then - local targetcoord=group:GetCoordinate() - - local distance=targetcoord:Get2DDistance(self:GetCoordinate()) + -- Get 3D vector of target. + local targetVec3=group:GetVec3() + + -- Distance to target. + local distance=UTILS.VecDist3D(self.position, targetVec3) if distance<=self.engagedetectedRmax and distance0 then - local task=self:GetTaskCurrent() - if task.dcstask.id=="PatrolZone" then - -- For patrol zone, we need to allow the update. + --local task=self:GetTaskCurrent() + local task=self:GetTaskByID(self.taskcurrent) + + if task then + if task.dcstask.id=="PatrolZone" then + -- For patrol zone, we need to allow the update. + else + 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))) + allowed=false + end else - self:E(self.lid.."Update route denied because taskcurrent>0") + -- Now this can happen, if we directly use TaskExecute as the task is not in the task queue and cannot be removed. + self:T(self.lid..string.format("WARNING: before update route taskcurrent=%d>0 but no task?!", self.taskcurrent)) + -- Anyhow, a task is running so we do not allow to update the route! allowed=false end end diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 51782feae..c202ab0ff 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -2096,7 +2096,8 @@ end -- @param #OPSGROUP self -- @return #OPSGROUP.Task Current task or nil. function OPSGROUP:GetTaskCurrent() - return self:GetTaskByID(self.taskcurrent, OPSGROUP.TaskStatus.EXECUTING) + local task=self:GetTaskByID(self.taskcurrent, OPSGROUP.TaskStatus.EXECUTING) + return task end --- Get task by its id. @@ -2893,11 +2894,9 @@ function OPSGROUP:RouteToMission(mission, delay) end end - - elseif mission.type==AUFTRAG.Type.PATROLZONE then - end + -- Formation. local formation=nil if self.isGround and mission.optionFormation then formation=mission.optionFormation