mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
- Fixed several bugs
This commit is contained in:
parent
902c001aa4
commit
c823a68616
@ -816,7 +816,7 @@ function ARMYGROUP:onafterSpawned(From, Event, To)
|
|||||||
-- Update route.
|
-- Update route.
|
||||||
if #self.waypoints>1 then
|
if #self.waypoints>1 then
|
||||||
self:T(self.lid.."Got waypoints on spawn ==> Cruise in -0.1 sec!")
|
self:T(self.lid.."Got waypoints on spawn ==> Cruise in -0.1 sec!")
|
||||||
self:__Cruise(-0.1, nil, self.option.Formation)
|
self:__Cruise(-1, nil, self.option.Formation)
|
||||||
else
|
else
|
||||||
self:T(self.lid.."No waypoints on spawn ==> Full Stop!")
|
self:T(self.lid.."No waypoints on spawn ==> Full Stop!")
|
||||||
self:FullStop()
|
self:FullStop()
|
||||||
@ -910,7 +910,7 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
wp.action=ENUMS.Formation.Vehicle.OffRoad
|
wp.action=ENUMS.Formation.Vehicle.OffRoad
|
||||||
|
|
||||||
-- Add "On Road" waypoint in between.
|
-- Add "On Road" waypoint in between.
|
||||||
local wproad=wp.roadcoord:WaypointGround(wp.speed, ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
local wproad=wp.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
-- Insert road waypoint.
|
-- Insert road waypoint.
|
||||||
table.insert(waypoints, wproad)
|
table.insert(waypoints, wproad)
|
||||||
@ -946,10 +946,12 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
|
|
||||||
|
|
||||||
-- Debug output.
|
-- Debug output.
|
||||||
if self.verbose>=5 then
|
if self.verbose>=0 then
|
||||||
for i,_wp in pairs(waypoints) do
|
for i,_wp in pairs(waypoints) do
|
||||||
local wp=_wp
|
local wp=_wp --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
local text=string.format("WP #%d UID=%d type=%s: Speed=%d m/s, alt=%d m, Action=%s", i, wp.uid and wp.uid or -1, wp.type, wp.speed, wp.alt, wp.action)
|
local text=string.format("WP #%d UID=%d type=%s: Speed=%d m/s, alt=%d m, Action=%s", i, wp.uid and wp.uid or -1, wp.type, wp.speed, wp.alt, wp.action)
|
||||||
|
local coord=COORDINATE:NewFromWaypoint(wp):MarkToAll(text)
|
||||||
|
--wp.coordinate:MarkToAll(text)
|
||||||
self:T(text)
|
self:T(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1487,7 +1489,7 @@ function ARMYGROUP:onafterCruise(From, Event, To, Speed, Formation)
|
|||||||
self.Twaiting=nil
|
self.Twaiting=nil
|
||||||
self.dTwait=nil
|
self.dTwait=nil
|
||||||
|
|
||||||
self:__UpdateRoute(-1, nil, nil, Speed, Formation)
|
self:__UpdateRoute(-0.1, nil, nil, Speed, Formation)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1760,7 +1760,7 @@ end
|
|||||||
|
|
||||||
--- **[GROUND, NAVAL]** Create an ON GUARD mission.
|
--- **[GROUND, NAVAL]** Create an ON GUARD mission.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param Core.Point#COORDINATE Coordinate Coordinate, were to be on guard.
|
-- @param Core.Point#COORDINATE Coordinate Coordinate, where to stand guard.
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:NewONGUARD(Coordinate)
|
function AUFTRAG:NewONGUARD(Coordinate)
|
||||||
|
|
||||||
|
|||||||
@ -2161,7 +2161,9 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM
|
|||||||
elseif MissionType==AUFTRAG.Type.CAS then
|
elseif MissionType==AUFTRAG.Type.CAS then
|
||||||
|
|
||||||
-- Create Patrol zone mission.
|
-- Create Patrol zone mission.
|
||||||
local mission=AUFTRAG:NewCAS(StratZone.opszone.zone, 7000)
|
--local mission=AUFTRAG:NewCAS(StratZone.opszone.zone, 7000)
|
||||||
|
local mission=AUFTRAG:NewPATROLZONE(StratZone.opszone.zone, 250, 7000)
|
||||||
|
mission:SetEngageDetected(25, TargetTypes,EngageZoneSet,NoEngageZoneSet)
|
||||||
|
|
||||||
-- Add assets to mission.
|
-- Add assets to mission.
|
||||||
for _,asset in pairs(assets) do
|
for _,asset in pairs(assets) do
|
||||||
|
|||||||
@ -2155,7 +2155,7 @@ function FLIGHTGROUP:_CheckGroupDone(delay, waittime)
|
|||||||
---
|
---
|
||||||
|
|
||||||
-- Got current mission or task?
|
-- Got current mission or task?
|
||||||
if self.currentmission==nil and self.taskcurrent==0 and self.cargoTransport==nil then
|
if self.currentmission==nil and self.taskcurrent==0 and (self.cargoTransport==nil or self.cargoTransport:GetCarrierTransportStatus(self)==OPSTRANSPORT.Status.DELIVERED) then
|
||||||
|
|
||||||
-- Number of remaining tasks/missions?
|
-- Number of remaining tasks/missions?
|
||||||
if nTasks==0 and nMissions==0 and nTransports==0 then
|
if nTasks==0 and nMissions==0 and nTransports==0 then
|
||||||
|
|||||||
@ -1008,7 +1008,7 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Depth)
|
|||||||
wp.speed=UTILS.KnotsToMps(Speed)
|
wp.speed=UTILS.KnotsToMps(Speed)
|
||||||
else
|
else
|
||||||
-- Take default waypoint speed. But make sure speed>0 if patrol ad infinitum.
|
-- Take default waypoint speed. But make sure speed>0 if patrol ad infinitum.
|
||||||
if self.adinfinitum and wp.speed<0.1 then
|
if wp.speed<0.1 then --self.adinfinitum and
|
||||||
wp.speed=UTILS.KmphToMps(self.speedCruise)
|
wp.speed=UTILS.KmphToMps(self.speedCruise)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1275,7 +1275,7 @@ function NAVYGROUP:onafterCruise(From, Event, To, Speed)
|
|||||||
-- No set depth.
|
-- No set depth.
|
||||||
self.depth=nil
|
self.depth=nil
|
||||||
|
|
||||||
self:__UpdateRoute(-1, nil, nil, Speed)
|
self:__UpdateRoute(-0.1, nil, nil, Speed)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -460,8 +460,7 @@ OPSGROUP.CargoStatus={
|
|||||||
-- @type OPSGROUP.CargoGroup
|
-- @type OPSGROUP.CargoGroup
|
||||||
-- @field #OPSGROUP opsgroup The cargo opsgroup.
|
-- @field #OPSGROUP opsgroup The cargo opsgroup.
|
||||||
-- @field #boolean delivered If `true`, group was delivered.
|
-- @field #boolean delivered If `true`, group was delivered.
|
||||||
-- @field #OPSGROUP disembarkCarrierGroup Carrier group where the cargo group is directly loaded to.
|
-- @field #boolean disembarkActivation If `true`, group is activated. If `false`, group is late activated.
|
||||||
-- @field #OPSGROUP disembarkCarrierElement Carrier element to which the cargo group is directly loaded to.
|
|
||||||
-- @field #string status Status of the cargo group. Not used yet.
|
-- @field #string status Status of the cargo group. Not used yet.
|
||||||
|
|
||||||
--- OpsGroup version.
|
--- OpsGroup version.
|
||||||
@ -533,7 +532,6 @@ function OPSGROUP:New(group)
|
|||||||
self.isTrain=true
|
self.isTrain=true
|
||||||
elseif self.category==Group.Category.SHIP then
|
elseif self.category==Group.Category.SHIP then
|
||||||
self.isNavygroup=true
|
self.isNavygroup=true
|
||||||
-- TODO submarine
|
|
||||||
elseif self.category==Group.Category.AIRPLANE then
|
elseif self.category==Group.Category.AIRPLANE then
|
||||||
self.isFlightgroup=true
|
self.isFlightgroup=true
|
||||||
elseif self.category==Group.Category.HELICOPTER then
|
elseif self.category==Group.Category.HELICOPTER then
|
||||||
@ -3663,6 +3661,13 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
-- Just stay put.
|
-- Just stay put.
|
||||||
--TODO: Change ALARM STATE
|
--TODO: Change ALARM STATE
|
||||||
|
|
||||||
|
if self:IsArmygroup() or self:IsNavygroup() then
|
||||||
|
-- Especially NAVYGROUP needs a full stop as patrol ad infinitum
|
||||||
|
self:FullStop()
|
||||||
|
else
|
||||||
|
-- FLIGHTGROUP not implemented (intended!) for this AUFTRAG type.
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- If task is scheduled (not waypoint) set task.
|
-- If task is scheduled (not waypoint) set task.
|
||||||
@ -3874,10 +3879,17 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task)
|
|||||||
else
|
else
|
||||||
|
|
||||||
if Task.description=="Engage_Target" then
|
if Task.description=="Engage_Target" then
|
||||||
|
self:T(self.lid.."Taske DONE Engage_Target ==> Cruise")
|
||||||
self:Disengage()
|
self:Disengage()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Task.description==AUFTRAG.SpecialTask.ONGUARD then
|
||||||
|
self:T(self.lid.."Taske DONE OnGuard ==> Cruise")
|
||||||
|
self:Cruise()
|
||||||
|
end
|
||||||
|
|
||||||
if Task.description=="Task_Land_At" then
|
if Task.description=="Task_Land_At" then
|
||||||
|
self:T(self.lid.."Taske DONE Task_Land_At ==> Wait")
|
||||||
self:Wait(20, 100)
|
self:Wait(20, 100)
|
||||||
else
|
else
|
||||||
self:T(self.lid.."Task Done but NO mission found ==> _CheckGroupDone in 0 sec")
|
self:T(self.lid.."Task Done but NO mission found ==> _CheckGroupDone in 0 sec")
|
||||||
@ -3997,7 +4009,7 @@ function OPSGROUP:CountRemainingTransports()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- In case we directly set the cargo transport (not in queue).
|
-- In case we directly set the cargo transport (not in queue).
|
||||||
if N==0 and self.cargoTransport then
|
if N==0 and self.cargoTransport and self.cargoTransport:GetState()~=OPSTRANSPORT.Status.DELIVERED then
|
||||||
N=1
|
N=1
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -4916,11 +4928,20 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
-- Final waypoint reached?
|
-- Final waypoint reached?
|
||||||
if wpindex==nil or wpindex==#self.waypoints then
|
if wpindex==nil or wpindex==#self.waypoints then
|
||||||
|
|
||||||
-- Ad infinitum?
|
-- Ad infinitum and not mission waypoint?
|
||||||
if self.adinfinitum then
|
if self.adinfinitum then
|
||||||
|
---
|
||||||
|
-- Ad Infinitum
|
||||||
|
---
|
||||||
|
|
||||||
|
if Waypoint.missionUID then
|
||||||
|
---
|
||||||
|
-- Last waypoint was a mission waypoint ==> Do nothing (when mission is over, it should take care of this)
|
||||||
|
---
|
||||||
|
else
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Ad Infinitum and last waypoint reached.
|
-- Last waypoint reached.
|
||||||
---
|
---
|
||||||
|
|
||||||
if #self.waypoints<=1 then
|
if #self.waypoints<=1 then
|
||||||
@ -4941,7 +4962,12 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
self:Detour(Coordinate, self.speedCruise, nil, true)
|
self:Detour(Coordinate, self.speedCruise, nil, true)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
|
---
|
||||||
|
-- NOT Ad Infinitum
|
||||||
|
---
|
||||||
|
|
||||||
-- Final waypoint reached.
|
-- Final waypoint reached.
|
||||||
self:_PassedFinalWaypoint(true, "PassingWaypoint: wpindex=#self.waypoints (or wpindex=nil)")
|
self:_PassedFinalWaypoint(true, "PassingWaypoint: wpindex=#self.waypoints (or wpindex=nil)")
|
||||||
end
|
end
|
||||||
@ -6183,6 +6209,14 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.cargoTransport and self.cargoTransport:GetCarrierTransportStatus(self)==OPSTRANSPORT.Status.DELIVERED then
|
||||||
|
-- Remove transport from queue.
|
||||||
|
self:DelOpsTransport(self.cargoTransport)
|
||||||
|
-- No current transport any more.
|
||||||
|
self.cargoTransport=nil
|
||||||
|
self.cargoTZC=nil
|
||||||
|
end
|
||||||
|
|
||||||
-- Check if there is anything in the queue.
|
-- Check if there is anything in the queue.
|
||||||
if not self.cargoTransport and not self:IsOnMission() then
|
if not self.cargoTransport and not self:IsOnMission() then
|
||||||
self.cargoTransport=self:_GetNextCargoTransport()
|
self.cargoTransport=self:_GetNextCargoTransport()
|
||||||
@ -6311,7 +6345,7 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
-- Unloading finished ==> pickup next batch or call it a day.
|
-- Unloading finished ==> pickup next batch or call it a day.
|
||||||
if delivered then
|
if delivered then
|
||||||
self:T(self.lid.."Unloading finished ==> UnloadingDone")
|
self:T(self.lid.."Unloading finished ==> UnloadingDone")
|
||||||
self:__UnloadingDone(10)
|
self:UnloadingDone()
|
||||||
else
|
else
|
||||||
self:Unloading()
|
self:Unloading()
|
||||||
end
|
end
|
||||||
@ -6614,11 +6648,14 @@ function OPSGROUP:DelOpsTransport(CargoTransport)
|
|||||||
local transport=self.cargoqueue[i] --Ops.OpsTransport#OPSTRANSPORT
|
local transport=self.cargoqueue[i] --Ops.OpsTransport#OPSTRANSPORT
|
||||||
if transport.uid==CargoTransport.uid then
|
if transport.uid==CargoTransport.uid then
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Removing transport UID=%d", transport.uid))
|
||||||
|
|
||||||
-- Remove from queue.
|
-- Remove from queue.
|
||||||
table.remove(self.cargoqueue, i)
|
table.remove(self.cargoqueue, i)
|
||||||
|
|
||||||
-- Remove carrier from ops transport.
|
-- Remove carrier from ops transport.
|
||||||
CargoTransport:_DelCarrier(self)
|
CargoTransport:_DelCarrier(self, 1)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -6627,6 +6664,22 @@ function OPSGROUP:DelOpsTransport(CargoTransport)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get cargo transport assignment from the cargo queue by its unique ID.
|
||||||
|
-- @param #OPSGROUP self
|
||||||
|
-- @param #number uid Unique ID of the transport
|
||||||
|
-- @return Ops.OpsTransport#OPSTRANSPORT Transport.
|
||||||
|
function OPSGROUP:GetOpsTransportByUID(uid)
|
||||||
|
|
||||||
|
for i=#self.cargoqueue,1,-1 do
|
||||||
|
local transport=self.cargoqueue[i] --Ops.OpsTransport#OPSTRANSPORT
|
||||||
|
if transport.uid==uid then
|
||||||
|
return transport
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get total weight of the group including cargo. Optionally, the total weight of a specific unit can be requested.
|
--- Get total weight of the group including cargo. Optionally, the total weight of a specific unit can be requested.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
@ -7110,7 +7163,7 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- NAVYGROUP
|
-- NAVYGROUP
|
||||||
local waypoint=NAVYGROUP.AddWaypoint(self, Coordinate, nil, uid) ; waypoint.detour=1
|
local waypoint=NAVYGROUP.AddWaypoint(self, Coordinate, nil, uid, self.altitudeCruise) ; waypoint.detour=1
|
||||||
|
|
||||||
-- Give cruise command.
|
-- Give cruise command.
|
||||||
self:__Cruise(-2)
|
self:__Cruise(-2)
|
||||||
@ -7398,8 +7451,15 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
local surfacetypes=nil
|
||||||
|
if self:IsArmygroup() then
|
||||||
|
surfacetypes={land.SurfaceType.LAND}
|
||||||
|
elseif self:IsNavygroup() then
|
||||||
|
surfacetypes={land.SurfaceType.WATER}
|
||||||
|
end
|
||||||
|
|
||||||
-- Coord where the carrier goes to unload.
|
-- Coord where the carrier goes to unload.
|
||||||
local Coordinate=Zone:GetRandomCoordinate() --Core.Point#COORDINATE
|
local Coordinate=Zone:GetRandomCoordinate(nil, nil, surfacetypes) --Core.Point#COORDINATE
|
||||||
|
|
||||||
-- Add waypoint.
|
-- Add waypoint.
|
||||||
if self:IsFlightgroup() then
|
if self:IsFlightgroup() then
|
||||||
@ -7452,6 +7512,14 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
|||||||
-- Formation used for transporting.
|
-- Formation used for transporting.
|
||||||
local Formation=self.cargoTransport:_GetFormationTransport(self.cargoTZC)
|
local Formation=self.cargoTransport:_GetFormationTransport(self.cargoTZC)
|
||||||
|
|
||||||
|
--[[
|
||||||
|
local coordinate=self:GetCoordinate()
|
||||||
|
local pathonroad=coordinate:GetPathOnRoad(Coordinate, false, false, true)
|
||||||
|
if pathonroad then
|
||||||
|
env.info("FF got path on road")
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
if path then
|
if path then
|
||||||
-- Loop over coordinates.
|
-- Loop over coordinates.
|
||||||
for i,coordinate in pairs(path) do
|
for i,coordinate in pairs(path) do
|
||||||
@ -7483,7 +7551,7 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- NAVYGROUP
|
-- NAVYGROUP
|
||||||
local waypoint=NAVYGROUP.AddWaypoint(self, Coordinate, nil, uid) ; waypoint.detour=1
|
local waypoint=NAVYGROUP.AddWaypoint(self, Coordinate, nil, uid, self.altitudeCruise) ; waypoint.detour=1
|
||||||
|
|
||||||
-- Give cruise command.
|
-- Give cruise command.
|
||||||
self:Cruise()
|
self:Cruise()
|
||||||
@ -7592,19 +7660,33 @@ function OPSGROUP:onafterUnloading(From, Event, To)
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
local element=cargo.opsgroup:_GetMyCarrierElement()
|
||||||
|
|
||||||
|
if element then
|
||||||
|
|
||||||
-- Get random point in disembark zone.
|
-- Get random point in disembark zone.
|
||||||
local zoneCarrier=self:GetElementZoneUnload(cargo.opsgroup:_GetMyCarrierElement().name)
|
local zoneCarrier=self:GetElementZoneUnload(element.name)
|
||||||
|
|
||||||
-- Random coordinate/heading in the zone.
|
-- Random coordinate/heading in the zone.
|
||||||
Coordinate=zoneCarrier:GetRandomCoordinate()
|
Coordinate=zoneCarrier:GetRandomCoordinate()
|
||||||
|
|
||||||
|
else
|
||||||
|
env.info(string.format("FF ERROR carrier element nil!"))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Random heading of the group.
|
-- Random heading of the group.
|
||||||
local Heading=math.random(0,359)
|
local Heading=math.random(0,359)
|
||||||
|
|
||||||
|
-- Activation on/off.
|
||||||
|
local activation=self.cargoTransport:GetDisembarkActivation(self.cargoTZC)
|
||||||
|
if cargo.disembarkActivation~=nil then
|
||||||
|
activation=cargo.disembarkActivation
|
||||||
|
end
|
||||||
|
|
||||||
-- Unload to Coordinate.
|
-- Unload to Coordinate.
|
||||||
self:Unload(cargo.opsgroup, Coordinate, self.cargoTransport:GetDisembarkActivation(self.cargoTZC), Heading)
|
self:Unload(cargo.opsgroup, Coordinate, activation, Heading)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -7771,6 +7853,7 @@ function OPSGROUP:onafterUnloadingDone(From, Event, To)
|
|||||||
|
|
||||||
if not delivered then
|
if not delivered then
|
||||||
|
|
||||||
|
-- Get new TZC.
|
||||||
self.cargoTZC=self.cargoTransport:_GetTransportZoneCombo(self)
|
self.cargoTZC=self.cargoTransport:_GetTransportZoneCombo(self)
|
||||||
|
|
||||||
if self.cargoTZC then
|
if self.cargoTZC then
|
||||||
@ -7856,17 +7939,18 @@ function OPSGROUP:onafterDelivered(From, Event, To, CargoTransport)
|
|||||||
self:__Cruise(0.1)
|
self:__Cruise(0.1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set carrier transport status.
|
||||||
|
self.cargoTransport:SetCarrierTransportStatus(self, OPSTRANSPORT.Status.DELIVERED)
|
||||||
|
|
||||||
-- Check group done.
|
-- Check group done.
|
||||||
self:T(self.lid.."All cargo delivered ==> check group done in 0.2 sec")
|
self:T(self.lid..string.format("All cargo of transport UID=%d delivered ==> check group done in 0.2 sec", self.cargoTransport.uid))
|
||||||
self:_CheckGroupDone(0.2)
|
self:_CheckGroupDone(0.2)
|
||||||
|
|
||||||
-- No current transport any more.
|
|
||||||
self.cargoTransport=nil
|
|
||||||
self.cargoTZC=nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove cargo transport from cargo queue.
|
-- Remove cargo transport from cargo queue.
|
||||||
self:DelOpsTransport(CargoTransport)
|
--self:DelOpsTransport(CargoTransport)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -8023,7 +8107,8 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
|||||||
local CargoIsArmyOrNavy=self:IsArmygroup() or self:IsNavygroup()
|
local CargoIsArmyOrNavy=self:IsArmygroup() or self:IsNavygroup()
|
||||||
|
|
||||||
-- Check that carrier is standing still.
|
-- Check that carrier is standing still.
|
||||||
if (CarrierIsArmyOrNavy and (CarrierGroup:IsHolding() and CarrierGroup:GetVelocity(Carrier.name)<=1)) or (CarrierGroup:IsFlightgroup() and (CarrierGroup:IsParking() or CarrierGroup:IsLandedAt())) then
|
--if (CarrierIsArmyOrNavy and (CarrierGroup:IsHolding() and CarrierGroup:GetVelocity(Carrier.name)<=1)) or (CarrierGroup:IsFlightgroup() and (CarrierGroup:IsParking() or CarrierGroup:IsLandedAt())) then
|
||||||
|
if (CarrierIsArmyOrNavy and (CarrierGroup:GetVelocity(Carrier.name)<=1)) or (CarrierGroup:IsFlightgroup() and (CarrierGroup:IsParking() or CarrierGroup:IsLandedAt())) then
|
||||||
|
|
||||||
-- Board if group is mobile, not late activated and army or navy. Everything else is loaded directly.
|
-- Board if group is mobile, not late activated and army or navy. Everything else is loaded directly.
|
||||||
local board=self.speedMax>0 and CargoIsArmyOrNavy and self:IsAlive() and CarrierGroup:IsAlive()
|
local board=self.speedMax>0 and CargoIsArmyOrNavy and self:IsAlive() and CarrierGroup:IsAlive()
|
||||||
@ -8036,7 +8121,7 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
|||||||
if board then
|
if board then
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Boarding group=%s [%s], carrier=%s", CarrierGroup:GetName(), CarrierGroup:GetState(), Carrier.name))
|
self:T(self.lid..string.format("Boarding group=%s [%s], carrier=%s", CarrierGroup:GetName(), CarrierGroup:GetState(), tostring(Carrier.name)))
|
||||||
|
|
||||||
-- TODO: Implement embarkzone.
|
-- TODO: Implement embarkzone.
|
||||||
local Coordinate=Carrier.unit:GetCoordinate()
|
local Coordinate=Carrier.unit:GetCoordinate()
|
||||||
@ -8062,7 +8147,7 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
|||||||
---
|
---
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Board with direct load to carrier %s", CarrierGroup:GetName()))
|
self:T(self.lid..string.format("Board [loaded=%s] with direct load to carrier group=%s, element=%s", tostring(self:IsLoaded()), CarrierGroup:GetName(), tostring(Carrier.name)))
|
||||||
|
|
||||||
-- Get current carrier group.
|
-- Get current carrier group.
|
||||||
local mycarriergroup=self:_GetMyCarrierGroup()
|
local mycarriergroup=self:_GetMyCarrierGroup()
|
||||||
@ -8071,8 +8156,9 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Unload cargo first.
|
-- Unload cargo first.
|
||||||
if mycarriergroup and mycarriergroup:GetName()~=CarrierGroup:GetName() and self:IsLoaded() then
|
if mycarriergroup and mycarriergroup:GetName()~=CarrierGroup:GetName() then
|
||||||
-- TODO: Unload triggers other stuff like Disembarked. This can be a problem!
|
-- TODO: Unload triggers other stuff like Disembarked. This can be a problem!
|
||||||
|
self:T(self.lid.."Unloading from mycarrier")
|
||||||
mycarriergroup:Unload(self)
|
mycarriergroup:Unload(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -503,8 +503,9 @@ end
|
|||||||
-- @param #OPSTRANSPORT self
|
-- @param #OPSTRANSPORT self
|
||||||
-- @param Core.Set#SET_GROUP GroupSet Set of groups to be transported. Can also be passed as a single GROUP or OPSGROUP object.
|
-- @param Core.Set#SET_GROUP GroupSet Set of groups to be transported. Can also be passed as a single GROUP or OPSGROUP object.
|
||||||
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||||
|
-- @param #boolean DisembarkActivation If `true`, cargo group is activated when disembarked. If `false`, cargo groups are late activated when disembarked. Default `nil` (usually activated).
|
||||||
-- @return #OPSTRANSPORT self
|
-- @return #OPSTRANSPORT self
|
||||||
function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo)
|
function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo, DisembarkActivation)
|
||||||
|
|
||||||
-- Use default TZC if no transport zone combo is provided.
|
-- Use default TZC if no transport zone combo is provided.
|
||||||
TransportZoneCombo=TransportZoneCombo or self.tzcDefault
|
TransportZoneCombo=TransportZoneCombo or self.tzcDefault
|
||||||
@ -513,7 +514,7 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo)
|
|||||||
if GroupSet:IsInstanceOf("GROUP") or GroupSet:IsInstanceOf("OPSGROUP") then
|
if GroupSet:IsInstanceOf("GROUP") or GroupSet:IsInstanceOf("OPSGROUP") then
|
||||||
|
|
||||||
-- We got a single GROUP or OPSGROUP object.
|
-- We got a single GROUP or OPSGROUP object.
|
||||||
local cargo=self:_CreateCargoGroupData(GroupSet, TransportZoneCombo)
|
local cargo=self:_CreateCargoGroupData(GroupSet, TransportZoneCombo, DisembarkActivation)
|
||||||
|
|
||||||
if cargo then
|
if cargo then
|
||||||
|
|
||||||
@ -536,7 +537,7 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo)
|
|||||||
for _,group in pairs(GroupSet.Set) do
|
for _,group in pairs(GroupSet.Set) do
|
||||||
|
|
||||||
-- Call iteravely for each group.
|
-- Call iteravely for each group.
|
||||||
self:AddCargoGroups(group, TransportZoneCombo)
|
self:AddCargoGroups(group, TransportZoneCombo, DisembarkActivation)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -651,6 +652,58 @@ function OPSTRANSPORT:GetEmbarkZone(TransportZoneCombo)
|
|||||||
return TransportZoneCombo.EmbarkZone
|
return TransportZoneCombo.EmbarkZone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
|
||||||
|
--- Set transfer carrier(s). These are carrier groups, where the cargo is directly loaded into when disembarked.
|
||||||
|
-- @param #OPSTRANSPORT self
|
||||||
|
-- @param Core.Set#SET_GROUP Carriers Carrier set. Can also be passed as a #GROUP, #OPSGROUP or #SET_OPSGROUP object.
|
||||||
|
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||||
|
-- @return #OPSTRANSPORT self
|
||||||
|
function OPSTRANSPORT:SetEmbarkCarriers(Carriers, TransportZoneCombo)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid.."Setting embark carriers!")
|
||||||
|
|
||||||
|
-- Use default TZC if no transport zone combo is provided.
|
||||||
|
TransportZoneCombo=TransportZoneCombo or self.tzcDefault
|
||||||
|
|
||||||
|
if Carriers:IsInstanceOf("GROUP") or Carriers:IsInstanceOf("OPSGROUP") then
|
||||||
|
|
||||||
|
local carrier=self:_GetOpsGroupFromObject(Carriers)
|
||||||
|
if carrier then
|
||||||
|
table.insert(TransportZoneCombo.EmbarkCarriers, carrier)
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif Carriers:IsInstanceOf("SET_GROUP") or Carriers:IsInstanceOf("SET_OPSGROUP") then
|
||||||
|
|
||||||
|
for _,object in pairs(Carriers:GetSet()) do
|
||||||
|
local carrier=self:_GetOpsGroupFromObject(object)
|
||||||
|
if carrier then
|
||||||
|
table.insert(TransportZoneCombo.EmbarkCarriers, carrier)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self:E(self.lid.."ERROR: Carriers must be a GROUP, OPSGROUP, SET_GROUP or SET_OPSGROUP object!")
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get embark transfer carrier(s). These are carrier groups, where the cargo is directly loaded into when disembarked.
|
||||||
|
-- @param #OPSTRANSPORT self
|
||||||
|
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||||
|
-- @return #table Table of carrier OPS groups.
|
||||||
|
function OPSTRANSPORT:GetEmbarkCarriers(TransportZoneCombo)
|
||||||
|
|
||||||
|
-- Use default TZC if no transport zone combo is provided.
|
||||||
|
TransportZoneCombo=TransportZoneCombo or self.tzcDefault
|
||||||
|
|
||||||
|
return TransportZoneCombo.EmbarkCarriers
|
||||||
|
end
|
||||||
|
|
||||||
|
]]
|
||||||
|
|
||||||
--- Set disembark zone.
|
--- Set disembark zone.
|
||||||
-- @param #OPSTRANSPORT self
|
-- @param #OPSTRANSPORT self
|
||||||
-- @param Core.Zone#ZONE DisembarkZone Zone where the troops are disembarked.
|
-- @param Core.Zone#ZONE DisembarkZone Zone where the troops are disembarked.
|
||||||
@ -953,9 +1006,13 @@ end
|
|||||||
--- Remove group from the current carrier list/table.
|
--- Remove group from the current carrier list/table.
|
||||||
-- @param #OPSTRANSPORT self
|
-- @param #OPSTRANSPORT self
|
||||||
-- @param Ops.OpsGroup#OPSGROUP CarrierGroup Carrier OPSGROUP.
|
-- @param Ops.OpsGroup#OPSGROUP CarrierGroup Carrier OPSGROUP.
|
||||||
|
-- @param #number Delay Delay in seconds before the carrier is removed.
|
||||||
-- @return #OPSTRANSPORT self
|
-- @return #OPSTRANSPORT self
|
||||||
function OPSTRANSPORT:_DelCarrier(CarrierGroup)
|
function OPSTRANSPORT:_DelCarrier(CarrierGroup, Delay)
|
||||||
|
|
||||||
|
if Delay and Delay>0 then
|
||||||
|
self:ScheduleOnce(Delay, OPSTRANSPORT._DelCarrier, CarrierGroup)
|
||||||
|
else
|
||||||
if self:IsCarrier(CarrierGroup) then
|
if self:IsCarrier(CarrierGroup) then
|
||||||
|
|
||||||
for i=#self.carriers,1,-1 do
|
for i=#self.carriers,1,-1 do
|
||||||
@ -967,6 +1024,7 @@ function OPSTRANSPORT:_DelCarrier(CarrierGroup)
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1280,6 +1338,13 @@ end
|
|||||||
-- @return #OPSTRANSPORT self
|
-- @return #OPSTRANSPORT self
|
||||||
function OPSTRANSPORT:SetCarrierTransportStatus(CarrierGroup, Status)
|
function OPSTRANSPORT:SetCarrierTransportStatus(CarrierGroup, Status)
|
||||||
|
|
||||||
|
-- Old status
|
||||||
|
local oldstatus=self:GetCarrierTransportStatus(CarrierGroup)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("New carrier transport status for %s: %s --> %s", CarrierGroup:GetName(), oldstatus, Status))
|
||||||
|
|
||||||
|
-- Set new status.
|
||||||
self.carrierTransportStatus[CarrierGroup.groupname]=Status
|
self.carrierTransportStatus[CarrierGroup.groupname]=Status
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -1290,7 +1355,8 @@ end
|
|||||||
-- @param Ops.OpsGroup#OPSGROUP CarrierGroup Carrier OPSGROUP.
|
-- @param Ops.OpsGroup#OPSGROUP CarrierGroup Carrier OPSGROUP.
|
||||||
-- @return #string Carrier status.
|
-- @return #string Carrier status.
|
||||||
function OPSTRANSPORT:GetCarrierTransportStatus(CarrierGroup)
|
function OPSTRANSPORT:GetCarrierTransportStatus(CarrierGroup)
|
||||||
return self.carrierTransportStatus[CarrierGroup.groupname]
|
local status=self.carrierTransportStatus[CarrierGroup.groupname] or "unknown"
|
||||||
|
return status
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get unique ID of the transport assignment.
|
--- Get unique ID of the transport assignment.
|
||||||
@ -1423,12 +1489,14 @@ end
|
|||||||
-- @return #boolean If true, group is an assigned carrier.
|
-- @return #boolean If true, group is an assigned carrier.
|
||||||
function OPSTRANSPORT:IsCarrier(CarrierGroup)
|
function OPSTRANSPORT:IsCarrier(CarrierGroup)
|
||||||
|
|
||||||
|
if CarrierGroup then
|
||||||
for _,_carrier in pairs(self.carriers) do
|
for _,_carrier in pairs(self.carriers) do
|
||||||
local carrier=_carrier --Ops.OpsGroup#OPSGROUP
|
local carrier=_carrier --Ops.OpsGroup#OPSGROUP
|
||||||
if carrier.groupname==CarrierGroup.groupname then
|
if carrier.groupname==CarrierGroup.groupname then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -2001,9 +2069,10 @@ end
|
|||||||
--- Create a cargo group data structure.
|
--- Create a cargo group data structure.
|
||||||
-- @param #OPSTRANSPORT self
|
-- @param #OPSTRANSPORT self
|
||||||
-- @param Wrapper.Group#GROUP group The GROUP or OPSGROUP object.
|
-- @param Wrapper.Group#GROUP group The GROUP or OPSGROUP object.
|
||||||
-- @return Ops.OpsGroup#OPSGROUP.CargoGroup Cargo group data.
|
|
||||||
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||||
function OPSTRANSPORT:_CreateCargoGroupData(group, TransportZoneCombo)
|
-- @param #boolean DisembarkActivation If `true`, cargo group is activated when disembarked.
|
||||||
|
-- @return Ops.OpsGroup#OPSGROUP.CargoGroup Cargo group data.
|
||||||
|
function OPSTRANSPORT:_CreateCargoGroupData(group, TransportZoneCombo, DisembarkActivation)
|
||||||
|
|
||||||
-- Get ops group.
|
-- Get ops group.
|
||||||
local opsgroup=self:_GetOpsGroupFromObject(group)
|
local opsgroup=self:_GetOpsGroupFromObject(group)
|
||||||
@ -2024,8 +2093,7 @@ function OPSTRANSPORT:_CreateCargoGroupData(group, TransportZoneCombo)
|
|||||||
cargo.opsgroup=opsgroup
|
cargo.opsgroup=opsgroup
|
||||||
cargo.delivered=false
|
cargo.delivered=false
|
||||||
cargo.status="Unknown"
|
cargo.status="Unknown"
|
||||||
cargo.disembarkCarrierElement=nil
|
cargo.disembarkActivation=DisembarkActivation
|
||||||
cargo.disembarkCarrierGroup=nil
|
|
||||||
cargo.tzcUID=TransportZoneCombo
|
cargo.tzcUID=TransportZoneCombo
|
||||||
|
|
||||||
return cargo
|
return cargo
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user