diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 9f0d780bd..07f15ad9d 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -2561,6 +2561,40 @@ function CTLD:_ListCratesNearby( _group, _unit) return self end +-- (Internal) Function to find and Remove nearby crates. +-- @param #CTLD self +-- @param Wrapper.Group#GROUP Group +-- @param Wrapper.Unit#UNIT Unit +-- @return #CTLD self +function CTLD:_RemoveCratesNearby( _group, _unit) + self:T(self.lid .. " _RemoveCratesNearby") + local finddist = self.CrateDistance or 35 + local crates,number = self:_FindCratesNearby(_group,_unit, finddist,true) -- #table + if number > 0 then + local text = REPORT:New("Removing Crates Found Nearby:") + text:Add("------------------------------------------------------------") + for _,_entry in pairs (crates) do + local entry = _entry -- #CTLD_CARGO + local name = entry:GetName() --#string + local dropped = entry:WasDropped() + if dropped then + text:Add(string.format("Crate for %s, %dkg removed",name, entry.PerCrateMass)) + else + text:Add(string.format("Crate for %s, %dkg removed",name, entry.PerCrateMass)) + end + entry:GetPositionable():Destroy(false) + end + if text:GetCount() == 1 then + text:Add(" N O N E") + end + text:Add("------------------------------------------------------------") + self:_SendMessage(text:Text(), 30, true, _group) + else + self:_SendMessage(string.format("No (loadable) crates within %d meters!",finddist), 10, false, _group) + end + return self +end + --- (Internal) Return distance in meters between two coordinates. -- @param #CTLD self -- @param Core.Point#COORDINATE _point1 Coordinate one @@ -3672,6 +3706,7 @@ function CTLD:_RefreshF10Menus() end end listmenu = MENU_GROUP_COMMAND:New(_group,"List crates nearby",topcrates, self._ListCratesNearby, self, _group, _unit) + listmenu = MENU_GROUP_COMMAND:New(_group,"Remove crates nearby",topcrates, self._RemoveCratesNearby, self, _group, _unit) local unloadmenu = MENU_GROUP_COMMAND:New(_group,"Drop crates",topcrates, self._UnloadCrates, self, _group, _unit) if not self.nobuildmenu then local buildmenu = MENU_GROUP_COMMAND:New(_group,"Build crates",topcrates, self._BuildCrates, self, _group, _unit) diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index f0ced1ff5..d215a0c7f 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -3474,10 +3474,9 @@ function OPSGROUP:RemoveWaypoint(wpindex) -- Could be that the waypoint we are currently moving to was the LAST waypoint. Then we now passed the final waypoint. if (self.adinfinitum or istemp) then - self:_PassedFinalWaypoint(false, "Removed PASSED temporary waypoint ") - end - - + self:_PassedFinalWaypoint(false, "Removed PASSED temporary waypoint") + end + end end @@ -5805,6 +5804,27 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission) end end + if self.legion and self.legionReturn==false and self.waypoints and #self.waypoints==1 then + --- + -- This is the case where a group was send on a mission (which is over now), has no addional + -- waypoints or tasks and should NOT return to its legion. + -- We create a new waypoint at the current position and let it hold here. + --- + + local Coordinate=self:GetCoordinate() + + if self.isArmygroup then + ARMYGROUP.AddWaypoint(self, Coordinate, 0, nil, nil, false) + elseif self.isNavygroup then + NAVYGROUP.AddWaypoint(self,Coordinate, 0, nil, nil, false) + end + + -- Remove original waypoint. + self:RemoveWaypoint(1) + + self:_PassedFinalWaypoint(true, "Passed final waypoint as group is done with mission but should NOT return to its legion") + end + -- Check if group is done. self:_CheckGroupDone(delay)