- Fixed some stuff for Egress coordinate
- Fixed some bugs in OPSTRANPORT if disembark carriers are specified
This commit is contained in:
Frank 2021-09-20 22:47:51 +02:00
parent 9b6cae6c49
commit c5af279730
4 changed files with 179 additions and 44 deletions

View File

@ -385,7 +385,7 @@ AUFTRAG.Type={
} }
--- Mission status of an assigned group. --- Mission status of an assigned group.
-- @type AUFTRAG.GroupStatus -- @type AUFTRAG.SpecialTask
-- @field #string PATROLZONE Patrol zone task. -- @field #string PATROLZONE Patrol zone task.
-- @field #string RECON Recon task -- @field #string RECON Recon task
-- @field #string AMMOSUPPLY Ammo Supply. -- @field #string AMMOSUPPLY Ammo Supply.
@ -508,8 +508,10 @@ AUFTRAG.Category={
-- @type AUFTRAG.GroupData -- @type AUFTRAG.GroupData
-- @field Ops.OpsGroup#OPSGROUP opsgroup The OPS group. -- @field Ops.OpsGroup#OPSGROUP opsgroup The OPS group.
-- @field Core.Point#COORDINATE waypointcoordinate Ingress waypoint coordinate. -- @field Core.Point#COORDINATE waypointcoordinate Ingress waypoint coordinate.
-- @field #number waypointindex Waypoint index. -- @field #number waypointindex Mission (ingress) Waypoint UID.
-- @field #number waypointEgressUID Egress Waypoint UID.
-- @field Core.Point#COORDINATE wpegresscoordinate Egress waypoint coordinate. -- @field Core.Point#COORDINATE wpegresscoordinate Egress waypoint coordinate.
--
-- @field Ops.OpsGroup#OPSGROUP.Task waypointtask Waypoint task. -- @field Ops.OpsGroup#OPSGROUP.Task waypointtask Waypoint task.
-- @field #string status Group mission status. -- @field #string status Group mission status.
-- @field Functional.Warehouse#WAREHOUSE.Assetitem asset The warehouse asset. -- @field Functional.Warehouse#WAREHOUSE.Assetitem asset The warehouse asset.
@ -2599,7 +2601,7 @@ end
--- Check if mission is ready to be pushed. --- Check if mission is ready to be pushed.
-- * Mission push time already passed. -- * Mission push time already passed.
-- * All push conditions are true. -- * **All** push conditions are true.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @return #boolean If true, mission groups can push. -- @return #boolean If true, mission groups can push.
function AUFTRAG:IsReadyToPush() function AUFTRAG:IsReadyToPush()
@ -2607,7 +2609,7 @@ function AUFTRAG:IsReadyToPush()
local Tnow=timer.getAbsTime() local Tnow=timer.getAbsTime()
-- Push time passed? -- Push time passed?
if self.Tpush and Tnow<self.Tpush then if self.Tpush and Tnow<=self.Tpush then
return false return false
end end
@ -3060,19 +3062,22 @@ function AUFTRAG:GetLegionStatus(Legion)
end end
--- Set Ops group waypoint coordinate. --- Set mission (ingress) waypoint coordinate for OPS group.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group. -- @param Ops.OpsGroup#OPSGROUP opsgroup The OPS group.
-- @param Core.Point#COORDINATE coordinate Waypoint Coordinate. -- @param Core.Point#COORDINATE coordinate Waypoint Coordinate.
-- @return #AUFTRAG self
function AUFTRAG:SetGroupWaypointCoordinate(opsgroup, coordinate) function AUFTRAG:SetGroupWaypointCoordinate(opsgroup, coordinate)
local groupdata=self:GetGroupData(opsgroup) local groupdata=self:GetGroupData(opsgroup)
if groupdata then if groupdata then
groupdata.waypointcoordinate=coordinate groupdata.waypointcoordinate=coordinate
end end
return self
end end
--- Get opsgroup waypoint coordinate. --- Get mission (ingress) waypoint coordinate of OPS group
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Ops.OpsGroup#OPSGROUP opsgroup The OPS group.
-- @return Core.Point#COORDINATE Waypoint Coordinate. -- @return Core.Point#COORDINATE Waypoint Coordinate.
function AUFTRAG:GetGroupWaypointCoordinate(opsgroup) function AUFTRAG:GetGroupWaypointCoordinate(opsgroup)
local groupdata=self:GetGroupData(opsgroup) local groupdata=self:GetGroupData(opsgroup)
@ -3082,9 +3087,9 @@ function AUFTRAG:GetGroupWaypointCoordinate(opsgroup)
end end
--- Set Ops group waypoint task. --- Set mission waypoint task for OPS group.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group. -- @param Ops.OpsGroup#OPSGROUP opsgroup The OPS group.
-- @param Ops.OpsGroup#OPSGROUP.Task task Waypoint task. -- @param Ops.OpsGroup#OPSGROUP.Task task Waypoint task.
function AUFTRAG:SetGroupWaypointTask(opsgroup, task) function AUFTRAG:SetGroupWaypointTask(opsgroup, task)
self:T2(self.lid..string.format("Setting waypoint task %s", task and task.description or "WTF")) self:T2(self.lid..string.format("Setting waypoint task %s", task and task.description or "WTF"))
@ -3094,9 +3099,9 @@ function AUFTRAG:SetGroupWaypointTask(opsgroup, task)
end end
end end
--- Get opsgroup waypoint task. --- Get mission waypoint task of OPS group.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group. -- @param Ops.OpsGroup#OPSGROUP opsgroup The OPS group.
-- @return Ops.OpsGroup#OPSGROUP.Task task Waypoint task. Waypoint task. -- @return Ops.OpsGroup#OPSGROUP.Task task Waypoint task. Waypoint task.
function AUFTRAG:GetGroupWaypointTask(opsgroup) function AUFTRAG:GetGroupWaypointTask(opsgroup)
local groupdata=self:GetGroupData(opsgroup) local groupdata=self:GetGroupData(opsgroup)
@ -3105,22 +3110,24 @@ function AUFTRAG:GetGroupWaypointTask(opsgroup)
end end
end end
--- Set opsgroup waypoint index. --- Set mission (ingress) waypoint UID for OPS group.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group. -- @param Ops.OpsGroup#OPSGROUP opsgroup The OPS group.
-- @param #number waypointindex Waypoint index. -- @param #number waypointindex Waypoint UID.
-- @return #AUFTRAG self
function AUFTRAG:SetGroupWaypointIndex(opsgroup, waypointindex) function AUFTRAG:SetGroupWaypointIndex(opsgroup, waypointindex)
self:T2(self.lid..string.format("Setting waypoint index %d", waypointindex)) self:T2(self.lid..string.format("Setting Mission waypoint UID=%d", waypointindex))
local groupdata=self:GetGroupData(opsgroup) local groupdata=self:GetGroupData(opsgroup)
if groupdata then if groupdata then
groupdata.waypointindex=waypointindex groupdata.waypointindex=waypointindex
end end
return self
end end
--- Get opsgroup waypoint index. --- Get mission (ingress) waypoint UID of OPS group.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group. -- @param Ops.OpsGroup#OPSGROUP opsgroup The OPS group.
-- @return #number Waypoint index -- @return #number Waypoint UID.
function AUFTRAG:GetGroupWaypointIndex(opsgroup) function AUFTRAG:GetGroupWaypointIndex(opsgroup)
local groupdata=self:GetGroupData(opsgroup) local groupdata=self:GetGroupData(opsgroup)
if groupdata then if groupdata then
@ -3128,6 +3135,32 @@ function AUFTRAG:GetGroupWaypointIndex(opsgroup)
end end
end end
--- Set Egress waypoint UID for OPS group.
-- @param #AUFTRAG self
-- @param Ops.OpsGroup#OPSGROUP opsgroup The OPS group.
-- @param #number waypointindex Waypoint UID.
-- @return #AUFTRAG self
function AUFTRAG:SetGroupEgressWaypointUID(opsgroup, waypointindex)
self:T2(self.lid..string.format("Setting Egress waypoint UID=%d", waypointindex))
local groupdata=self:GetGroupData(opsgroup)
if groupdata then
groupdata.waypointEgressUID=waypointindex
end
return self
end
--- Get Egress waypoint UID of OPS group.
-- @param #AUFTRAG self
-- @param Ops.OpsGroup#OPSGROUP opsgroup The OPS group.
-- @return #number Waypoint UID.
function AUFTRAG:GetGroupEgressWaypointUID(opsgroup)
local groupdata=self:GetGroupData(opsgroup)
if groupdata then
return groupdata.waypointEgressUID
end
end
--- Check if all flights are done with their mission (or dead). --- Check if all flights are done with their mission (or dead).
-- @param #AUFTRAG self -- @param #AUFTRAG self
@ -4052,7 +4085,7 @@ function AUFTRAG:UpdateMarker()
local text=string.format("%s %s: %s", self.name, self.type:upper(), self.status:upper()) local text=string.format("%s %s: %s", self.name, self.type:upper(), self.status:upper())
text=text..string.format("\n%s", self:GetTargetName()) text=text..string.format("\n%s", self:GetTargetName())
text=text..string.format("\nTargets %d/%d, Life Points=%d/%d", self:CountMissionTargets(), self:GetTargetInitialNumber(), self:GetTargetLife(), self:GetTargetInitialLife()) text=text..string.format("\nTargets %d/%d, Life Points=%d/%d", self:CountMissionTargets(), self:GetTargetInitialNumber(), self:GetTargetLife(), self:GetTargetInitialLife())
text=text..string.format("\nOpsGroups %d/%d", self:CountOpsGroups(), self.nassets) text=text..string.format("\nOpsGroups %d/%d", self:CountOpsGroups(), self:GetNumberOfRequiredAssets())
if not self.marker then if not self.marker then

View File

@ -2654,19 +2654,20 @@ function FLIGHTGROUP:onafterWait(From, Event, To, Duration, Altitude, Speed)
Speed=Speed or (self.isHelo and 20 or 250) Speed=Speed or (self.isHelo and 20 or 250)
-- Debug message. -- Debug message.
local text=string.format("Flight group set to wait/orbit at altitude %d m and speed %.1f km/h", Altitude, Speed) local text=string.format("Group set to wait/orbit at altitude %d m and speed %.1f km/h for %s seconds", Altitude, Speed, tostring(Duration))
self:T(self.lid..text) self:T(self.lid..text)
--TODO: set ROE passive. introduce roe event/state/variable. --TODO: set ROE passive. introduce roe event/state/variable.
-- Orbit until flaghold=1 (true) but max 5 min if no FC is giving the landing clearance. -- Orbit until flaghold=1 (true) but max 5 min if no FC is giving the landing clearance.
self.flaghold:Set(0)
local TaskOrbit = self.group:TaskOrbit(Coord, Altitude, UTILS.KnotsToMps(Speed)) local TaskOrbit = self.group:TaskOrbit(Coord, Altitude, UTILS.KnotsToMps(Speed))
local TaskStop = self.group:TaskCondition(nil, nil, nil, nil, Duration) local TaskStop = self.group:TaskCondition(nil, self.flaghold.UserFlagName, 1, nil, Duration)
local TaskCntr = self.group:TaskControlled(TaskOrbit, TaskStop) local TaskCntr = self.group:TaskControlled(TaskOrbit, TaskStop)
local TaskOver = self.group:TaskFunction("FLIGHTGROUP._FinishedWaiting", self) local TaskOver = self.group:TaskFunction("FLIGHTGROUP._FinishedWaiting", self)
local DCSTasks local DCSTasks
if Duration then if Duration or true then
DCSTasks=self.group:TaskCombo({TaskCntr, TaskOver}) DCSTasks=self.group:TaskCombo({TaskCntr, TaskOver})
else else
DCSTasks=self.group:TaskCombo({TaskOrbit, TaskOver}) DCSTasks=self.group:TaskCombo({TaskOrbit, TaskOver})
@ -2674,7 +2675,7 @@ function FLIGHTGROUP:onafterWait(From, Event, To, Duration, Altitude, Speed)
-- Set task. -- Set task.
self:SetTask(DCSTasks) self:PushTask(DCSTasks)
-- Set time stamp. -- Set time stamp.
self.Twaiting=timer.getAbsTime() self.Twaiting=timer.getAbsTime()
@ -3175,7 +3176,7 @@ end
-- @return Wrapper.Airbase#AIRBASE Final destination airbase or #nil. -- @return Wrapper.Airbase#AIRBASE Final destination airbase or #nil.
function FLIGHTGROUP:GetHomebaseFromWaypoints() function FLIGHTGROUP:GetHomebaseFromWaypoints()
local wp=self:GetWaypoint(1) local wp=self.waypoints0 and self.waypoints0[1] or nil --self:GetWaypoint(1)
if wp then if wp then
@ -3289,7 +3290,7 @@ end
-- @return Wrapper.Airbase#AIRBASE Final destination airbase or #nil. -- @return Wrapper.Airbase#AIRBASE Final destination airbase or #nil.
function FLIGHTGROUP:GetDestinationFromWaypoints() function FLIGHTGROUP:GetDestinationFromWaypoints()
local wp=self:GetWaypointFinal() local wp=self.waypoints0 and self.waypoints0[#self.waypoints0] or nil --self:GetWaypointFinal()
if wp then if wp then

View File

@ -3230,26 +3230,47 @@ function OPSGROUP:onbeforeTaskExecute(From, Event, To, Task)
if Mission and (Mission.Tpush or #Mission.conditionPush>0) then if Mission and (Mission.Tpush or #Mission.conditionPush>0) then
if Mission:IsReadyToPush() then if Mission:IsReadyToPush() then
-- Not waiting any more. ---
self.Twaiting=nil -- READY to push yet
self.dTwait=nil ---
-- Group is currently waiting.
if self:IsWaiting() then
-- Not waiting any more.
self.Twaiting=nil
self.dTwait=nil
-- For a flight group, we must cancel the wait/orbit task.
if self:IsFlightgroup() then
-- Set hold flag to 1. This is a condition in the wait/orbit task.
self.flaghold:Set(1)
-- Reexecute task in 1 sec to allow to flag to take effect.
--self:__TaskExecute(-1, Task)
-- Deny transition for now.
--return false
end
end
else else
--- ---
-- Not ready to push yet -- NOT READY to push yet
--- ---
if self:IsWaiting() then if self:IsWaiting() then
-- Group is already waiting -- Group is already waiting
else else
-- Wait indefinately.
self:Wait() self:Wait()
end end
-- Time to for the next try. -- Time to for the next try. Best guess is when push time is reached or 20 sec when push conditions are not true yet.
local dt=Mission.Tpush and Mission.Tpush-timer.getAbsTime() or 20 local dt=Mission.Tpush and Mission.Tpush-timer.getAbsTime() or 20
-- Debug info. -- Debug info.
self:T(self.lid..string.format("Mission %s task execute suspended for %d seconds", Mission.name, dt)) self:T(self.lid..string.format("Mission %s task execute suspended for %d seconds", Mission.name, dt))
@ -3594,8 +3615,13 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task)
local status=Mission:GetGroupStatus(self) local status=Mission:GetGroupStatus(self)
if status~=AUFTRAG.GroupStatus.PAUSED then if status~=AUFTRAG.GroupStatus.PAUSED then
self:T(self.lid.."Task Done ==> Mission Done!") local EgressUID=Mission:GetGroupEgressWaypointUID(self)
self:MissionDone(Mission) if EgressUID then
self:T(self.lid..string.format("Task Done but Egress waypoint defined ==> Will call Mission Done once group passed waypoint UID=%d!", EgressUID))
else
self:T(self.lid.."Task Done ==> Mission Done!")
self:MissionDone(Mission)
end
else else
--Mission paused. Do nothing! Just set the current mission to nil so we can launch a new one. --Mission paused. Do nothing! Just set the current mission to nil so we can launch a new one.
if self.currentmission and self.currentmission==Mission.auftragsnummer then if self.currentmission and self.currentmission==Mission.auftragsnummer then
@ -3800,7 +3826,8 @@ function OPSGROUP:_GetNextMission()
isEscort=false isEscort=false
end end
end end
-- Conditons to start.
local isScheduled=mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.SCHEDULED local isScheduled=mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.SCHEDULED
local isReadyToGo=(mission:IsReadyToGo() or self.legion) local isReadyToGo=(mission:IsReadyToGo() or self.legion)
local isImportant=(mission.importance==nil or mission.importance<=vip) local isImportant=(mission.importance==nil or mission.importance<=vip)
@ -4297,7 +4324,9 @@ function OPSGROUP:RouteToMission(mission, delay)
-- Add egress waypoint. -- Add egress waypoint.
local egress=mission:GetMissionEgressCoord() local egress=mission:GetMissionEgressCoord()
if egress then if egress then
--egress:MarkToAll(string.format("Egress Mission %s alt=%d m", mission:GetName(), waypointcoord.y))
local waypointEgress=self:AddWaypoint(egress, SpeedToMission, waypoint.uid, formation, false) ; waypointEgress.missionUID=mission.auftragsnummer local waypointEgress=self:AddWaypoint(egress, SpeedToMission, waypoint.uid, formation, false) ; waypointEgress.missionUID=mission.auftragsnummer
mission:SetGroupEgressWaypointUID(self, waypointEgress.uid)
end end
--- ---
@ -4633,13 +4662,26 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
end end
-- Passing mission waypoint? -- Passing mission waypoint?
local isEgress=false
if Waypoint.missionUID then if Waypoint.missionUID then
self:T2(self.lid..string.format("Passing mission waypoint"))
-- Debug info.
self:T2(self.lid..string.format("Passing mission waypoint UID=%s", tostring(Waypoint.uid)))
-- Get the mission.
local mission=self:GetMissionByID(Waypoint.missionUID)
-- Check if this was an Egress waypoint of the mission. If so, call Mission Done! This will call CheckGroupDone.
local EgressUID=mission and mission:GetGroupEgressWaypointUID(self) or nil
isEgress=EgressUID and Waypoint.uid==EgressUID
if isEgress and mission:GetGroupStatus(self)~=AUFTRAG.GroupStatus.DONE then
self:MissionDone(mission)
end
end end
-- Check if all tasks/mission are done? -- Check if all tasks/mission are done?
-- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there. -- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there.
if ntasks==0 and self:HasPassedFinalWaypoint() then if ntasks==0 and self:HasPassedFinalWaypoint() and not isEgress then
self:_CheckGroupDone(0.01) self:_CheckGroupDone(0.01)
end end
@ -6788,10 +6830,24 @@ function OPSGROUP:onafterLoading(From, Event, To)
-- Loading time stamp. -- Loading time stamp.
self.Tloading=timer.getAbsTime() self.Tloading=timer.getAbsTime()
--TODO: sort cargos wrt weight.
-- Cargo group table. -- Cargo group table.
local cargos=self.cargoTZC.Cargos --local cargos=self.cargoTZC.Cargos
local cargos={}
for _,_cargo in pairs(self.cargoTZC.Cargos) do
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
if self:CanCargo(cargo.opsgroup) and (not (cargo.delivered or cargo.opsgroup:IsDead())) then
table.insert(cargos, cargo)
end
end
-- Sort results table wrt descending weight.
local function _sort(a, b)
local cargoA=a --Ops.OpsGroup#OPSGROUP.CargoGroup
local cargoB=b --Ops.OpsGroup#OPSGROUP.CargoGroup
return cargoA.opsgroup:GetWeightTotal()>cargoB.opsgroup:GetWeightTotal()
end
table.sort(cargos, _sort)
-- Loop over all cargos. -- Loop over all cargos.
for _,_cargo in pairs(cargos) do for _,_cargo in pairs(cargos) do
@ -8019,8 +8075,16 @@ function OPSGROUP:_CheckStuck()
-- Time we are holding. -- Time we are holding.
local holdtime=Tnow-self.stuckTimestamp local holdtime=Tnow-self.stuckTimestamp
if holdtime>=5*60 and holdtime<10*60 then
if holdtime>=10*60 then -- Debug warning.
self:E(self.lid..string.format("WARNING: Group came to an unexpected standstill. Speed=%.1f<%.1f m/s expected for %d sec", speed, ExpectedSpeed, holdtime))
-- Give cruise command again.
self:__Cruise(1)
elseif holdtime>=10*60 then
-- Debug warning. -- Debug warning.
self:E(self.lid..string.format("WARNING: Group came to an unexpected standstill. Speed=%.1f<%.1f m/s expected for %d sec", speed, ExpectedSpeed, holdtime)) self:E(self.lid..string.format("WARNING: Group came to an unexpected standstill. Speed=%.1f<%.1f m/s expected for %d sec", speed, ExpectedSpeed, holdtime))
@ -8428,6 +8492,9 @@ function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax)
local destbase=self:GetDestinationFromWaypoints() local destbase=self:GetDestinationFromWaypoints()
self.destbase=self.destbase or destbase self.destbase=self.destbase or destbase
self.currbase=self:GetHomebaseFromWaypoints() self.currbase=self:GetHomebaseFromWaypoints()
--env.info("FF home base "..(self.homebase and self.homebase:GetName() or "unknown"))
--env.info("FF dest base "..(self.destbase and self.destbase:GetName() or "unknown"))
-- Remove the landing waypoint. We use RTB for that. It makes adding new waypoints easier as we do not have to check if the last waypoint is the landing waypoint. -- Remove the landing waypoint. We use RTB for that. It makes adding new waypoints easier as we do not have to check if the last waypoint is the landing waypoint.
if destbase and #self.waypoints>1 then if destbase and #self.waypoints>1 then

View File

@ -700,7 +700,7 @@ end
--- Get transfer carrier(s). These are carrier groups, where the cargo is directly loaded into when disembarked. --- Get transfer carrier(s). These are carrier groups, where the cargo is directly loaded into when disembarked.
-- @param #OPSTRANSPORT self -- @param #OPSTRANSPORT self
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo. -- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
-- @return #table Table of carriers. -- @return #table Table of carrier OPS groups.
function OPSTRANSPORT:GetDisembarkCarriers(TransportZoneCombo) function OPSTRANSPORT:GetDisembarkCarriers(TransportZoneCombo)
-- Use default TZC if no transport zone combo is provided. -- Use default TZC if no transport zone combo is provided.
@ -909,7 +909,7 @@ function OPSTRANSPORT:GetCargoOpsGroups(Delivered, Carrier, TransportZoneCombo)
end end
end end
end end
return opsgroups return opsgroups
end end
@ -1898,15 +1898,49 @@ function OPSTRANSPORT:_CountCargosInZone(Zone, Delivered, Carrier, TransportZone
-- Get cargo ops groups. -- Get cargo ops groups.
local cargos=self:GetCargoOpsGroups(Delivered, Carrier, TransportZoneCombo) local cargos=self:GetCargoOpsGroups(Delivered, Carrier, TransportZoneCombo)
--- Function to check if carrier is supposed to be disembarked to.
local function iscarrier(_cargo)
local cargo=_cargo --Ops.OpsGroup#OPSGROUP
local mycarrier=cargo:_GetMyCarrierGroup()
if mycarrier and mycarrier:IsUnloading() then
local carriers=mycarrier.cargoTransport:GetDisembarkCarriers(mycarrier.cargoTZC)
for _,_carrier in pairs(carriers) do
local carrier=_carrier --Ops.OpsGroup#OPSGROUP
if Carrier:GetName()==carrier:GetName() then
return true
end
end
end
return false
end
local N=0 local N=0
for _,_cargo in pairs(cargos) do for _,_cargo in pairs(cargos) do
local cargo=_cargo --Ops.OpsGroup#OPSGROUP local cargo=_cargo --Ops.OpsGroup#OPSGROUP
local isNotCargo=cargo:IsNotCargo(true)
if not isNotCargo then
isNotCargo=iscarrier(cargo)
end
-- Debug info.
--self:T2(self.lid..string.format("Cargo=%s: notcargo=%s, iscarrier=%s inzone=%s, inutero=%s", cargo:GetName(), tostring(cargo:IsNotCargo(true)), tostring(iscarrier(cargo)), tostring(cargo:IsInZone(Zone)), tostring(cargo:IsInUtero()) ))
-- We look for groups that are not cargo, in the zone or in utero. -- We look for groups that are not cargo, in the zone or in utero.
if cargo:IsNotCargo(true) and (cargo:IsInZone(Zone) or cargo:IsInUtero()) then if isNotCargo and (cargo:IsInZone(Zone) or cargo:IsInUtero()) then
N=N+1 N=N+1
end end
end end
-- Debug info.
self:T(self.lid..string.format("Found %d units in zone %s", N, Zone:GetName()))
return N return N
end end