mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixes for OPSTRANSPOTRT formation
This commit is contained in:
parent
addb7ba36a
commit
d031651b58
@ -1190,6 +1190,8 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
||||
formation=Formation
|
||||
end
|
||||
|
||||
env.info(self.lid..string.format("FF Formation %s", formation))
|
||||
|
||||
-- Add road waypoint.
|
||||
if formation==ENUMS.Formation.Vehicle.OnRoad then
|
||||
|
||||
@ -1908,7 +1910,7 @@ end
|
||||
function ARMYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Formation, Updateroute)
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("AddWaypoint Formation = %s",tostring(Formation) or "none"))
|
||||
self:T(self.lid..string.format("AddWaypoint Formation = %s", tostring(Formation)))
|
||||
|
||||
-- Create coordinate.
|
||||
local coordinate=self:_CoordinateFromObject(Coordinate)
|
||||
@ -1926,8 +1928,10 @@ function ARMYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Formation
|
||||
elseif self.option.Formation then
|
||||
Formation = self.option.Formation
|
||||
else
|
||||
Formation = "On Road"
|
||||
-- Default formation is on road.
|
||||
Formation = ENUMS.Formation.Vehicle.OnRoad
|
||||
end
|
||||
self:T2(self.lid..string.format("Formation set to = %s", tostring(Formation)))
|
||||
end
|
||||
|
||||
-- Create a Ground waypoint.
|
||||
|
||||
@ -8509,13 +8509,9 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
||||
|
||||
-- Get a random coordinate in the pickup zone and let the carrier go there.
|
||||
local Coordinate=Zone:GetRandomCoordinate(nil, nil, surfacetypes)
|
||||
--Coordinate:MarkToAll(string.format("Pickup coordinate for group %s [Surface type=%d]", self:GetName(), Coordinate:GetSurfaceType()))
|
||||
|
||||
-- Current Waypoint.
|
||||
local cwp=self:GetWaypointCurrent()
|
||||
|
||||
-- Current waypoint ID.
|
||||
local uid=cwp and cwp.uid or nil
|
||||
local uid=self:GetWaypointCurrentUID()
|
||||
|
||||
-- Add waypoint.
|
||||
if self:IsFlightgroup() then
|
||||
@ -8556,8 +8552,6 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
||||
|
||||
local coordinate=self:GetCoordinate():GetIntermediateCoordinate(Coordinate, 0.5)
|
||||
|
||||
--coordinate:MarkToAll("Pickup Inter Coord")
|
||||
|
||||
-- If this is a helo and no ZONE_AIRBASE was given, we make the helo land in the pickup zone.
|
||||
local waypoint=FLIGHTGROUP.AddWaypoint(self, coordinate, nil, uid, UTILS.MetersToFeet(self.altitudeCruise), true) ; waypoint.detour=1
|
||||
|
||||
@ -8626,8 +8620,8 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
||||
local path=self.cargoTransport:_GetPathTransport(self.category, self.cargoTZC)
|
||||
|
||||
-- Formation used to go to the pickup zone..
|
||||
local Formation=self.cargoTransport:_GetFormationPickup(self.cargoTZC)
|
||||
|
||||
local Formation=self.cargoTransport:_GetFormationPickup(self.cargoTZC, self)
|
||||
|
||||
-- Get transport path.
|
||||
if path and oldstatus~=OPSGROUP.CarrierStatus.NOTCARRIER then
|
||||
for i=#path.waypoints,1,-1 do
|
||||
@ -8642,7 +8636,7 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
||||
local waypoint=ARMYGROUP.AddWaypoint(self, Coordinate, nil, uid, Formation, false) ; waypoint.detour=1
|
||||
|
||||
-- Give cruise command.
|
||||
self:__Cruise(-2)
|
||||
self:__Cruise(-2, nil, Formation)
|
||||
|
||||
end
|
||||
|
||||
@ -8927,7 +8921,8 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
||||
-- Coord where the carrier goes to unload.
|
||||
local Coordinate=Zone:GetRandomCoordinate(nil, nil, surfacetypes) --Core.Point#COORDINATE
|
||||
|
||||
--Coordinate:MarkToAll(string.format("Deploy coordinate for group %s [Surface type=%d]", self:GetName(), Coordinate:GetSurfaceType()))
|
||||
-- Current waypoint UID.
|
||||
local uid=self:GetWaypointCurrentUID()
|
||||
|
||||
-- Add waypoint.
|
||||
if self:IsFlightgroup() then
|
||||
@ -8943,9 +8938,6 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
||||
-- Deploy at airbase
|
||||
---
|
||||
|
||||
local cwp=self:GetWaypointCurrent()
|
||||
local uid=cwp and cwp.uid or nil
|
||||
|
||||
-- Get a (random) pre-defined transport path.
|
||||
local path=self.cargoTransport:_GetPathTransport(self.category, self.cargoTZC)
|
||||
|
||||
@ -8967,16 +8959,11 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
||||
|
||||
local coordinate=self:GetCoordinate():GetIntermediateCoordinate(Coordinate, 0.5)
|
||||
|
||||
--coordinate:MarkToAll("Transport Inter Waypoint")
|
||||
|
||||
-- If this is a helo and no ZONE_AIRBASE was given, we make the helo land in the pickup zone.
|
||||
local waypoint=FLIGHTGROUP.AddWaypoint(self, coordinate, nil, uid, UTILS.MetersToFeet(self.altitudeCruise), true) ; waypoint.detour=1
|
||||
|
||||
end
|
||||
|
||||
-- Order group to land at an airbase.
|
||||
--self:__LandAtAirbase(-0.1, airbaseDeploy)
|
||||
|
||||
elseif self.isHelo then
|
||||
|
||||
---
|
||||
@ -8984,7 +8971,7 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
||||
---
|
||||
|
||||
-- If this is a helo and no ZONE_AIRBASE was given, we make the helo land in the pickup zone.
|
||||
local waypoint=FLIGHTGROUP.AddWaypoint(self, Coordinate, nil, self:GetWaypointCurrent().uid, UTILS.MetersToFeet(self.altitudeCruise), false) ; waypoint.detour=1
|
||||
local waypoint=FLIGHTGROUP.AddWaypoint(self, Coordinate, nil, uid, UTILS.MetersToFeet(self.altitudeCruise), false) ; waypoint.detour=1
|
||||
|
||||
else
|
||||
self:T(self.lid.."ERROR: Aircraft (cargo carrier) cannot land in Deploy zone! Specify a ZONE_AIRBASE as deploy zone")
|
||||
@ -9002,14 +8989,11 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
||||
|
||||
elseif self:IsArmygroup() then
|
||||
|
||||
local cwp=self:GetWaypointCurrent()
|
||||
local uid=cwp and cwp.uid or nil
|
||||
|
||||
-- Get transport path.
|
||||
local path=self.cargoTransport:_GetPathTransport(self.category, self.cargoTZC)
|
||||
|
||||
-- Formation used for transporting.
|
||||
local Formation=self.cargoTransport:_GetFormationTransport(self.cargoTZC)
|
||||
local Formation=self.cargoTransport:_GetFormationTransport(self.cargoTZC, self)
|
||||
|
||||
-- Get transport path.
|
||||
if path then
|
||||
@ -9025,13 +9009,10 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
||||
local waypoint=ARMYGROUP.AddWaypoint(self, Coordinate, nil, uid, Formation, false) ; waypoint.detour=1
|
||||
|
||||
-- Give cruise command.
|
||||
self:Cruise()
|
||||
self:Cruise(nil, Formation)
|
||||
|
||||
elseif self:IsNavygroup() then
|
||||
|
||||
local cwp=self:GetWaypointCurrent()
|
||||
local uid=cwp and cwp.uid or nil
|
||||
|
||||
-- Get a (random) pre-defined transport path.
|
||||
local path=self.cargoTransport:_GetPathTransport(self.category, self.cargoTZC)
|
||||
|
||||
@ -10656,7 +10637,7 @@ function OPSGROUP._PassingWaypoint(opsgroup, uid)
|
||||
|
||||
-- Set formation.
|
||||
if opsgroup.isArmygroup then
|
||||
opsgroup.formation=wpnext.action
|
||||
opsgroup.option.Formation=wpnext.action
|
||||
end
|
||||
|
||||
-- Set speed to next wp.
|
||||
|
||||
@ -50,6 +50,10 @@
|
||||
-- @field #number NcarrierDead Total number of dead carrier groups
|
||||
-- @field #number NcargoDead Totalnumber of dead cargo groups.
|
||||
--
|
||||
-- @field #string formationArmy Default formation for ground vehicles.
|
||||
-- @field #string formationHelo Default formation for helicopters.
|
||||
-- @field #string formationPlane Default formation for airplanes.
|
||||
--
|
||||
-- @field Ops.Auftrag#AUFTRAG mission The mission attached to this transport.
|
||||
-- @field #table assets Warehouse assets assigned for this transport.
|
||||
-- @field #table legions Assigned legions.
|
||||
@ -235,6 +239,10 @@ function OPSTRANSPORT:New(CargoGroups, PickupZone, DeployZone)
|
||||
self:SetTime()
|
||||
self:SetRequiredCarriers()
|
||||
|
||||
self.formationArmy=ENUMS.Formation.Vehicle.OnRoad
|
||||
self.formationHelo=ENUMS.Formation.RotaryWing.Wedge
|
||||
self.formationPlane=ENUMS.Formation.FixedWing.Wedge
|
||||
|
||||
-- Init arrays and counters.
|
||||
self.carriers={}
|
||||
self.Ncargo=0
|
||||
@ -809,16 +817,44 @@ function OPSTRANSPORT:SetFormationPickup(Formation, TransportZoneCombo)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get pickup formation.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param Ops.OpsGroup#OPSGROUP OpsGroup
|
||||
-- @return #string Formation.
|
||||
function OPSTRANSPORT:_GetFormationDefault(OpsGroup)
|
||||
|
||||
if OpsGroup.isArmygroup then
|
||||
|
||||
return self.formationArmy
|
||||
|
||||
elseif OpsGroup.isFlightgroup then
|
||||
|
||||
if OpsGroup.isHelo then
|
||||
return self.formationHelo
|
||||
else
|
||||
return self.formationPlane
|
||||
end
|
||||
|
||||
else
|
||||
return ENUMS.Formation.Vehicle.OffRoad
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Get pickup formation.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||
-- @param Ops.OpsGroup#OPSGROUP OpsGroup
|
||||
-- @return #number Formation.
|
||||
function OPSTRANSPORT:_GetFormationPickup(TransportZoneCombo)
|
||||
function OPSTRANSPORT:_GetFormationPickup(TransportZoneCombo, OpsGroup)
|
||||
|
||||
-- Use default TZC if no transport zone combo is provided.
|
||||
TransportZoneCombo=TransportZoneCombo or self.tzcDefault
|
||||
|
||||
local formation=TransportZoneCombo.PickupFormation or self:_GetFormationDefault(OpsGroup)
|
||||
|
||||
return TransportZoneCombo.PickupFormation
|
||||
return formation
|
||||
end
|
||||
|
||||
--- Set transport formation.
|
||||
@ -839,13 +875,16 @@ end
|
||||
--- Get transport formation.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||
-- @param Ops.OpsGroup#OPSGROUP OpsGroup
|
||||
-- @return #number Formation.
|
||||
function OPSTRANSPORT:_GetFormationTransport(TransportZoneCombo)
|
||||
function OPSTRANSPORT:_GetFormationTransport(TransportZoneCombo, OpsGroup)
|
||||
|
||||
-- Use default TZC if no transport zone combo is provided.
|
||||
TransportZoneCombo=TransportZoneCombo or self.tzcDefault
|
||||
|
||||
local formation=TransportZoneCombo.TransportFormation or self:_GetFormationDefault(OpsGroup)
|
||||
|
||||
return TransportZoneCombo.TransportFormation
|
||||
return formation
|
||||
end
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user