diff --git a/Moose Development/Moose/Ops/Chief.lua b/Moose Development/Moose/Ops/Chief.lua index 4531bbdd8..20c82e8ad 100644 --- a/Moose Development/Moose/Ops/Chief.lua +++ b/Moose Development/Moose/Ops/Chief.lua @@ -1396,7 +1396,7 @@ function CHIEF:CheckTargetQueue() else text=text..string.format(", NO mission yet") end - self:I(self.lid..text) + self:T2(self.lid..text) -- Check that target is alive and not already a mission has been assigned. if isAlive and isThreat and isImportant and not target.mission then @@ -1485,14 +1485,14 @@ function CHIEF:CheckTargetQueue() local mp=_mp --#CHIEF.MissionPerformance -- Debug info. - self:I(self.lid..string.format("Recruiting assets for mission type %s [performance=%d] of target %s", mp.MissionType, mp.Performance, target:GetName())) + self:T2(self.lid..string.format("Recruiting assets for mission type %s [performance=%d] of target %s", mp.MissionType, mp.Performance, target:GetName())) -- Recruit assets. local recruited, assets, legions=self:RecruitAssetsForTarget(target, mp.MissionType, NassetsMin, NassetsMax) if recruited then - self:I(self.lid..string.format("Recruited %d assets for mission type %s [performance=%d] of target %s", #assets, mp.MissionType, mp.Performance, target:GetName())) + self:T(self.lid..string.format("Recruited %d assets for mission type %s [performance=%d] of target %s", #assets, mp.MissionType, mp.Performance, target:GetName())) -- Create a mission. mission=AUFTRAG:NewFromTarget(target, mp.MissionType) @@ -1509,7 +1509,7 @@ function CHIEF:CheckTargetQueue() break end else - self:I(self.lid..string.format("Could NOT recruit assets for mission type %s [performance=%d] of target %s", mp.MissionType, mp.Performance, target:GetName())) + self:T(self.lid..string.format("Could NOT recruit assets for mission type %s [performance=%d] of target %s", mp.MissionType, mp.Performance, target:GetName())) end end end diff --git a/Moose Development/Moose/Ops/Cohort.lua b/Moose Development/Moose/Ops/Cohort.lua index 611f56abd..f23704450 100644 --- a/Moose Development/Moose/Ops/Cohort.lua +++ b/Moose Development/Moose/Ops/Cohort.lua @@ -132,7 +132,7 @@ function COHORT:New(TemplateGroupName, Ngroups, CohortName) -- Mission range depends on if self.category==Group.Category.AIRPLANE then - self:SetMissionRange(150) + self:SetMissionRange(200) elseif self.category==Group.Category.HELICOPTER then self:SetMissionRange(150) elseif self.category==Group.Category.GROUND then diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 54e6e10d4..bfd5b0657 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -2172,7 +2172,7 @@ function FLIGHTGROUP:_CheckGroupDone(delay, waittime) elseif destbase then if self.currbase and self.currbase.AirbaseName==destbase.AirbaseName and self:IsParking() then self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports AND parking at destination airbase ==> Arrived!") - self:__Arrived(0.1) + self:Arrived() else self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports ==> RTB!") self:__RTB(-0.1, destbase) @@ -2818,6 +2818,7 @@ end -- @param #string To To state. function FLIGHTGROUP:onafterFuelLow(From, Event, To) + -- Current min fuel. local fuel=self:GetFuelMin() or 0 -- Debug message. @@ -2829,58 +2830,31 @@ function FLIGHTGROUP:onafterFuelLow(From, Event, To) -- Back to destination or home. local airbase=self.destbase or self.homebase - - local airwing=self:GetAirWing() - if airwing then + if self.fuellowrefuel and self.refueltype then - -- Get closest tanker from airwing that can refuel this flight. - local tanker=airwing:GetTankerForFlight(self) + -- Find nearest tanker within 50 NM. + local tanker=self:FindNearestTanker(50) - if tanker and self.fuellowrefuel then + if tanker then -- Debug message. - self:I(self.lid..string.format("Send to refuel at tanker %s", tanker.flightgroup:GetName())) + self:I(self.lid..string.format("Send to refuel at tanker %s", tanker:GetName())) -- Get a coordinate towards the tanker. - local coordinate=self:GetCoordinate():GetIntermediateCoordinate(tanker.flightgroup:GetCoordinate(), 0.75) + local coordinate=self:GetCoordinate():GetIntermediateCoordinate(tanker:GetCoordinate(), 0.75) - -- Send flight to tanker with refueling task. + -- Trigger refuel even. self:Refuel(coordinate) - else - - if airbase and self.fuellowrtb then - self:RTB(airbase) - --TODO: RTZ - end - - end - - else - - if self.fuellowrefuel and self.refueltype then - - local tanker=self:FindNearestTanker(50) - - if tanker then - - self:I(self.lid..string.format("Send to refuel at tanker %s", tanker:GetName())) - - -- Get a coordinate towards the tanker. - local coordinate=self:GetCoordinate():GetIntermediateCoordinate(tanker:GetCoordinate(), 0.75) - - self:Refuel(coordinate) - - return - end - end - - if airbase and self.fuellowrtb then - self:RTB(airbase) - --TODO: RTZ + return end + end + -- Send back to airbase. + if airbase and self.fuellowrtb then + self:RTB(airbase) + --TODO: RTZ end end diff --git a/Moose Development/Moose/Ops/Intelligence.lua b/Moose Development/Moose/Ops/Intelligence.lua index de5159841..0dbf99004 100644 --- a/Moose Development/Moose/Ops/Intelligence.lua +++ b/Moose Development/Moose/Ops/Intelligence.lua @@ -804,17 +804,29 @@ function INTEL:GetDetectedUnits(Unit, DetectedUnits, RecceDetecting, DetectVisua for DetectionObjectID, Detection in pairs(detectedtargets or {}) do local DetectedObject=Detection.object -- DCS#Object + -- NOTE: Got an object that exists but when trying UNIT:Find() the DCS getName() function failed. ID of the object was 5,000,031 if DetectedObject and DetectedObject:isExist() and DetectedObject.id_<50000000 then - local unit=UNIT:Find(DetectedObject) - - if unit and unit:IsAlive() then + -- Protected call to get the name of the object. + local status,name = pcall( + function() + local name=DetectedObject:getName() + return name + end) - local unitname=unit:GetName() + if status then + + local unit=UNIT:FindByName(name) + + if unit and unit:IsAlive() then + DetectedUnits[name]=unit + RecceDetecting[name]=reccename + self:T(string.format("Unit %s detect by %s", name, reccename)) + end - DetectedUnits[unitname]=unit - RecceDetecting[unitname]=reccename - self:T(string.format("Unit %s detect by %s", unitname, reccename)) + else + -- Warning! + self:T(self.lid..string.format("WARNING: Could not get name of detected object ID=%s! Detected by %s", DetectedObject.id_, reccename)) end end end diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 7ab640d1b..284c4d3bd 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -6008,10 +6008,7 @@ function OPSGROUP:onafterDead(From, Event, To) self.cohort:DelGroup(self.groupname) end else - if self.airwing then - -- Not all assets were destroyed (despawn) ==> Add asset back to airwing. - --self.airwing:AddAsset(self.group, 1) - end + -- Not all assets were destroyed (despawn) ==> Add asset back to legion? end -- Stop in a sec.