diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index d938256e3..60e2c09bd 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -628,8 +628,17 @@ function AIRWING:onafterStatus(From, Event, To) local status=asset.flightgroup:GetState() local fuelmin=asset.flightgroup:GetFuelMin() local fuellow=asset.flightgroup:IsFuelLow() + local fuelcri=asset.flightgroup:IsFuelCritical() - text=text..string.format("%s fuel=%d (low=%s)", status, fuelmin, tostring(fuellow)) + text=text..string.format("%s fuel=%d", status, fuelmin) + if fuelcri then + text=text.." (critical!)" + elseif fuellow then + text=text.." (low)" + end + + local lifept, lifept0=asset.flightgroup:GetLifePoints() + text=text..string.format(" life=%d/%d", lifept, lifept0) else text=text.."N/A" end diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index 1d29fab04..d6713aab9 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -1064,10 +1064,12 @@ function AUFTRAG:onafterStatus(From, Event, To) self:E(self.lid..string.format("ERROR: FSM state %s != %s mission status!", fsmstate, self.status)) end - for _,_flightdata in pairs(self.flightdata) do + local text="Flight data:" + for groupname,_flightdata in pairs(self.flightdata) do local flightdata=_flightdata --#AUFTRAG.FlightData - string.format("%s", flightdata.status) + text=text..string.format("\n- %s: status mission=%s flightgroup=%s", groupname, flightdata.status, flightdata.flightgroup and flightdata.flightgroup:GetState() or "N/A") end + self:I(self.lid..text) -- Check if mission is OVER (done or cancelled). if self:IsOver() then @@ -1158,7 +1160,6 @@ function AUFTRAG:SetFlightStatus(flightgroup, status) flightdata.status=status else self:E(self.lid.."WARNING: Could not SET flight data for flight group. Setting status to DONE.") - flightdata.status=AUFTRAG.FlightStatus.DONE end end @@ -1183,7 +1184,7 @@ function AUFTRAG:GetFlightStatus(flightgroup) if flightdata then return flightdata.status else - self:E(self.lid.."WARNING: Could not get flight data for flight group. Returning status DONE.") + self:E(self.lid.."WARNING: Could not GET flightdata for flight group. Returning status DONE.") return AUFTRAG.FlightStatus.DONE end end @@ -1490,21 +1491,24 @@ end -- @param #string To To state. function AUFTRAG:onafterRepeat(From, Event, To) + -- Set mission status to PLANNED. self.status=AUFTRAG.Status.PLANNED - self:I(self.lid..string.format("New mission status=%s (on Repeat)", self.status)) + + self:I(self.lid..string.format("New mission status=%s (on Repeat)", self.status)) -- Increase repeat counter. self.missionRepeated=self.missionRepeated+1 if self.wingcommander then - + elseif self.airwing then - - + -- Already at the airwing ==> Queued() + self:Queued(self.airwing) else end + -- No mission assets. self.assets={} diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 87b6e4903..bb5622b40 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -2325,18 +2325,19 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n) -- Is transition allowed? We assume yes until proven otherwise. local allowed=true + local trepeat=nil - if self.group and self.group:IsAlive() and (self:IsAirborne() or self:IsWaiting()) then + if self:IsAlive() and (self:IsAirborne() or self:IsWaiting() or self:IsInbound() or self:IsHolding()) then -- Alive & Airborne ==> Update route possible. - self:T3(self.lid.."Update route possible. Group is ALIVE and AIRBORNE") - elseif self:IsDead() then + self:T3(self.lid.."Update route possible. Group is ALIVE and AIRBORNE or WAITING or INBOUND or HOLDING") + elseif self:IsDead() then -- Group is dead! No more updates. self:E(self.lid.."Update route denied. Group is DEAD!") allowed=false else -- Not airborne yet. Try again in 1 sec. - self:T3(self.lid.."FF update route denied ==> checking back in 1 sec") - self:__UpdateRoute(-1, n) + self:T3(self.lid.."FF update route denied ==> checking back in 5 sec") + trepeat=-5 allowed=false end @@ -2353,7 +2354,7 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n) local N=n or self.currentwp+1 if not N or N<1 then self:E(self.lid.."FF update route denied because N=nil or N<1") - self:__UpdateRoute(-1, n) + trepeat=-5 allowed=false end @@ -2368,6 +2369,13 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n) --allowed=false end + -- Debug info. + self:T2(self.lid..string.format("Onbefore Updateroute allowed=%s state=%s repeat in %s", tostring(allowed), self:GetState(), tostring(trepeat))) + + if trepeat then + self:__UpdateRoute(trepeat, n) + end + return allowed end @@ -2562,7 +2570,7 @@ function FLIGHTGROUP:_CheckFlightDone(delay) end else self:I(self.lid.."Did NOT pass the final waypoint yet ==> update route") - self:UpdateRoute() + self:__UpdateRoute(-1) end end end @@ -5102,6 +5110,16 @@ function FLIGHTGROUP:GetCoalition() return self.group:GetCoalition() end +--- Returns the absolute (average) life points of the group. +-- @param #FLIGHTGROUP self +-- @return #number Life points. If group contains more than one element, the average is given. +-- @return #number Initial life points. +function FLIGHTGROUP:GetLifePoints() + if self.group then + return self.group:GetLife(), self.group:GetLife0() + end +end + --- Returns the parking spot of the element. -- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP.Element element Element of the flight group. diff --git a/Moose Development/Moose/Ops/Squadron.lua b/Moose Development/Moose/Ops/Squadron.lua index 994945f0f..210c33474 100644 --- a/Moose Development/Moose/Ops/Squadron.lua +++ b/Moose Development/Moose/Ops/Squadron.lua @@ -116,8 +116,8 @@ function SQUADRON:New(TemplateGroupName, Ngroups, SquadronName) self.attribute=self.templategroup:GetAttribute() - _,self.refuelSystem=self.templategroup:GetUnit(1):IsRefuelable() - _,self.tankerSystem=self.templategroup:GetUnit(1):IsTanker() + self.refuelSystem=select(2, self.templategroup:GetUnit(1):IsRefuelable()) + self.tankerSystem=select(2, self.templategroup:GetUnit(1):IsTanker()) -- Start State. diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index d4633fcc9..4fa1edbd3 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -312,7 +312,6 @@ function CONTROLLABLE:ClearTasks() if DCSControllable then local Controller = self:_GetController() - env.info("FF clearing tasks!") Controller:resetTask() return self end @@ -627,7 +626,6 @@ function CONTROLLABLE:StartUncontrolled(delay) if delay and delay>0 then SCHEDULER:New(nil, CONTROLLABLE.StartUncontrolled, {self}, delay) else - env.info("FF staring controllable") self:SetCommand({id='Start', params={}}) end return self diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 0e2204348..bac9cd605 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -424,9 +424,9 @@ function UNIT:GetRange() local Desc = self:GetDesc() if Desc then - local Range = Desc.range --This is in nautical miles for some reason. But should check again! + local Range = Desc.range --This is in kilometers (not meters) for some reason. But should check again! if Range then - Range=UTILS.NMToMeters(Range) + Range=Range*1000 -- convert to meters. else Range=10000000 --10.000 km if no range end @@ -475,6 +475,7 @@ function UNIT:IsTanker() local typename=self:GetTypeName() + -- Some hard coded data as this is not in the descriptors... if typename=="IL-78M" then system=1 --probe elseif typename=="KC130" then @@ -488,8 +489,6 @@ function UNIT:IsTanker() end end - - env.info(string.format("unit %s type=%s: tanker=%s system=%s", tostring(self.UnitName), tostring(typename), tostring(tanker), tostring(system))) return tanker, system end