- Improved transport path
This commit is contained in:
Frank 2021-11-07 16:03:44 +01:00
parent 7a2508bf17
commit fb4caf1a42
5 changed files with 136 additions and 93 deletions

View File

@ -349,7 +349,6 @@ RANGE.Defaults={
boxlength=3000, boxlength=3000,
boxwidth=300, boxwidth=300,
goodpass=20, goodpass=20,
goodhitrange=25,
foulline=610, foulline=610,
} }
@ -2570,7 +2569,7 @@ function RANGE:_DisplayBombTargets(_unitname)
end end
end end
self:_DisplayMessageToGroup(_unit,_text, 60, true, true) self:_DisplayMessageToGroup(_unit,_text, 120, true, true)
end end
end end

View File

@ -946,13 +946,12 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
-- Debug output. -- Debug output.
if self.verbose>=0 then if self.verbose>=10 then
for i,_wp in pairs(waypoints) do for i,_wp in pairs(waypoints) do
local wp=_wp --Ops.OpsGroup#OPSGROUP.Waypoint local wp=_wp --Ops.OpsGroup#OPSGROUP.Waypoint
local text=string.format("WP #%d UID=%d type=%s: Speed=%d m/s, alt=%d m, Action=%s", i, wp.uid and wp.uid or -1, wp.type, wp.speed, wp.alt, wp.action) local text=string.format("WP #%d UID=%d type=%s: Speed=%d m/s, alt=%d m, Action=%s", i, wp.uid and wp.uid or -1, wp.type, wp.speed, wp.alt, wp.action)
local coord=COORDINATE:NewFromWaypoint(wp):MarkToAll(text) local coord=COORDINATE:NewFromWaypoint(wp):MarkToAll(text)
--wp.coordinate:MarkToAll(text) self:I(text)
self:T(text)
end end
end end

View File

@ -1677,6 +1677,7 @@ function FLIGHTGROUP:onafterCruise(From, Event, To)
-- AI -- AI
--- ---
--[[
if self:IsTransporting() then if self:IsTransporting() then
if self.cargoTransport and self.cargoTZC and self.cargoTZC.DeployAirbase then if self.cargoTransport and self.cargoTZC and self.cargoTZC.DeployAirbase then
self:LandAtAirbase(self.cargoTZC.DeployAirbase) self:LandAtAirbase(self.cargoTZC.DeployAirbase)
@ -1688,6 +1689,9 @@ function FLIGHTGROUP:onafterCruise(From, Event, To)
else else
self:_CheckGroupDone(nil, 120) self:_CheckGroupDone(nil, 120)
end end
]]
self:_CheckGroupDone(nil, 120)
else else

View File

@ -7133,10 +7133,15 @@ function OPSGROUP:onafterPickup(From, Event, To)
end end
-- 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(nil, nil, surfacetypes) local Coordinate=Zone:GetRandomCoordinate(nil, nil, surfacetypes)
--Coordinate:MarkToAll(string.format("Pickup coordinate for group %s [Surface type=%d]", self:GetName(), Coordinate:GetSurfaceType())) --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
-- Add waypoint. -- Add waypoint.
if self:IsFlightgroup() then if self:IsFlightgroup() then
@ -7155,8 +7160,33 @@ function OPSGROUP:onafterPickup(From, Event, To)
-- Pickup at airbase -- Pickup at airbase
--- ---
-- Order group to land at an airbase. -- Get a (random) pre-defined transport path.
self:__LandAtAirbase(-0.1, airbasePickup) local path=self.cargoTransport:_GetPathTransport(self.category, self.cargoTZC)
-- Get transport path.
if path and oldstatus~=OPSGROUP.CarrierStatus.NOTCARRIER then
for i=#path.waypoints,1,-1 do
local wp=path.waypoints[i]
local coordinate=COORDINATE:NewFromWaypoint(wp)
local waypoint=FLIGHTGROUP.AddWaypoint(self, coordinate, nil, uid, nil, false) ; waypoint.temp=true
uid=waypoint.uid
if i==1 then
waypoint.temp=false
waypoint.detour=1 --Needs to trigger the landatairbase function.
end
end
else
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
end
elseif self.isHelo then elseif self.isHelo then
@ -7165,7 +7195,7 @@ function OPSGROUP:onafterPickup(From, Event, To)
--- ---
-- If this is a helo and no ZONE_AIRBASE was given, we make the helo land in the pickup zone. -- 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 else
self:E(self.lid.."ERROR: Transportcarrier aircraft cannot land in Pickup zone! Specify a ZONE_AIRBASE as pickup zone") self:E(self.lid.."ERROR: Transportcarrier aircraft cannot land in Pickup zone! Specify a ZONE_AIRBASE as pickup zone")
@ -7179,7 +7209,11 @@ function OPSGROUP:onafterPickup(From, Event, To)
else else
self:E(self.lid.."ERROR: No current task but landed at?!") self:E(self.lid.."ERROR: No current task but landed at?!")
end end
end end
if self:IsWaiting() then
self:__Cruise(-2)
end
elseif self:IsNavygroup() then elseif self:IsNavygroup() then
@ -7187,29 +7221,17 @@ function OPSGROUP:onafterPickup(From, Event, To)
-- Navy Group -- Navy Group
--- ---
local cwp=self:GetWaypointCurrent()
local uid=cwp and cwp.uid or nil
-- Get a (random) pre-defined transport path. -- Get a (random) pre-defined transport path.
local path=self.cargoTransport:_GetPathPickup(self.category, self.cargoTZC) local path=self.cargoTransport:_GetPathTransport(self.category, self.cargoTZC)
-- Get transport path. -- Get transport path.
if path and oldstatus~=OPSGROUP.CarrierStatus.NOTCARRIER then if path then --and oldstatus~=OPSGROUP.CarrierStatus.NOTCARRIER then
if path.reverse then for i=#path.waypoints,1,-1 do
for i=#path.waypoints,1,-1 do local wp=path.waypoints[i]
local wp=path.waypoints[i] local coordinate=COORDINATE:NewFromWaypoint(wp)
local coordinate=COORDINATE:NewFromWaypoint(wp) local waypoint=NAVYGROUP.AddWaypoint(self, coordinate, nil, uid, nil, false) ; waypoint.temp=true
local waypoint=NAVYGROUP.AddWaypoint(self, coordinate, nil, uid, nil, false) ; waypoint.temp=true uid=waypoint.uid
uid=waypoint.uid end
end
else
for i=1,#path.waypoints do
local wp=path.waypoints[i]
local coordinate=COORDINATE:NewFromWaypoint(wp)
local waypoint=NAVYGROUP.AddWaypoint(self, coordinate, nil, uid, nil, false) ; waypoint.temp=true
uid=waypoint.uid
end
end
end end
-- NAVYGROUP -- NAVYGROUP
@ -7223,34 +7245,22 @@ function OPSGROUP:onafterPickup(From, Event, To)
--- ---
-- Army Group -- Army Group
--- ---
local cwp=self:GetWaypointCurrent()
local uid=cwp and cwp.uid or nil
-- Get a (random) pre-defined transport path. -- Get a (random) pre-defined transport path.
local path=self.cargoTransport:_GetPathPickup(self.category, self.cargoTZC) local path=self.cargoTransport:_GetPathTransport(self.category, self.cargoTZC)
-- Formation used to go to the pickup zone.. -- Formation used to go to the pickup zone..
local Formation=self.cargoTransport:_GetFormationPickup(self.cargoTZC) local Formation=self.cargoTransport:_GetFormationTransport(self.cargoTZC)
-- Get transport path. -- Get transport path.
if path then if path and oldstatus~=OPSGROUP.CarrierStatus.NOTCARRIER then
if path.reverse then for i=#path.waypoints,1,-1 do
for i=#path.waypoints,1,-1 do local wp=path.waypoints[i]
local wp=path.waypoints[i] local coordinate=COORDINATE:NewFromWaypoint(wp)
local coordinate=COORDINATE:NewFromWaypoint(wp) local waypoint=ARMYGROUP.AddWaypoint(self, coordinate, nil, uid, wp.action, false) ; waypoint.temp=true
local waypoint=ARMYGROUP.AddWaypoint(self, coordinate, nil, uid, wp.action, false) ; waypoint.temp=true uid=waypoint.uid
uid=waypoint.uid end
end
else
for i=1,#path.waypoints do
local wp=path.waypoints[i]
local coordinate=COORDINATE:NewFromWaypoint(wp)
local waypoint=ARMYGROUP.AddWaypoint(self, coordinate, nil, uid, wp.action, false) ; waypoint.temp=true
uid=waypoint.uid
end
end
end end
-- ARMYGROUP -- ARMYGROUP
@ -7537,9 +7547,40 @@ function OPSGROUP:onafterTransport(From, Event, To)
--- ---
-- Deploy at airbase -- 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)
-- Get transport path.
if path then
for i=1, #path.waypoints do
local wp=path.waypoints[i]
local coordinate=COORDINATE:NewFromWaypoint(wp)
local waypoint=FLIGHTGROUP.AddWaypoint(self, coordinate, nil, uid, nil, false) ; waypoint.temp=true
uid=waypoint.uid
if i==#path.waypoints then
waypoint.temp=false
waypoint.detour=1 --Needs to trigger the landatairbase function.
end
end
else
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. -- Order group to land at an airbase.
self:__LandAtAirbase(-0.1, airbaseDeploy) --self:__LandAtAirbase(-0.1, airbaseDeploy)
elseif self.isHelo then elseif self.isHelo then
@ -7577,22 +7618,11 @@ function OPSGROUP:onafterTransport(From, Event, To)
-- Get transport path. -- Get transport path.
if path then if path then
env.info("FF 100") for i=1,#path.waypoints do
if path.reverse then local wp=path.waypoints[i]
for i=#path.waypoints,1,-1 do local coordinate=COORDINATE:NewFromWaypoint(wp)
local wp=path.waypoints[i] local waypoint=ARMYGROUP.AddWaypoint(self, coordinate, nil, uid, wp.action, false) ; waypoint.temp=true
local coordinate=COORDINATE:NewFromWaypoint(wp) uid=waypoint.uid
local waypoint=ARMYGROUP.AddWaypoint(self, coordinate, nil, uid, wp.action, false) ; waypoint.temp=true
uid=waypoint.uid
end
else
for i=1,#path.waypoints do
local wp=path.waypoints[i]
local coordinate=COORDINATE:NewFromWaypoint(wp)
coordinate:MarkToAll("Path")
local waypoint=ARMYGROUP.AddWaypoint(self, coordinate, nil, uid, wp.action, false) ; waypoint.temp=true
uid=waypoint.uid
end
end end
end end
@ -7612,25 +7642,16 @@ function OPSGROUP:onafterTransport(From, Event, To)
-- Get transport path. -- Get transport path.
if path then if path then
if path.reverse then for i=1,#path.waypoints do
for i=#path.waypoints,1,-1 do local wp=path.waypoints[i]
local wp=path.waypoints[i] local coordinate=COORDINATE:NewFromWaypoint(wp)
local coordinate=COORDINATE:NewFromWaypoint(wp) local waypoint=NAVYGROUP.AddWaypoint(self, coordinate, nil, uid, nil, false) ; waypoint.temp=true
local waypoint=NAVYGROUP.AddWaypoint(self, coordinate, nil, uid) ; waypoint.temp=true uid=waypoint.uid
uid=waypoint.uid
end
else
for i=1,#path.waypoints do
local wp=path.waypoints[i]
local coordinate=COORDINATE:NewFromWaypoint(wp)
local waypoint=NAVYGROUP.AddWaypoint(self, coordinate, nil, uid) ; waypoint.temp=true
uid=waypoint.uid
end
end end
end end
-- NAVYGROUP -- NAVYGROUP
local waypoint=NAVYGROUP.AddWaypoint(self, Coordinate, nil, uid, self.altitudeCruise) ; waypoint.detour=1 local waypoint=NAVYGROUP.AddWaypoint(self, Coordinate, nil, uid, self.altitudeCruise, false) ; waypoint.detour=1
-- Give cruise command. -- Give cruise command.
self:Cruise() self:Cruise()
@ -9242,13 +9263,23 @@ function OPSGROUP._PassingWaypoint(opsgroup, uid)
if opsgroup:IsFlightgroup() then if opsgroup:IsFlightgroup() then
-- Land at current pos and wait for 60 min max. -- Land at current pos and wait for 60 min max.
local coordinate=nil
if opsgroup.cargoTZC then if opsgroup.cargoTZC then
coordinate=opsgroup.cargoTZC.PickupZone:GetRandomCoordinate(nil, nil, {land.SurfaceType.LAND})
if opsgroup.cargoTZC.PickupAirbase then
-- Pickup airbase specified. Land there.
env.info(opsgroup.lid.."FF Land at Pickup Airbase")
opsgroup:LandAtAirbase(opsgroup.cargoTZC.PickupAirbase)
else
-- Land somewhere in the pickup zone. Only helos can do that.
local coordinate=opsgroup.cargoTZC.PickupZone:GetRandomCoordinate(nil, nil, {land.SurfaceType.LAND})
opsgroup:LandAt(coordinate, 60*60)
end
else else
coordinate=opsgroup:GetCoordinate() local coordinate=opsgroup:GetCoordinate()
opsgroup:LandAt(coordinate, 60*60)
end end
opsgroup:LandAt(coordinate, 60*60)
else else
@ -9263,13 +9294,23 @@ function OPSGROUP._PassingWaypoint(opsgroup, uid)
if opsgroup:IsFlightgroup() then if opsgroup:IsFlightgroup() then
-- Land at current pos and wait for 60 min max. -- Land at current pos and wait for 60 min max.
local coordinate=nil
if opsgroup.cargoTZC then if opsgroup.cargoTZC then
coordinate=opsgroup.cargoTZC.DeployZone:GetRandomCoordinate(nil, nil, {land.SurfaceType.LAND})
if opsgroup.cargoTZC.DeployAirbase then
-- Pickup airbase specified. Land there.
env.info(opsgroup.lid.."FF Land at Deploy Airbase")
opsgroup:LandAtAirbase(opsgroup.cargoTZC.DeployAirbase)
else
-- Land somewhere in the pickup zone. Only helos can do that.
local coordinate=opsgroup.cargoTZC.DeployZone:GetRandomCoordinate(nil, nil, {land.SurfaceType.LAND})
opsgroup:LandAt(coordinate, 60*60)
end
else else
coordinate=opsgroup:GetCoordinate() coordinate=opsgroup:GetCoordinate()
opsgroup:LandAt(coordinate, 60*60)
end end
opsgroup:LandAt(coordinate, 60*60)
else else
-- Stop and unload. -- Stop and unload.

View File

@ -750,7 +750,7 @@ routines.groupRandomDistSelf = function(gpData, dist, form, heading, speed)
local pos = routines.getLeadPos(gpData) local pos = routines.getLeadPos(gpData)
local fakeZone = {} local fakeZone = {}
fakeZone.radius = dist or math.random(300, 1000) fakeZone.radius = dist or math.random(300, 1000)
fakeZone.point = {x = pos.x, y, pos.y, z = pos.z} fakeZone.point = {x = pos.x, y = pos.y, z = pos.z}
routines.groupToRandomZone(gpData, fakeZone, form, heading, speed) routines.groupToRandomZone(gpData, fakeZone, form, heading, speed)
return return