mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
- Improved transport path
This commit is contained in:
parent
7a2508bf17
commit
fb4caf1a42
@ -349,7 +349,6 @@ RANGE.Defaults={
|
||||
boxlength=3000,
|
||||
boxwidth=300,
|
||||
goodpass=20,
|
||||
goodhitrange=25,
|
||||
foulline=610,
|
||||
}
|
||||
|
||||
@ -2570,7 +2569,7 @@ function RANGE:_DisplayBombTargets(_unitname)
|
||||
end
|
||||
end
|
||||
|
||||
self:_DisplayMessageToGroup(_unit,_text, 60, true, true)
|
||||
self:_DisplayMessageToGroup(_unit,_text, 120, true, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -946,13 +946,12 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
||||
|
||||
|
||||
-- Debug output.
|
||||
if self.verbose>=0 then
|
||||
if self.verbose>=10 then
|
||||
for i,_wp in pairs(waypoints) do
|
||||
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 coord=COORDINATE:NewFromWaypoint(wp):MarkToAll(text)
|
||||
--wp.coordinate:MarkToAll(text)
|
||||
self:T(text)
|
||||
self:I(text)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1677,6 +1677,7 @@ function FLIGHTGROUP:onafterCruise(From, Event, To)
|
||||
-- AI
|
||||
---
|
||||
|
||||
--[[
|
||||
if self:IsTransporting() then
|
||||
if self.cargoTransport and self.cargoTZC and self.cargoTZC.DeployAirbase then
|
||||
self:LandAtAirbase(self.cargoTZC.DeployAirbase)
|
||||
@ -1688,6 +1689,9 @@ function FLIGHTGROUP:onafterCruise(From, Event, To)
|
||||
else
|
||||
self:_CheckGroupDone(nil, 120)
|
||||
end
|
||||
]]
|
||||
|
||||
self:_CheckGroupDone(nil, 120)
|
||||
|
||||
else
|
||||
|
||||
|
||||
@ -7133,10 +7133,15 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
||||
end
|
||||
|
||||
-- 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()))
|
||||
|
||||
-- Current Waypoint.
|
||||
local cwp=self:GetWaypointCurrent()
|
||||
|
||||
-- Current waypoint ID.
|
||||
local uid=cwp and cwp.uid or nil
|
||||
|
||||
-- Add waypoint.
|
||||
if self:IsFlightgroup() then
|
||||
|
||||
@ -7155,8 +7160,33 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
||||
-- Pickup at airbase
|
||||
---
|
||||
|
||||
-- Order group to land at an airbase.
|
||||
self:__LandAtAirbase(-0.1, airbasePickup)
|
||||
-- Get a (random) pre-defined transport path.
|
||||
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
|
||||
|
||||
@ -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.
|
||||
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: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
|
||||
self:E(self.lid.."ERROR: No current task but landed at?!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self:IsWaiting() then
|
||||
self:__Cruise(-2)
|
||||
end
|
||||
|
||||
elseif self:IsNavygroup() then
|
||||
|
||||
@ -7187,29 +7221,17 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
||||
-- Navy Group
|
||||
---
|
||||
|
||||
local cwp=self:GetWaypointCurrent()
|
||||
local uid=cwp and cwp.uid or nil
|
||||
|
||||
-- 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.
|
||||
if path and oldstatus~=OPSGROUP.CarrierStatus.NOTCARRIER then
|
||||
if path.reverse then
|
||||
for i=#path.waypoints,1,-1 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
|
||||
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
|
||||
if path then --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=NAVYGROUP.AddWaypoint(self, coordinate, nil, uid, nil, false) ; waypoint.temp=true
|
||||
uid=waypoint.uid
|
||||
end
|
||||
end
|
||||
|
||||
-- NAVYGROUP
|
||||
@ -7223,34 +7245,22 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
||||
|
||||
---
|
||||
-- Army Group
|
||||
---
|
||||
|
||||
local cwp=self:GetWaypointCurrent()
|
||||
local uid=cwp and cwp.uid or nil
|
||||
---
|
||||
|
||||
-- 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..
|
||||
local Formation=self.cargoTransport:_GetFormationPickup(self.cargoTZC)
|
||||
local Formation=self.cargoTransport:_GetFormationTransport(self.cargoTZC)
|
||||
|
||||
-- Get transport path.
|
||||
if path then
|
||||
if path.reverse then
|
||||
for i=#path.waypoints,1,-1 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
|
||||
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
|
||||
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=ARMYGROUP.AddWaypoint(self, coordinate, nil, uid, wp.action, false) ; waypoint.temp=true
|
||||
uid=waypoint.uid
|
||||
end
|
||||
end
|
||||
|
||||
-- ARMYGROUP
|
||||
@ -7537,9 +7547,40 @@ 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)
|
||||
|
||||
-- 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.
|
||||
self:__LandAtAirbase(-0.1, airbaseDeploy)
|
||||
--self:__LandAtAirbase(-0.1, airbaseDeploy)
|
||||
|
||||
elseif self.isHelo then
|
||||
|
||||
@ -7577,22 +7618,11 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
||||
|
||||
-- Get transport path.
|
||||
if path then
|
||||
env.info("FF 100")
|
||||
if path.reverse then
|
||||
for i=#path.waypoints,1,-1 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
|
||||
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
|
||||
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
|
||||
|
||||
@ -7612,25 +7642,16 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
||||
|
||||
-- Get transport path.
|
||||
if path then
|
||||
if path.reverse then
|
||||
for i=#path.waypoints,1,-1 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
|
||||
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
|
||||
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
|
||||
|
||||
-- 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.
|
||||
self:Cruise()
|
||||
@ -9242,13 +9263,23 @@ function OPSGROUP._PassingWaypoint(opsgroup, uid)
|
||||
if opsgroup:IsFlightgroup() then
|
||||
|
||||
-- Land at current pos and wait for 60 min max.
|
||||
local coordinate=nil
|
||||
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
|
||||
coordinate=opsgroup:GetCoordinate()
|
||||
local coordinate=opsgroup:GetCoordinate()
|
||||
opsgroup:LandAt(coordinate, 60*60)
|
||||
end
|
||||
opsgroup:LandAt(coordinate, 60*60)
|
||||
|
||||
|
||||
else
|
||||
|
||||
@ -9263,13 +9294,23 @@ function OPSGROUP._PassingWaypoint(opsgroup, uid)
|
||||
if opsgroup:IsFlightgroup() then
|
||||
|
||||
-- Land at current pos and wait for 60 min max.
|
||||
local coordinate=nil
|
||||
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
|
||||
coordinate=opsgroup:GetCoordinate()
|
||||
opsgroup:LandAt(coordinate, 60*60)
|
||||
end
|
||||
opsgroup:LandAt(coordinate, 60*60)
|
||||
|
||||
|
||||
else
|
||||
-- Stop and unload.
|
||||
|
||||
@ -750,7 +750,7 @@ routines.groupRandomDistSelf = function(gpData, dist, form, heading, speed)
|
||||
local pos = routines.getLeadPos(gpData)
|
||||
local fakeZone = {}
|
||||
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)
|
||||
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user