mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OPS Cargo
This commit is contained in:
@@ -460,6 +460,22 @@ do -- Types
|
|||||||
--@field #boolean lateActivated
|
--@field #boolean lateActivated
|
||||||
--@field #boolean uncontrolled
|
--@field #boolean uncontrolled
|
||||||
|
|
||||||
|
--- DCS template data structure.
|
||||||
|
-- @type Template
|
||||||
|
-- @field #boolean uncontrolled Aircraft is uncontrolled.
|
||||||
|
-- @field #boolean lateActivation Group is late activated.
|
||||||
|
-- @field #number x 2D Position on x-axis in meters.
|
||||||
|
-- @field #number y 2D Position on y-axis in meters.
|
||||||
|
-- @field #table units Unit list.
|
||||||
|
--
|
||||||
|
|
||||||
|
--- Unit data structure.
|
||||||
|
--@type Template.Unit
|
||||||
|
--@field #string name Name of the unit.
|
||||||
|
--@field #number x
|
||||||
|
--@field #number y
|
||||||
|
--@field #number alt
|
||||||
|
|
||||||
end --
|
end --
|
||||||
|
|
||||||
|
|
||||||
@@ -1452,4 +1468,4 @@ do -- AI
|
|||||||
|
|
||||||
AI = {} --#AI
|
AI = {} --#AI
|
||||||
|
|
||||||
end -- AI
|
end -- AI
|
||||||
|
|||||||
@@ -464,8 +464,8 @@ function ARMYGROUP:onafterStatus(From, Event, To)
|
|||||||
local ammo=self:GetAmmoElement(element)
|
local ammo=self:GetAmmoElement(element)
|
||||||
|
|
||||||
-- Output text for element.
|
-- Output text for element.
|
||||||
text=text..string.format("\n[%d] %s: status=%s, life=%.1f/%.1f, guns=%d, rockets=%d, bombs=%d, missiles=%d",
|
text=text..string.format("\n[%d] %s: status=%s, life=%.1f/%.1f, guns=%d, rockets=%d, bombs=%d, missiles=%d, cargo=%d/%d kg",
|
||||||
i, name, status, life, life0, ammo.Guns, ammo.Rockets, ammo.Bombs, ammo.Missiles)
|
i, name, status, life, life0, ammo.Guns, ammo.Rockets, ammo.Bombs, ammo.Missiles, element.weightCargo, element.weightMaxCargo)
|
||||||
end
|
end
|
||||||
if #self.elements==0 then
|
if #self.elements==0 then
|
||||||
text=text.." none!"
|
text=text.." none!"
|
||||||
@@ -478,88 +478,7 @@ function ARMYGROUP:onafterStatus(From, Event, To)
|
|||||||
-- Cargo
|
-- Cargo
|
||||||
---
|
---
|
||||||
|
|
||||||
if self.cargoTransport then
|
self:_CheckCargoTransport()
|
||||||
|
|
||||||
-- Debug
|
|
||||||
local text=string.format("Carrier [%s]: %s --> %s", self.carrierStatus, self.cargoTransport.pickupzone:GetName(), self.cargoTransport.deployzone:GetName())
|
|
||||||
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
|
||||||
local name=cargo.opsgroup:GetName()
|
|
||||||
local gstatus=cargo.opsgroup:GetState()
|
|
||||||
local cstatus=cargo.opsgroup.cargoStatus
|
|
||||||
text=text..string.format("\n- %s [%s]: %s", name, gstatus, cstatus)
|
|
||||||
--self:I({template=cargo.opsgroup.template})
|
|
||||||
end
|
|
||||||
self:I(self.lid..text)
|
|
||||||
|
|
||||||
|
|
||||||
if self:IsNotCarrier() then
|
|
||||||
|
|
||||||
env.info("FF not carrier ==> pickup")
|
|
||||||
|
|
||||||
--TODO: Check if there is still cargo left. Maybe someone else already picked it up or it got destroyed.
|
|
||||||
|
|
||||||
-- Initiate the cargo transport process.
|
|
||||||
self:Pickup(self.cargoTransport.pickupzone)
|
|
||||||
|
|
||||||
elseif self:IsPickingup() then
|
|
||||||
|
|
||||||
env.info("FF picking up")
|
|
||||||
|
|
||||||
--TODO: Check if there is still cargo left. Maybe someone else already picked it up or it got destroyed.
|
|
||||||
|
|
||||||
elseif self:IsLoading() then
|
|
||||||
|
|
||||||
env.info("FF loading")
|
|
||||||
|
|
||||||
local boarding=false
|
|
||||||
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
|
||||||
|
|
||||||
if cargo.opsgroup.carrierGroup and cargo.opsgroup.carrierGroup:GetName()==self:GetName() and cargo.opsgroup.cargoStatus==OPSGROUP.CargoStatus.BOARDING then
|
|
||||||
boarding=true
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Boarding finished ==> Transport cargo.
|
|
||||||
if not boarding then
|
|
||||||
env.info("FF boarding finished ==> Loaded")
|
|
||||||
self:Loaded()
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif self:IsLoaded() then
|
|
||||||
|
|
||||||
env.info("FF loaded (nothing to do?)")
|
|
||||||
|
|
||||||
elseif self:IsTransporting() then
|
|
||||||
|
|
||||||
env.info("FF transporting (nothing to do)")
|
|
||||||
|
|
||||||
elseif self:IsUnloading() then
|
|
||||||
|
|
||||||
env.info("FF unloading ==> Checking if all cargo was delivered")
|
|
||||||
|
|
||||||
local delivered=true
|
|
||||||
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
|
||||||
|
|
||||||
if (cargo.opsgroup.carrierGroup and cargo.opsgroup.carrierGroup:GetName()==self:GetName()) and not cargo.delivered then
|
|
||||||
delivered=false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Boarding finished ==> Transport cargo.
|
|
||||||
if delivered then
|
|
||||||
env.info("FF unloading finished ==> Unloaded")
|
|
||||||
self:Unloaded()
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ function FLIGHTGROUP:New(group)
|
|||||||
|
|
||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
|
self:AddTransition("*", "LandAtAirbase", "Inbound") -- Helo group is ordered to land at a specific point.
|
||||||
self:AddTransition("*", "RTB", "Inbound") -- Group is returning to destination base.
|
self:AddTransition("*", "RTB", "Inbound") -- Group is returning to destination base.
|
||||||
self:AddTransition("*", "RTZ", "Inbound") -- Group is returning to destination zone. Not implemented yet!
|
self:AddTransition("*", "RTZ", "Inbound") -- Group is returning to destination zone. Not implemented yet!
|
||||||
self:AddTransition("Inbound", "Holding", "Holding") -- Group is in holding pattern.
|
self:AddTransition("Inbound", "Holding", "Holding") -- Group is in holding pattern.
|
||||||
@@ -795,7 +796,7 @@ function FLIGHTGROUP:onbeforeStatus(From, Event, To)
|
|||||||
local text=string.format("Element %s is dead at t=%.3f! Maybe despawned without notice or landed at a too small airbase. Calling ElementDead in 60 sec to give other events a chance",
|
local text=string.format("Element %s is dead at t=%.3f! Maybe despawned without notice or landed at a too small airbase. Calling ElementDead in 60 sec to give other events a chance",
|
||||||
tostring(element.name), timer.getTime())
|
tostring(element.name), timer.getTime())
|
||||||
self:E(self.lid..text)
|
self:E(self.lid..text)
|
||||||
self:__ElementDead(60, element)
|
--self:__ElementDead(60, element)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1013,7 +1014,6 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
|||||||
-- Engage Detected Targets
|
-- Engage Detected Targets
|
||||||
---
|
---
|
||||||
if self:IsAirborne() and self.detectionOn and self.engagedetectedOn and not (self.fuellow or self.fuelcritical) then
|
if self:IsAirborne() and self.detectionOn and self.engagedetectedOn and not (self.fuellow or self.fuelcritical) then
|
||||||
env.info("FF 100")
|
|
||||||
|
|
||||||
-- Target.
|
-- Target.
|
||||||
local targetgroup=nil --Wrapper.Group#GROUP
|
local targetgroup=nil --Wrapper.Group#GROUP
|
||||||
@@ -1023,12 +1023,8 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
|||||||
for _,_group in pairs(self.detectedgroups:GetSet()) do
|
for _,_group in pairs(self.detectedgroups:GetSet()) do
|
||||||
local group=_group --Wrapper.Group#GROUP
|
local group=_group --Wrapper.Group#GROUP
|
||||||
|
|
||||||
env.info("FF 200")
|
|
||||||
|
|
||||||
if group and group:IsAlive() then
|
if group and group:IsAlive() then
|
||||||
|
|
||||||
env.info("FF 300")
|
|
||||||
|
|
||||||
-- Get 3D vector of target.
|
-- Get 3D vector of target.
|
||||||
local targetVec3=group:GetVec3()
|
local targetVec3=group:GetVec3()
|
||||||
|
|
||||||
@@ -1037,8 +1033,6 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
if distance<=self.engagedetectedRmax and distance<targetdist then
|
if distance<=self.engagedetectedRmax and distance<targetdist then
|
||||||
|
|
||||||
env.info("FF 400")
|
|
||||||
|
|
||||||
-- Check type attribute.
|
-- Check type attribute.
|
||||||
local righttype=false
|
local righttype=false
|
||||||
for _,attribute in pairs(self.engagedetectedTypes) do
|
for _,attribute in pairs(self.engagedetectedTypes) do
|
||||||
@@ -1101,6 +1095,12 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Cargo
|
||||||
|
---
|
||||||
|
|
||||||
|
self:_CheckCargoTransport()
|
||||||
|
|
||||||
|
|
||||||
-- Next check in ~30 seconds.
|
-- Next check in ~30 seconds.
|
||||||
if not self:IsStopped() then
|
if not self:IsStopped() then
|
||||||
@@ -1554,6 +1554,9 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
|||||||
self:GetGroup():SetOption(AI.Option.Air.id.PROHIBIT_AB, true) -- Does not seem to work. AI still used the after burner.
|
self:GetGroup():SetOption(AI.Option.Air.id.PROHIBIT_AB, true) -- Does not seem to work. AI still used the after burner.
|
||||||
self:GetGroup():SetOption(AI.Option.Air.id.RTB_ON_BINGO, false)
|
self:GetGroup():SetOption(AI.Option.Air.id.RTB_ON_BINGO, false)
|
||||||
--self.group:SetOption(AI.Option.Air.id.RADAR_USING, AI.Option.Air.val.RADAR_USING.FOR_CONTINUOUS_SEARCH)
|
--self.group:SetOption(AI.Option.Air.id.RADAR_USING, AI.Option.Air.val.RADAR_USING.FOR_CONTINUOUS_SEARCH)
|
||||||
|
|
||||||
|
-- Update status.
|
||||||
|
self:__Status(-0.1)
|
||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
self:__UpdateRoute(-0.5)
|
self:__UpdateRoute(-0.5)
|
||||||
@@ -1703,6 +1706,14 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function FLIGHTGROUP:onafterLandedAt(From, Event, To)
|
function FLIGHTGROUP:onafterLandedAt(From, Event, To)
|
||||||
self:T(self.lid..string.format("Flight landed at"))
|
self:T(self.lid..string.format("Flight landed at"))
|
||||||
|
|
||||||
|
|
||||||
|
if self:IsPickingup() then
|
||||||
|
self:Loading()
|
||||||
|
elseif self:IsTransporting() then
|
||||||
|
self:Deploy()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -1721,7 +1732,78 @@ function FLIGHTGROUP:onafterArrived(From, Event, To)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Despawn in 5 min.
|
-- Despawn in 5 min.
|
||||||
if not self.airwing then
|
if self.airwing then
|
||||||
|
-- Let airwing do its thing.
|
||||||
|
elseif self.isLandingAtAirbase then
|
||||||
|
|
||||||
|
local Template=UTILS.DeepCopy(self.template) --DCS#Template
|
||||||
|
|
||||||
|
-- No late activation.
|
||||||
|
self.isLateActivated=false
|
||||||
|
Template.lateActivation=self.isLateActivated
|
||||||
|
|
||||||
|
-- Spawn in uncontrolled state.
|
||||||
|
self.isUncontrolled=true
|
||||||
|
Template.uncontrolled=self.isUncontrolled
|
||||||
|
|
||||||
|
-- First waypoint of the group.
|
||||||
|
local SpawnPoint=Template.route.points[1]
|
||||||
|
|
||||||
|
-- These are only for ships and FARPS.
|
||||||
|
SpawnPoint.linkUnit = nil
|
||||||
|
SpawnPoint.helipadId = nil
|
||||||
|
SpawnPoint.airdromeId = nil
|
||||||
|
|
||||||
|
-- Airbase.
|
||||||
|
local airbase=self.isLandingAtAirbase
|
||||||
|
|
||||||
|
-- Get airbase ID and category.
|
||||||
|
local AirbaseID = airbase:GetID()
|
||||||
|
|
||||||
|
-- Set airdromeId.
|
||||||
|
if airbase:IsShip() then
|
||||||
|
SpawnPoint.linkUnit = AirbaseID
|
||||||
|
SpawnPoint.helipadId = AirbaseID
|
||||||
|
elseif airbase:IsHelipad() then
|
||||||
|
SpawnPoint.linkUnit = AirbaseID
|
||||||
|
SpawnPoint.helipadId = AirbaseID
|
||||||
|
elseif airbase:IsAirdrome() then
|
||||||
|
SpawnPoint.airdromeId = AirbaseID
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set waypoint type/action.
|
||||||
|
SpawnPoint.alt = 0
|
||||||
|
SpawnPoint.type = COORDINATE.WaypointType.TakeOffParking
|
||||||
|
SpawnPoint.action = COORDINATE.WaypointAction.FromParkingArea
|
||||||
|
|
||||||
|
local units=Template.units
|
||||||
|
|
||||||
|
for i=#units,1,-1 do
|
||||||
|
local unit=units[i]
|
||||||
|
local element=self:GetElementByName(unit.name)
|
||||||
|
if element and element.status~=OPSGROUP.ElementStatus.DEAD then
|
||||||
|
unit.parking=element.parking.TerminalID
|
||||||
|
unit.parking_id=nil
|
||||||
|
local vec3=element.unit:GetVec3()
|
||||||
|
local heading=element.unit:GetHeading()
|
||||||
|
unit.x=vec3.x
|
||||||
|
unit.y=vec3.z
|
||||||
|
unit.alt=vec3.y
|
||||||
|
unit.heading=math.rad(heading)
|
||||||
|
unit.psi=-unit.heading
|
||||||
|
else
|
||||||
|
table.remove(units, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Respawn with this template.
|
||||||
|
self:_Respawn(0, Template)
|
||||||
|
|
||||||
|
-- Reset.
|
||||||
|
self.isLandingAtAirbase=nil
|
||||||
|
|
||||||
|
else
|
||||||
|
-- Depawn after 5 min. Important to trigger dead events before DCS despawns on its own without any notification.
|
||||||
self:Despawn(5*60)
|
self:Despawn(5*60)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1860,9 +1942,16 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
|||||||
|
|
||||||
-- Current velocity.
|
-- Current velocity.
|
||||||
local speed=self.group and self.group:GetVelocityKMH() or 100
|
local speed=self.group and self.group:GetVelocityKMH() or 100
|
||||||
|
|
||||||
|
-- Waypoint type.
|
||||||
|
local waypointType=COORDINATE.WaypointType.TurningPoint
|
||||||
|
if self:IsLanded() or self:IsLandedAt() or self:IsAirborne()==false then
|
||||||
|
-- Had some issues with passing waypoint function of the next WP called too ealy when the type is TurningPoint. Setting it to TakeOff solved it!
|
||||||
|
waypointType=COORDINATE.WaypointType.TakeOff
|
||||||
|
end
|
||||||
|
|
||||||
-- Set current waypoint or we get problem that the _PassingWaypoint function is triggered too early, i.e. right now and not when passing the next WP.
|
-- Set current waypoint or we get problem that the _PassingWaypoint function is triggered too early, i.e. right now and not when passing the next WP.
|
||||||
local current=self.group:GetCoordinate():WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, speed, true, nil, {}, "Current")
|
local current=self.group:GetCoordinate():WaypointAir(COORDINATE.WaypointAltType.BARO, waypointType, COORDINATE.WaypointAction.TurningPoint, speed, true, nil, {}, "Current")
|
||||||
table.insert(wp, current)
|
table.insert(wp, current)
|
||||||
|
|
||||||
local Nwp=self.waypoints and #self.waypoints or 0
|
local Nwp=self.waypoints and #self.waypoints or 0
|
||||||
@@ -1916,6 +2005,9 @@ function FLIGHTGROUP:_CheckGroupDone(delay)
|
|||||||
-- Delayed call.
|
-- Delayed call.
|
||||||
self:ScheduleOnce(delay, FLIGHTGROUP._CheckGroupDone, self)
|
self:ScheduleOnce(delay, FLIGHTGROUP._CheckGroupDone, self)
|
||||||
else
|
else
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid.."Check group done?")
|
||||||
|
|
||||||
-- First check if there is a paused mission that
|
-- First check if there is a paused mission that
|
||||||
if self.missionpaused then
|
if self.missionpaused then
|
||||||
@@ -1925,6 +2017,13 @@ function FLIGHTGROUP:_CheckGroupDone(delay)
|
|||||||
|
|
||||||
-- Group is currently engaging.
|
-- Group is currently engaging.
|
||||||
if self:IsEngaging() then
|
if self:IsEngaging() then
|
||||||
|
self:T(self.lid.."Engaging! Group NOT done...")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Group is ordered to land at an airbase.
|
||||||
|
if self.isLandingAtAirbase then
|
||||||
|
self:T(self.lid.."Landing at airbase! Group NOT done...")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2063,9 +2162,6 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
|||||||
-- Set the destination base.
|
-- Set the destination base.
|
||||||
self.destbase=airbase
|
self.destbase=airbase
|
||||||
|
|
||||||
-- Clear holding time in any case.
|
|
||||||
self.Tholding=nil
|
|
||||||
|
|
||||||
-- Cancel all missions.
|
-- Cancel all missions.
|
||||||
for _,_mission in pairs(self.missionqueue) do
|
for _,_mission in pairs(self.missionqueue) do
|
||||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
@@ -2080,10 +2176,39 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:_LandAtAirbase(airbase, SpeedTo, SpeedHold, SpeedLand)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On after "LandAtAirbase" event.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE airbase The airbase to hold at.
|
||||||
|
function FLIGHTGROUP:onafterLandAtAirbase(From, Event, To, airbase)
|
||||||
|
|
||||||
|
self.isLandingAtAirbase=airbase
|
||||||
|
|
||||||
|
self:_LandAtAirbase(airbase)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Land at an airbase.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE airbase Airbase where the group shall land.
|
||||||
|
-- @param #number SpeedTo Speed used for travelling from current position to holding point in knots.
|
||||||
|
-- @param #number SpeedHold Holding speed in knots.
|
||||||
|
-- @param #number SpeedLand Landing speed in knots. Default 170 kts.
|
||||||
|
function FLIGHTGROUP:_LandAtAirbase(airbase, SpeedTo, SpeedHold, SpeedLand)
|
||||||
|
|
||||||
-- Defaults:
|
-- Defaults:
|
||||||
SpeedTo=SpeedTo or UTILS.KmphToKnots(self.speedCruise)
|
SpeedTo=SpeedTo or UTILS.KmphToKnots(self.speedCruise)
|
||||||
SpeedHold=SpeedHold or (self.ishelo and 80 or 250)
|
SpeedHold=SpeedHold or (self.ishelo and 80 or 250)
|
||||||
SpeedLand=SpeedLand or (self.ishelo and 40 or 170)
|
SpeedLand=SpeedLand or (self.ishelo and 40 or 170)
|
||||||
|
|
||||||
|
-- Clear holding time in any case.
|
||||||
|
self.Tholding=nil
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Flight group set to hold at airbase %s. SpeedTo=%d, SpeedHold=%d, SpeedLand=%d", airbase:GetName(), SpeedTo, SpeedHold, SpeedLand)
|
local text=string.format("Flight group set to hold at airbase %s. SpeedTo=%d, SpeedHold=%d, SpeedLand=%d", airbase:GetName(), SpeedTo, SpeedHold, SpeedLand)
|
||||||
@@ -2181,7 +2306,7 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
|||||||
--self:ClearTasks()
|
--self:ClearTasks()
|
||||||
|
|
||||||
-- Just route the group. Respawn might happen when going from holding to final.
|
-- Just route the group. Respawn might happen when going from holding to final.
|
||||||
self:Route(wp, 1)
|
self:Route(wp)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2474,9 +2599,6 @@ function FLIGHTGROUP:onafterLandAt(From, Event, To, Coordinate, Duration)
|
|||||||
|
|
||||||
local Task=self:NewTaskScheduled(DCStask, 1, "Task_Land_At", 0)
|
local Task=self:NewTaskScheduled(DCStask, 1, "Task_Land_At", 0)
|
||||||
|
|
||||||
-- Add task with high priority.
|
|
||||||
--self:AddTask(task, 1, "Task_Land_At", 0)
|
|
||||||
|
|
||||||
self:TaskExecute(Task)
|
self:TaskExecute(Task)
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -3182,7 +3304,7 @@ function FLIGHTGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Altitud
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
Speed=Speed or 350
|
Speed=Speed or self.speedCruise
|
||||||
|
|
||||||
-- Create air waypoint.
|
-- Create air waypoint.
|
||||||
local wp=Coordinate:WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, UTILS.KnotsToKmph(Speed), true, nil, {})
|
local wp=Coordinate:WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, UTILS.KnotsToKmph(Speed), true, nil, {})
|
||||||
@@ -3209,6 +3331,54 @@ function FLIGHTGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Altitud
|
|||||||
return waypoint
|
return waypoint
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add an LANDING waypoint to the flight plan.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE Airbase The airbase where the group should land.
|
||||||
|
-- @param #number Speed Speed in knots. Default 350 kts.
|
||||||
|
-- @param #number AfterWaypointWithID Insert waypoint after waypoint given ID. Default is to insert as last waypoint.
|
||||||
|
-- @param #number Altitude Altitude in feet. Default is y-component of Coordinate. Note that these altitudes are wrt to sea level (barometric altitude).
|
||||||
|
-- @param #boolean Updateroute If true or nil, call UpdateRoute. If false, no call.
|
||||||
|
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
||||||
|
function FLIGHTGROUP:AddWaypointLanding(Airbase, Speed, AfterWaypointWithID, Altitude, Updateroute)
|
||||||
|
|
||||||
|
-- Set waypoint index.
|
||||||
|
local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID)
|
||||||
|
|
||||||
|
if wpnumber>self.currentwp then
|
||||||
|
self.passedfinalwp=false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Speed in knots.
|
||||||
|
Speed=Speed or self.speedCruise
|
||||||
|
|
||||||
|
-- Get coordinate of airbase.
|
||||||
|
local Coordinate=Airbase:GetCoordinate()
|
||||||
|
|
||||||
|
-- Create air waypoint.
|
||||||
|
local wp=Coordinate:WaypointAir(COORDINATE.WaypointAltType.BARO,COORDINATE.WaypointType.Land, COORDINATE.WaypointAction.Landing, Speed, nil, Airbase, {}, "Landing Temp", nil)
|
||||||
|
|
||||||
|
-- Create waypoint data table.
|
||||||
|
local waypoint=self:_CreateWaypoint(wp)
|
||||||
|
|
||||||
|
-- Set altitude.
|
||||||
|
if Altitude then
|
||||||
|
waypoint.alt=UTILS.FeetToMeters(Altitude)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add waypoint to table.
|
||||||
|
self:_AddWaypoint(waypoint, wpnumber)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Adding AIR waypoint #%d, speed=%.1f knots. Last waypoint passed was #%s. Total waypoints #%d", wpnumber, Speed, self.currentwp, #self.waypoints))
|
||||||
|
|
||||||
|
-- Update route.
|
||||||
|
if Updateroute==nil or Updateroute==true then
|
||||||
|
self:__UpdateRoute(-1)
|
||||||
|
end
|
||||||
|
|
||||||
|
return waypoint
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Check if a unit is an element of the flightgroup.
|
--- Check if a unit is an element of the flightgroup.
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
-- @field #OPSGROUP.WeaponData weaponData Weapon data table with key=BitType.
|
-- @field #OPSGROUP.WeaponData weaponData Weapon data table with key=BitType.
|
||||||
--
|
--
|
||||||
-- @field #OPSGROUP.Element carrier Carrier the group is loaded into as cargo.
|
-- @field #OPSGROUP.Element carrier Carrier the group is loaded into as cargo.
|
||||||
|
-- @field #OPSGROUP carrierGroup Carrier group transporting this group as cargo.
|
||||||
-- @field #table cargo Table containing all cargo of the carrier.
|
-- @field #table cargo Table containing all cargo of the carrier.
|
||||||
-- @field #table cargoqueue Table containing cargo groups to be transported.
|
-- @field #table cargoqueue Table containing cargo groups to be transported.
|
||||||
-- @field #OPSGROUP.CargoTransport cargoTransport Current cargo transport assignment.
|
-- @field #OPSGROUP.CargoTransport cargoTransport Current cargo transport assignment.
|
||||||
@@ -546,7 +547,7 @@ function OPSGROUP:New(group)
|
|||||||
self:AddTransition("*", "ElementDead", "*") -- An element is dead.
|
self:AddTransition("*", "ElementDead", "*") -- An element is dead.
|
||||||
self:AddTransition("*", "ElementDamaged", "*") -- An element was damaged.
|
self:AddTransition("*", "ElementDamaged", "*") -- An element was damaged.
|
||||||
|
|
||||||
self:AddTransition("*", "Board", "Boarding") -- Group is boarding a cargo carrier.
|
self:AddTransition("*", "Board", "*") -- Group is boarding a cargo carrier.
|
||||||
self:AddTransition("*", "Embark", "*") -- Group was loaded into a cargo carrier.
|
self:AddTransition("*", "Embark", "*") -- Group was loaded into a cargo carrier.
|
||||||
self:AddTransition("InUtero", "Unboard", "*") -- Group was unloaded from a cargo carrier.
|
self:AddTransition("InUtero", "Unboard", "*") -- Group was unloaded from a cargo carrier.
|
||||||
|
|
||||||
@@ -556,6 +557,7 @@ function OPSGROUP:New(group)
|
|||||||
self:AddTransition("*", "Loaded", "*") -- Carrier loaded all assigned cargo into carrier.
|
self:AddTransition("*", "Loaded", "*") -- Carrier loaded all assigned cargo into carrier.
|
||||||
self:AddTransition("*", "Transport", "*") -- Carrier is transporting cargo.
|
self:AddTransition("*", "Transport", "*") -- Carrier is transporting cargo.
|
||||||
self:AddTransition("*", "Deploy", "*") -- Carrier is dropping off cargo.
|
self:AddTransition("*", "Deploy", "*") -- Carrier is dropping off cargo.
|
||||||
|
self:AddTransition("*", "Unload", "*") -- Carrier unload a cargo group.
|
||||||
self:AddTransition("*", "Unloaded", "*") -- Carrier unloaded all its cargo.
|
self:AddTransition("*", "Unloaded", "*") -- Carrier unloaded all its cargo.
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
@@ -1255,6 +1257,9 @@ function OPSGROUP:Despawn(Delay, NoEventRemoveUnit)
|
|||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
|
|
||||||
|
-- Clear any task ==> makes DCS crash!
|
||||||
|
--self.group:ClearTasks()
|
||||||
|
|
||||||
-- Get all units.
|
-- Get all units.
|
||||||
local units=self:GetDCSUnits()
|
local units=self:GetDCSUnits()
|
||||||
|
|
||||||
@@ -1539,7 +1544,6 @@ function OPSGROUP:IsPickingup()
|
|||||||
return self.carrierStatus==OPSGROUP.CarrierStatus.PICKUP
|
return self.carrierStatus==OPSGROUP.CarrierStatus.PICKUP
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if the group is picking up cargo.
|
--- Check if the group is picking up cargo.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @return #boolean If true, group is picking up.
|
-- @return #boolean If true, group is picking up.
|
||||||
@@ -1547,16 +1551,9 @@ function OPSGROUP:IsLoading()
|
|||||||
return self.carrierStatus==OPSGROUP.CarrierStatus.LOADING
|
return self.carrierStatus==OPSGROUP.CarrierStatus.LOADING
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if the group is picking up cargo.
|
--- Check if the group is transporting cargo.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @return #boolean If true, group is picking up.
|
-- @return #boolean If true, group is transporting.
|
||||||
function OPSGROUP:IsLoaded()
|
|
||||||
return self.carrierStatus==OPSGROUP.CarrierStatus.LOADED
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Check if the group is picking up cargo.
|
|
||||||
-- @param #OPSGROUP self
|
|
||||||
-- @return #boolean If true, group is picking up.
|
|
||||||
function OPSGROUP:IsTransporting()
|
function OPSGROUP:IsTransporting()
|
||||||
return self.carrierStatus==OPSGROUP.CarrierStatus.TRANSPORTING
|
return self.carrierStatus==OPSGROUP.CarrierStatus.TRANSPORTING
|
||||||
end
|
end
|
||||||
@@ -1568,6 +1565,48 @@ function OPSGROUP:IsUnloading()
|
|||||||
return self.carrierStatus==OPSGROUP.CarrierStatus.UNLOADING
|
return self.carrierStatus==OPSGROUP.CarrierStatus.UNLOADING
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Check if the group is **not** cargo.
|
||||||
|
-- @param #OPSGROUP self
|
||||||
|
-- @return #boolean If true, group is *not* cargo.
|
||||||
|
function OPSGROUP:IsNotCargo()
|
||||||
|
return self.cargoStatus==OPSGROUP.CargoStatus.NOTCARGO
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if the group is currently boarding a carrier.
|
||||||
|
-- @param #OPSGROUP self
|
||||||
|
-- @param #string CarrierGroupName (Optional) Additionally check if group is boarding this particular carrier group.
|
||||||
|
-- @return #boolean If true, group is boarding.
|
||||||
|
function OPSGROUP:IsBoarding(CarrierGroupName)
|
||||||
|
if CarrierGroupName then
|
||||||
|
if self.carrierGroup and self.carrierGroup.groupname~=CarrierGroupName then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self.cargoStatus==OPSGROUP.CargoStatus.BOARDING
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if the group is currently loaded into a carrier.
|
||||||
|
-- @param #OPSGROUP self
|
||||||
|
-- @param #string CarrierGroupName (Optional) Additionally check if group is loaded into this particular carrier group.
|
||||||
|
-- @return #boolean If true, group is loaded.
|
||||||
|
function OPSGROUP:IsLoaded(CarrierGroupName)
|
||||||
|
if CarrierGroupName then
|
||||||
|
if self.carrierGroup and self.carrierGroup.groupname~=CarrierGroupName then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self.cargoStatus==OPSGROUP.CargoStatus.LOADED
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if the group is cargo and waiting for a carrier to pick it up.
|
||||||
|
-- @param #OPSGROUP self
|
||||||
|
-- @return #boolean If true, group is waiting for a carrier.
|
||||||
|
function OPSGROUP:IsWaitingAsCargo()
|
||||||
|
return self.cargoStatus==OPSGROUP.CargoStatus.WAITING
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Waypoint Functions
|
-- Waypoint Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -2562,9 +2601,14 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
if self.taskcurrent>0 then
|
if self.taskcurrent>0 then
|
||||||
self:TaskCancel()
|
self:TaskCancel()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set current task.
|
-- Set current task.
|
||||||
self.taskcurrent=Task.id
|
self.taskcurrent=Task.id
|
||||||
|
|
||||||
|
--
|
||||||
|
if self:GetTaskCurrent()==nil then
|
||||||
|
table.insert(self.taskqueue, Task)
|
||||||
|
end
|
||||||
|
|
||||||
-- Set time stamp.
|
-- Set time stamp.
|
||||||
Task.timestamp=timer.getAbsTime()
|
Task.timestamp=timer.getAbsTime()
|
||||||
@@ -4432,6 +4476,111 @@ end
|
|||||||
-- Cargo Functions
|
-- Cargo Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Check cargo transport assignments.
|
||||||
|
-- @param #OPSGROUP self
|
||||||
|
-- @return #OPSGROUP self
|
||||||
|
function OPSGROUP:_CheckCargoTransport()
|
||||||
|
|
||||||
|
if self.cargoTransport then
|
||||||
|
|
||||||
|
-- TODO: Check if this group can actually transport any cargo.
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
local text=string.format("Carrier [%s]: %s --> %s", self.carrierStatus, self.cargoTransport.pickupzone:GetName(), self.cargoTransport.deployzone:GetName())
|
||||||
|
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
||||||
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
|
local name=cargo.opsgroup:GetName()
|
||||||
|
local gstatus=cargo.opsgroup:GetState()
|
||||||
|
local cstatus=cargo.opsgroup.cargoStatus
|
||||||
|
local weight=cargo.opsgroup:GetWeightTotal()
|
||||||
|
text=text..string.format("\n- %s [%s]: %s (weight %.1f kg)", name, gstatus, cstatus, weight)
|
||||||
|
end
|
||||||
|
self:I(self.lid..text)
|
||||||
|
|
||||||
|
|
||||||
|
if self:IsNotCarrier() then
|
||||||
|
|
||||||
|
env.info("FF not carrier ==> pickup")
|
||||||
|
|
||||||
|
--TODO: Check if there is still cargo left. Maybe someone else already picked it up or it got destroyed.
|
||||||
|
|
||||||
|
-- Initiate the cargo transport process.
|
||||||
|
self:Pickup(self.cargoTransport.pickupzone)
|
||||||
|
|
||||||
|
elseif self:IsPickingup() then
|
||||||
|
|
||||||
|
env.info("FF picking up")
|
||||||
|
|
||||||
|
--TODO: Check if there is still cargo left. Maybe someone else already picked it up or it got destroyed.
|
||||||
|
|
||||||
|
elseif self:IsLoading() then
|
||||||
|
|
||||||
|
env.info("FF loading")
|
||||||
|
|
||||||
|
local boarding=false
|
||||||
|
local gotcargo=false
|
||||||
|
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
||||||
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
|
|
||||||
|
-- Check if anyone is still boarding.
|
||||||
|
if cargo.opsgroup:IsBoarding(self.groupname) then
|
||||||
|
boarding=true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if we have any cargo to transport.
|
||||||
|
if cargo.opsgroup:IsLoaded(self.groupname) then
|
||||||
|
gotcargo=true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Boarding finished ==> Transport cargo.
|
||||||
|
if gotcargo and not boarding then
|
||||||
|
env.info("FF boarding finished ==> Loaded")
|
||||||
|
self:Loaded()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- No cargo and noone is boarding ==> check again if we can make anyone board.
|
||||||
|
if not gotcargo and not boarding then
|
||||||
|
self:Loading()
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif self:IsLoaded() then
|
||||||
|
|
||||||
|
env.info("FF loaded (nothing to do?)")
|
||||||
|
|
||||||
|
elseif self:IsTransporting() then
|
||||||
|
|
||||||
|
env.info("FF transporting (nothing to do)")
|
||||||
|
|
||||||
|
elseif self:IsUnloading() then
|
||||||
|
|
||||||
|
env.info("FF unloading ==> Checking if all cargo was delivered")
|
||||||
|
|
||||||
|
local delivered=true
|
||||||
|
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
||||||
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
|
|
||||||
|
if (cargo.opsgroup.carrierGroup and cargo.opsgroup.carrierGroup:GetName()==self:GetName()) and not cargo.delivered then
|
||||||
|
delivered=false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Boarding finished ==> Transport cargo.
|
||||||
|
if delivered then
|
||||||
|
env.info("FF unloading finished ==> Unloaded")
|
||||||
|
self:Unloaded()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Create a cargo transport assignment.
|
--- Create a cargo transport assignment.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param Core.Set#SET_GROUP GroupSet Set of groups to be transported. Can also be a single @{Wrapper.Group#GROUP} object.
|
-- @param Core.Set#SET_GROUP GroupSet Set of groups to be transported. Can also be a single @{Wrapper.Group#GROUP} object.
|
||||||
@@ -4474,6 +4623,12 @@ function OPSGROUP:CreateCargoTransport(GroupSet, Pickupzone, Deployzone)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local text=string.format("Created Cargo Transport (UID=%d) from %s -->%s", transport.uid, transport.pickupzone:GetName(), transport.deployzone:GetName())
|
||||||
|
for _,_cargo in pairs(transport.cargos) do
|
||||||
|
local cargo=_cargo --#OPSGROUP.CargoGroup
|
||||||
|
text=text..string.format("\n- %s [%s] weight=%.1f kg", cargo.opsgroup:GetName(), cargo.opsgroup:GetState(), cargo.opsgroup:GetWeightTotal())
|
||||||
|
end
|
||||||
|
|
||||||
return transport
|
return transport
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4536,7 +4691,7 @@ function OPSGROUP:GetWeightTotal(UnitName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return weight
|
return weight
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get weight of the internal cargo the group is carriing right now.
|
--- Get weight of the internal cargo the group is carriing right now.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
@@ -4559,6 +4714,41 @@ function OPSGROUP:GetWeightCargo(UnitName)
|
|||||||
return weight
|
return weight
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add weight to the internal cargo of an element of the group.
|
||||||
|
-- @param #OPSGROUP self
|
||||||
|
-- @param #string UnitName Name of the unit. Default is of the whole group.
|
||||||
|
-- @param #number Weight Cargo weight to be added in kg.
|
||||||
|
function OPSGROUP:AddWeightCargo(UnitName, Weight)
|
||||||
|
|
||||||
|
local element=self:GetElementByName(UnitName)
|
||||||
|
|
||||||
|
if element and element.unit and element.unit:IsAlive() then
|
||||||
|
|
||||||
|
-- Add weight.
|
||||||
|
element.weightCargo=element.weightCargo+Weight
|
||||||
|
|
||||||
|
-- For airborne units, we set the weight in game.
|
||||||
|
if self.isFlightgroup then
|
||||||
|
trigger.action.setUnitInternalCargo(element.name, element.weightCargo) --https://wiki.hoggitworld.com/view/DCS_func_setUnitInternalCargo
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Reduce weight to the internal cargo of an element of the group.
|
||||||
|
-- @param #OPSGROUP self
|
||||||
|
-- @param #string UnitName Name of the unit.
|
||||||
|
-- @param #number Weight Cargo weight to be reduced in kg.
|
||||||
|
function OPSGROUP:RedWeightCargo(UnitName, Weight)
|
||||||
|
|
||||||
|
-- Reduce weight.
|
||||||
|
self:AddWeightCargo(UnitName, -Weight)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Create a cargo transport assignment.
|
--- Create a cargo transport assignment.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
@@ -4580,12 +4770,13 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Zone#ZONE Zone Pickup zone.
|
-- @param Core.Zone#ZONE Zone Pickup zone.
|
||||||
function OPSGROUP:onafterPickup(From, Event, To, Zone)
|
function OPSGROUP:onafterPickup(From, Event, To, Zone)
|
||||||
|
-- Debug info.
|
||||||
env.info("FF pickup")
|
self:I(self.lid..string.format("New carrier status %s --> %s", self.carrierStatus, OPSGROUP.CarrierStatus.PICKUP))
|
||||||
|
|
||||||
-- Set carrier status.
|
-- Set carrier status.
|
||||||
self.carrierStatus=OPSGROUP.CarrierStatus.PICKUP
|
self.carrierStatus=OPSGROUP.CarrierStatus.PICKUP
|
||||||
|
|
||||||
|
-- Check if already in the pickup zone.
|
||||||
local inzone=Zone:IsCoordinateInZone(self:GetCoordinate())
|
local inzone=Zone:IsCoordinateInZone(self:GetCoordinate())
|
||||||
|
|
||||||
if inzone then
|
if inzone then
|
||||||
@@ -4598,8 +4789,16 @@ function OPSGROUP:onafterPickup(From, Event, To, Zone)
|
|||||||
-- Get a random coordinate in the pickup zone and let the carrier go there.
|
-- Get a random coordinate in the pickup zone and let the carrier go there.
|
||||||
local Coordinate=Zone:GetRandomCoordinate()
|
local Coordinate=Zone:GetRandomCoordinate()
|
||||||
|
|
||||||
local waypoint=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation, Updateroute)
|
--TODO: Add NAVYGROUP and FLIGHTGROUP waypoint
|
||||||
waypoint.detour=true
|
if self.isFlightgroup then
|
||||||
|
Coordinate:SetAltitude(200)
|
||||||
|
local waypoint=FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude, Updateroute)
|
||||||
|
waypoint.detour=true
|
||||||
|
else
|
||||||
|
local waypoint=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation, Updateroute)
|
||||||
|
waypoint.detour=true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4611,25 +4810,29 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function OPSGROUP:onafterLoading(From, Event, To)
|
function OPSGROUP:onafterLoading(From, Event, To)
|
||||||
env.info("FF loading")
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("New carrier status %s --> %s", self.carrierStatus, OPSGROUP.CarrierStatus.LOADING))
|
||||||
|
|
||||||
-- Set carrier status.
|
-- Set carrier status.
|
||||||
self.carrierStatus=OPSGROUP.CarrierStatus.LOADING
|
self.carrierStatus=OPSGROUP.CarrierStatus.LOADING
|
||||||
|
|
||||||
|
-- Create a temp array and monitor the free cargo space for each element.
|
||||||
|
local cargobay={}
|
||||||
|
for _,_element in pairs(self.elements) do
|
||||||
|
local element=_element --#OPSGROUP.Element
|
||||||
|
cargobay[element.name]=element.weightMaxCargo-element.weightCargo
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Find a carrier which can load a given weight.
|
--- Find a carrier which can load a given weight.
|
||||||
local function _findCarrier(weight)
|
local function _findCarrier(weight)
|
||||||
local carrier=nil --#OPSGROUP.Element
|
local carrier=nil --#OPSGROUP.Element
|
||||||
for _,_element in pairs(self.elements) do
|
for _,_element in pairs(self.elements) do
|
||||||
local element=_element --#OPSGROUP.Element
|
local element=_element --#OPSGROUP.Element
|
||||||
|
if cargobay[element.name]>=weight then
|
||||||
local cargobay=element.weightMaxCargo-element.weightCargo
|
|
||||||
|
|
||||||
if cargobay>=weight then
|
|
||||||
return element
|
return element
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4637,30 +4840,37 @@ function OPSGROUP:onafterLoading(From, Event, To)
|
|||||||
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
||||||
local cargo=_cargo --#OPSGROUP.CargoGroup
|
local cargo=_cargo --#OPSGROUP.CargoGroup
|
||||||
|
|
||||||
if not cargo.delivered then
|
if cargo.opsgroup:IsNotCargo() and not cargo.delivered then
|
||||||
|
|
||||||
local weight=cargo.opsgroup:GetWeightTotal()
|
-- Check if cargo is in pickup zone.
|
||||||
|
local inzone=self.cargoTransport.pickupzone:IsCoordinateInZone(cargo.opsgroup:GetCoordinate())
|
||||||
|
|
||||||
local carrier=_findCarrier(weight)
|
-- First check if cargo is not delivered yet.
|
||||||
|
if inzone then
|
||||||
|
|
||||||
if carrier then
|
local weight=cargo.opsgroup:GetWeightTotal()
|
||||||
|
|
||||||
-- Set cargo status.
|
|
||||||
cargo.opsgroup.cargoStatus=OPSGROUP.CargoStatus.ASSIGNED
|
|
||||||
|
|
||||||
-- Order cargo group to board the carrier.
|
|
||||||
env.info("FF order group to board carrier")
|
|
||||||
cargo.opsgroup:Board(self, carrier)
|
|
||||||
|
|
||||||
--TODO: only one group for testing
|
local carrier=_findCarrier(weight)
|
||||||
break
|
|
||||||
|
|
||||||
else
|
if carrier then
|
||||||
|
|
||||||
env.info("FF cannot board carrier")
|
-- Decrease free cargo bay.
|
||||||
|
cargobay[carrier.name]=cargobay[carrier.name]-weight
|
||||||
|
|
||||||
|
-- Set cargo status.
|
||||||
|
cargo.opsgroup.cargoStatus=OPSGROUP.CargoStatus.ASSIGNED
|
||||||
|
|
||||||
|
-- Order cargo group to board the carrier.
|
||||||
|
env.info("FF order group to board carrier")
|
||||||
|
cargo.opsgroup:Board(self, carrier)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
env.info("FF cannot board carrier")
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4682,18 +4892,12 @@ function OPSGROUP:onafterLoad(From, Event, To, CargoGroup)
|
|||||||
|
|
||||||
if carrier then
|
if carrier then
|
||||||
|
|
||||||
-- TODO: add function to set/add/get internal cargo.
|
-- Add weight to carrier.
|
||||||
carrier.weightCargo=carrier.weightCargo+weight
|
self:AddWeightCargo(carrier.name, weight)
|
||||||
|
|
||||||
-- This function is only really used for aircraft and sets the total internal cargo weight.
|
|
||||||
--trigger.action.setUnitInternalCargo(carrier.name, carrier.weightCargo) --https://wiki.hoggitworld.com/view/DCS_func_setUnitInternalCargo
|
|
||||||
|
|
||||||
-- Embark ==> Loaded
|
-- Embark ==> Loaded
|
||||||
CargoGroup:Embark(carrier)
|
CargoGroup:Embark(carrier)
|
||||||
|
|
||||||
--env.info("FF carrier loaded (todo)")
|
|
||||||
--self:Loaded()
|
|
||||||
|
|
||||||
else
|
else
|
||||||
self:E(self.lid.."ERROR: Cargo has no carrier on Load event!")
|
self:E(self.lid.."ERROR: Cargo has no carrier on Load event!")
|
||||||
end
|
end
|
||||||
@@ -4708,12 +4912,15 @@ end
|
|||||||
function OPSGROUP:onafterLoaded(From, Event, To)
|
function OPSGROUP:onafterLoaded(From, Event, To)
|
||||||
env.info("FF loaded")
|
env.info("FF loaded")
|
||||||
|
|
||||||
--TODO: analyze current cargo for deploy zones and initiate transport.
|
-- Cancel landedAt task.
|
||||||
|
if self.isFlightgroup and self:IsLandedAt() then
|
||||||
env.info("FF ordering carrier to transport")
|
local Task=self:GetTaskCurrent()
|
||||||
self:Transport(self.cargoTransport.deployzone)
|
self:TaskCancel(Task)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Order group to transport.
|
||||||
|
self:__Transport(1, self.cargoTransport.deployzone)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "Transport" event.
|
--- On after "Transport" event.
|
||||||
@@ -4723,8 +4930,9 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Zone#ZONE Zone Deploy zone.
|
-- @param Core.Zone#ZONE Zone Deploy zone.
|
||||||
function OPSGROUP:onafterTransport(From, Event, To, Zone)
|
function OPSGROUP:onafterTransport(From, Event, To, Zone)
|
||||||
env.info("FF transport")
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("New carrier status %s --> %s", self.carrierStatus, OPSGROUP.CarrierStatus.TRANSPORTING))
|
||||||
|
|
||||||
-- Set carrier status.
|
-- Set carrier status.
|
||||||
self.carrierStatus=OPSGROUP.CarrierStatus.TRANSPORTING
|
self.carrierStatus=OPSGROUP.CarrierStatus.TRANSPORTING
|
||||||
|
|
||||||
@@ -4734,28 +4942,38 @@ function OPSGROUP:onafterTransport(From, Event, To, Zone)
|
|||||||
if inzone then
|
if inzone then
|
||||||
|
|
||||||
-- We are already in the pickup zone ==> initiate loading.
|
-- We are already in the pickup zone ==> initiate loading.
|
||||||
self:Deploy()
|
self:Deploy(Zone)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Get a random coordinate in the pickup zone and let the carrier go there.
|
-- Get a random coordinate in the pickup zone and let the carrier go there.
|
||||||
local Coordinate=Zone:GetRandomCoordinate()
|
local Coordinate=Zone:GetRandomCoordinate()
|
||||||
|
|
||||||
local waypoint=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation, Updateroute)
|
--TODO: Add NAVYGROUP and FLIGHTGROUP waypoint
|
||||||
waypoint.detour=true
|
if self.isFlightgroup then
|
||||||
|
Coordinate:SetAltitude(200)
|
||||||
|
local waypoint=FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Altitude, Updateroute)
|
||||||
|
waypoint.detour=true
|
||||||
|
local dist=self:GetCoordinate():Get2DDistance(waypoint.coordinate)
|
||||||
|
env.info(string.format("FF adding transport detour wp with uid=%d at dist=%d m", waypoint.uid, dist))
|
||||||
|
else
|
||||||
|
local waypoint=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation, Updateroute)
|
||||||
|
waypoint.detour=true
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "Transport" event.
|
--- On after "Deploy" event.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Zone#ZONE Zone Deploy zone.
|
-- @param Core.Zone#ZONE Zone Deploy zone.
|
||||||
function OPSGROUP:onafterDeploy(From, Event, To, Zone)
|
function OPSGROUP:onafterDeploy(From, Event, To, Zone)
|
||||||
env.info("FF deploy at zone ".. (Zone and Zone:GetName() or "Not given!"))
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("New carrier status %s --> %s", self.carrierStatus, OPSGROUP.CarrierStatus.UNLOADING))
|
||||||
|
|
||||||
-- Set carrier status to UNLOADING.
|
-- Set carrier status to UNLOADING.
|
||||||
self.carrierStatus=OPSGROUP.CarrierStatus.UNLOADING
|
self.carrierStatus=OPSGROUP.CarrierStatus.UNLOADING
|
||||||
@@ -4763,7 +4981,8 @@ function OPSGROUP:onafterDeploy(From, Event, To, Zone)
|
|||||||
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
||||||
local cargo=_cargo --#OPSGROUP.CargoGroup
|
local cargo=_cargo --#OPSGROUP.CargoGroup
|
||||||
|
|
||||||
if cargo.opsgroup.cargoStatus==OPSGROUP.CargoStatus.LOADED and cargo.opsgroup.carrierGroup:GetName()==self.groupname then
|
-- Check that cargo is loaded into this group.
|
||||||
|
if cargo.opsgroup:IsLoaded(self.groupname) then
|
||||||
|
|
||||||
env.info("FF deploy cargo "..cargo.opsgroup:GetName())
|
env.info("FF deploy cargo "..cargo.opsgroup:GetName())
|
||||||
|
|
||||||
@@ -4774,12 +4993,12 @@ function OPSGROUP:onafterDeploy(From, Event, To, Zone)
|
|||||||
local Coordinate=zone:GetRandomCoordinate()
|
local Coordinate=zone:GetRandomCoordinate()
|
||||||
local Heading=math.random(0,359)
|
local Heading=math.random(0,359)
|
||||||
|
|
||||||
|
-- Cargo was delivered.
|
||||||
cargo.delivered=true
|
cargo.delivered=true
|
||||||
|
|
||||||
-- Unload.
|
-- Unload.
|
||||||
env.info("FF unload cargo "..cargo.opsgroup:GetName())
|
env.info("FF unload cargo "..cargo.opsgroup:GetName())
|
||||||
cargo.opsgroup:Unboard(Coordinate, Heading)
|
self:Unload(cargo.opsgroup, Coordinate, Heading)
|
||||||
--self:Unload(cargo.opsgroup, Coordinate, Heading)
|
|
||||||
|
|
||||||
--end
|
--end
|
||||||
|
|
||||||
@@ -4794,14 +5013,14 @@ end
|
|||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #OPSGROUP CargoGroup The OPSGROUP loaded as cargo.
|
-- @param #OPSGROUP OpsGroup The OPSGROUP loaded as cargo.
|
||||||
-- @param Core.Point#COORDINATE Coordinate Coordinate were the group is unloaded to.
|
-- @param Core.Point#COORDINATE Coordinate Coordinate were the group is unloaded to.
|
||||||
-- @param #number Heading Heading of group.
|
-- @param #number Heading Heading of group.
|
||||||
function OPSGROUP:onafterUnload(From, Event, To, CargoGroup, Coordinate, Heading)
|
function OPSGROUP:onafterUnload(From, Event, To, OpsGroup, Coordinate, Heading)
|
||||||
|
|
||||||
--TODO: Add check if CargoGroup is cargo of this carrier.
|
--TODO: Add check if CargoGroup is cargo of this carrier.
|
||||||
if CargoGroup:IsInUtero() then
|
if OpsGroup:IsInUtero() then
|
||||||
CargoGroup:Unboard(Coordinate, Heading)
|
OpsGroup:Unboard(Coordinate, Heading)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -4815,6 +5034,12 @@ end
|
|||||||
function OPSGROUP:onafterUnloaded(From, Event, To)
|
function OPSGROUP:onafterUnloaded(From, Event, To)
|
||||||
env.info("FF unloaded")
|
env.info("FF unloaded")
|
||||||
|
|
||||||
|
-- Cancel landedAt task.
|
||||||
|
if self.isFlightgroup and self:IsLandedAt() then
|
||||||
|
local Task=self:GetTaskCurrent()
|
||||||
|
self:TaskCancel(Task)
|
||||||
|
end
|
||||||
|
|
||||||
local pickup=false
|
local pickup=false
|
||||||
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
@@ -4839,7 +5064,7 @@ function OPSGROUP:onafterUnloaded(From, Event, To)
|
|||||||
self.cargoTransport=nil
|
self.cargoTransport=nil
|
||||||
|
|
||||||
env.info("FF all delivered ==> check group done")
|
env.info("FF all delivered ==> check group done")
|
||||||
self:_CheckGroupDone()
|
self:_CheckGroupDone(0.1)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4858,7 +5083,8 @@ end
|
|||||||
-- @param #OPSGROUP CarrierGroup The carrier group.
|
-- @param #OPSGROUP CarrierGroup The carrier group.
|
||||||
-- @param #OPSGROUP.Element Carrier The OPSGROUP element
|
-- @param #OPSGROUP.Element Carrier The OPSGROUP element
|
||||||
function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
||||||
env.info("FF board")
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("New cargo status %s --> %s", self.cargoStatus, OPSGROUP.CargoStatus.BOARDING))
|
||||||
|
|
||||||
-- Set cargo status.
|
-- Set cargo status.
|
||||||
self.cargoStatus=OPSGROUP.CargoStatus.BOARDING
|
self.cargoStatus=OPSGROUP.CargoStatus.BOARDING
|
||||||
@@ -4874,8 +5100,20 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
|||||||
--TODO: check if cargo is mobile. if not ==> load
|
--TODO: check if cargo is mobile. if not ==> load
|
||||||
--TODO: check if cargo is alive=true. if only exists ==> load.
|
--TODO: check if cargo is alive=true. if only exists ==> load.
|
||||||
|
|
||||||
-- Trigger embark event.
|
if self.speedMax>0 then
|
||||||
self.carrierGroup:__Load(10, self)
|
|
||||||
|
local Coordinate=Carrier.unit:GetCoordinate()
|
||||||
|
|
||||||
|
--TODO: NAVYGROUP and FLIGHTGROUP
|
||||||
|
local waypoint=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, AfterWaypointWithID, Formation, Updateroute)
|
||||||
|
waypoint.detour=true
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Trigger Load event in 10 seconds.
|
||||||
|
self.carrierGroup:__Load(10, self)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4887,7 +5125,8 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #OPSGROUP.Element Carrier The OPSGROUP element
|
-- @param #OPSGROUP.Element Carrier The OPSGROUP element
|
||||||
function OPSGROUP:onafterEmbark(From, Event, To, Carrier)
|
function OPSGROUP:onafterEmbark(From, Event, To, Carrier)
|
||||||
env.info("FF embark")
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("New cargo status %s --> %s", self.cargoStatus, OPSGROUP.CargoStatus.LOADED))
|
||||||
|
|
||||||
-- Set cargo status.
|
-- Set cargo status.
|
||||||
self.cargoStatus=OPSGROUP.CargoStatus.LOADED
|
self.cargoStatus=OPSGROUP.CargoStatus.LOADED
|
||||||
@@ -4907,14 +5146,12 @@ end
|
|||||||
-- @param Core.Point#COORDINATE Coordinate Coordinate were the group is unloaded to. Can also be a DCS#Vec3 object.
|
-- @param Core.Point#COORDINATE Coordinate Coordinate were the group is unloaded to. Can also be a DCS#Vec3 object.
|
||||||
-- @param #number Heading Heading the group has in degrees. Default is last known heading of the group.
|
-- @param #number Heading Heading the group has in degrees. Default is last known heading of the group.
|
||||||
function OPSGROUP:onafterUnboard(From, Event, To, Coordinate, Heading)
|
function OPSGROUP:onafterUnboard(From, Event, To, Coordinate, Heading)
|
||||||
env.info("FF Unboard")
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("New cargo status %s --> %s", self.cargoStatus, OPSGROUP.CargoStatus.NOTCARGO))
|
||||||
|
|
||||||
|
|
||||||
-- Template for the respawned group.
|
-- Template for the respawned group.
|
||||||
local Template=UTILS.DeepCopy(self.template)
|
local Template=UTILS.DeepCopy(self.template) --DCS#Template
|
||||||
|
|
||||||
env.info("FF template")
|
|
||||||
self:I({template=Template})
|
|
||||||
self:I({template=self.template})
|
|
||||||
|
|
||||||
-- Loop over template units.
|
-- Loop over template units.
|
||||||
for _,Unit in pairs(Template.units) do
|
for _,Unit in pairs(Template.units) do
|
||||||
@@ -4942,16 +5179,10 @@ function OPSGROUP:onafterUnboard(From, Event, To, Coordinate, Heading)
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Reduce carrier weight.
|
-- Reduce carrier weight.
|
||||||
for _,_element in pairs(self.elements) do
|
local weight=self:GetWeightTotal()
|
||||||
local element=_element --#OPSGROUP.Element
|
self.carrierGroup:RedWeightCargo(self.carrier.name, weight)
|
||||||
self.carrier.weightCargo=self.carrier.weightCargo-element.weight
|
|
||||||
end
|
|
||||||
-- This function is only really used for aircraft and sets the total internal cargo weight.
|
|
||||||
if self.isFlightgroup then
|
|
||||||
trigger.action.setUnitInternalCargo(self.carrier.name, self.carrier.weightCargo) --https://wiki.hoggitworld.com/view/DCS_func_setUnitInternalCargo
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set cargo status.
|
-- Set cargo status.
|
||||||
self.cargoStatus=OPSGROUP.CargoStatus.NOTCARGO
|
self.cargoStatus=OPSGROUP.CargoStatus.NOTCARGO
|
||||||
@@ -5669,7 +5900,7 @@ function OPSGROUP._PassingWaypoint(group, opsgroup, uid)
|
|||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Group passing waypoint uid=%d", uid)
|
local text=string.format("Group passing waypoint uid=%d", uid)
|
||||||
opsgroup:T(opsgroup.lid..text)
|
opsgroup:I(opsgroup.lid..text)
|
||||||
|
|
||||||
-- Trigger PassingWaypoint event.
|
-- Trigger PassingWaypoint event.
|
||||||
if waypoint.astar then
|
if waypoint.astar then
|
||||||
@@ -5697,15 +5928,48 @@ function OPSGROUP._PassingWaypoint(group, opsgroup, uid)
|
|||||||
|
|
||||||
elseif opsgroup:IsPickingup() then
|
elseif opsgroup:IsPickingup() then
|
||||||
|
|
||||||
opsgroup:FullStop()
|
if opsgroup.isFlightgroup then
|
||||||
|
|
||||||
opsgroup:Loading()
|
-- Land at current pos and wait for 60 min max.
|
||||||
|
opsgroup:LandAt(opsgroup:GetCoordinate(), 60*60)
|
||||||
|
|
||||||
|
else
|
||||||
|
-- Stop and loading.
|
||||||
|
opsgroup:FullStop()
|
||||||
|
opsgroup:Loading()
|
||||||
|
end
|
||||||
|
|
||||||
elseif opsgroup:IsTransporting() then
|
elseif opsgroup:IsTransporting() then
|
||||||
|
|
||||||
opsgroup:FullStop()
|
if opsgroup.isFlightgroup then
|
||||||
|
|
||||||
|
env.info("FF passing waypointg in state istransporting ==> land at")
|
||||||
|
|
||||||
opsgroup:Deploy()
|
-- Land at current pos and wait for 60 min max.
|
||||||
|
opsgroup:LandAt(opsgroup:GetCoordinate(), 60*60)
|
||||||
|
|
||||||
|
else
|
||||||
|
-- Stop and loading.
|
||||||
|
opsgroup:FullStop()
|
||||||
|
opsgroup:Deploy()
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif opsgroup:IsBoarding() then
|
||||||
|
|
||||||
|
if opsgroup.carrierGroup and opsgroup.carrierGroup:IsAlive() then
|
||||||
|
|
||||||
|
if opsgroup.carrier and opsgroup.carrier.unit and opsgroup.carrier.unit:IsAlive() then
|
||||||
|
|
||||||
|
-- Load group into the carrier.
|
||||||
|
opsgroup.carrierGroup:Load(opsgroup)
|
||||||
|
|
||||||
|
else
|
||||||
|
opsgroup:E(opsgroup.lid.."ERROR: Group cannot board assigned carrier UNIT as it is NOT alive!")
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
opsgroup:E(opsgroup.lid.."ERROR: Group cannot board assigned carrier GROUP as it is NOT alive!")
|
||||||
|
end
|
||||||
|
|
||||||
elseif opsgroup:IsEngaging() then
|
elseif opsgroup:IsEngaging() then
|
||||||
|
|
||||||
@@ -6644,7 +6908,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
|
|||||||
---
|
---
|
||||||
|
|
||||||
if self:_AllSimilarStatus(newstatus) then
|
if self:_AllSimilarStatus(newstatus) then
|
||||||
self:__InUtero(-0.5)
|
self:InUtero()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif newstatus==OPSGROUP.ElementStatus.SPAWNED then
|
elseif newstatus==OPSGROUP.ElementStatus.SPAWNED then
|
||||||
@@ -6761,13 +7025,17 @@ end
|
|||||||
-- @return #OPSGROUP.Element The element.
|
-- @return #OPSGROUP.Element The element.
|
||||||
function OPSGROUP:GetElementByName(unitname)
|
function OPSGROUP:GetElementByName(unitname)
|
||||||
|
|
||||||
for _,_element in pairs(self.elements) do
|
if unitname and type(unitname)=="string" then
|
||||||
local element=_element --#OPSGROUP.Element
|
|
||||||
|
|
||||||
if element.name==unitname then
|
for _,_element in pairs(self.elements) do
|
||||||
return element
|
local element=_element --#OPSGROUP.Element
|
||||||
|
|
||||||
|
if element.name==unitname then
|
||||||
|
return element
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -7117,7 +7385,7 @@ function OPSGROUP:_AddElementByName(unitname)
|
|||||||
|
|
||||||
-- Weight and cargo.
|
-- Weight and cargo.
|
||||||
element.weightEmpty=element.descriptors.massEmpty or 666
|
element.weightEmpty=element.descriptors.massEmpty or 666
|
||||||
element.weightMaxTotal=element.descriptors.massMax or element.weightEmpty+10*95 --If max mass is not given, we assume 10 soldiers.
|
element.weightMaxTotal=element.descriptors.massMax or element.weightEmpty+2*95 --If max mass is not given, we assume 10 soldiers.
|
||||||
element.weightMaxCargo=math.max(element.weightMaxTotal-element.weightEmpty, 0)
|
element.weightMaxCargo=math.max(element.weightMaxTotal-element.weightEmpty, 0)
|
||||||
element.weightCargo=0
|
element.weightCargo=0
|
||||||
element.weight=element.weightEmpty+element.weightCargo
|
element.weight=element.weightEmpty+element.weightCargo
|
||||||
|
|||||||
Reference in New Issue
Block a user