ARMYGROUP

- Fixed opstransport not being readded to brigade
This commit is contained in:
Frank 2022-10-31 20:50:35 +01:00
parent 3f8efae23f
commit d4b5e24364
2 changed files with 130 additions and 66 deletions

View File

@ -1071,6 +1071,15 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
-- Next waypoint. -- Next waypoint.
local wp=self.waypoints[n] --Ops.OpsGroup#OPSGROUP.Waypoint local wp=self.waypoints[n] --Ops.OpsGroup#OPSGROUP.Waypoint
-- Current position.
local coordinate=self:GetCoordinate()
-- Road coordinate.
local coordRoad=coordinate:GetClosestPointToRoad()
-- Road distance.
local roaddist=coordinate:Get2DDistance(coordRoad)
-- Formation at the current position. -- Formation at the current position.
local formation0=wp.action local formation0=wp.action
if formation0==ENUMS.Formation.Vehicle.OnRoad then if formation0==ENUMS.Formation.Vehicle.OnRoad then
@ -1084,9 +1093,12 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
end end
-- Current point. -- Current point.
local current=self:GetCoordinate():WaypointGround(UTILS.MpsToKmph(self.speedWp), formation0) --ENUMS.Formation.Vehicle.OffRoad) local current=coordinate:WaypointGround(UTILS.MpsToKmph(self.speedWp), formation0) --ENUMS.Formation.Vehicle.OffRoad)
table.insert(waypoints, 1, current) table.insert(waypoints, 1, current)
-- Check if route consists of more than one waypoint.
if N-n>0 then
-- Loop over waypoints. -- Loop over waypoints.
for j=n, N do for j=n, N do
@ -1104,8 +1116,11 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
-- Previous waypoint. Index is i and not i-1 because we added the current position. -- Previous waypoint. Index is i and not i-1 because we added the current position.
local wp0=self.waypoints[i] --Ops.OpsGroup#OPSGROUP.Waypoint local wp0=self.waypoints[i] --Ops.OpsGroup#OPSGROUP.Waypoint
--local text=string.format("FF Update: i=%d, wp[i]=%s, wp[i-1]=%s", i, wp.action, wp0.action) -- Debug
--env.info(text) if false and self.attribute==GROUP.Attribute.GROUND_APC then
local text=string.format("FF Update: i=%d, wp[i]=%s, wp[i-1]=%s", i, wp.action, wp0.action)
env.info(text)
end
-- Speed. -- Speed.
if Speed then if Speed then
@ -1127,8 +1142,6 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
-- Add waypoint in between because this waypoint is "On Road" but lies "Off Road". -- Add waypoint in between because this waypoint is "On Road" but lies "Off Road".
if wp.action==ENUMS.Formation.Vehicle.OnRoad and wp0.roaddist>=0 then if wp.action==ENUMS.Formation.Vehicle.OnRoad and wp0.roaddist>=0 then
--env.info("FF adding waypoint0 on road #"..i)
-- Add "On Road" waypoint in between. -- Add "On Road" waypoint in between.
local wproad=wp0.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint local wproad=wp0.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
@ -1139,8 +1152,6 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
-- Add waypoint in between because this waypoint is "On Road" but lies "Off Road". -- Add waypoint in between because this waypoint is "On Road" but lies "Off Road".
if wp.action==ENUMS.Formation.Vehicle.OnRoad and wp.roaddist>=0 then if wp.action==ENUMS.Formation.Vehicle.OnRoad and wp.roaddist>=0 then
--env.info("FF adding waypoint on road #"..i)
-- The real waypoint is actually off road. -- The real waypoint is actually off road.
wp.action=ENUMS.Formation.Vehicle.OffRoad wp.action=ENUMS.Formation.Vehicle.OffRoad
@ -1156,6 +1167,59 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
table.insert(waypoints, wp) table.insert(waypoints, wp)
end end
else
---
-- This is the case, where we have only one WP left.
-- Could be because we had only one WP and did a detour (temp waypoint, which was deleted).
---
-- Next waypoint.
local wp=UTILS.DeepCopy(self.waypoints[n]) --Ops.OpsGroup#OPSGROUP.Waypoint
-- Speed.
if wp.speed<0.1 then
wp.speed=UTILS.KmphToMps(self.speedCruise)
end
-- Formation.
local formation=wp.action
if self.formationPerma then
formation=self.formationPerma
elseif Formation then
formation=Formation
end
-- Add road waypoint.
if formation==ENUMS.Formation.Vehicle.OnRoad then
if roaddist>10 then
-- Add "On Road" waypoint in between.
local wproad=coordRoad:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
-- Insert road waypoint.
table.insert(waypoints, wproad)
end
if wp.roaddist>10 then
-- Add "On Road" waypoint in between.
local wproad=wp.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
-- Insert road waypoint.
table.insert(waypoints, wproad)
end
end
-- Add actual waypoint.
table.insert(waypoints, wp)
end
-- First (next wp). -- First (next wp).
local wp=waypoints[1] --Ops.OpsGroup#OPSGROUP.Waypoint local wp=waypoints[1] --Ops.OpsGroup#OPSGROUP.Waypoint
@ -1166,7 +1230,7 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
self.speedWp=wp.speed self.speedWp=wp.speed
-- Debug output. -- Debug output.
if self.verbose>=10 then if self.verbose>=10 or self.attribute==GROUP.Attribute.GROUND_APC 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

View File

@ -8626,7 +8626,7 @@ function OPSGROUP:onafterPickup(From, Event, To)
local path=self.cargoTransport:_GetPathTransport(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:_GetFormationTransport(self.cargoTZC) local Formation=self.cargoTransport:_GetFormationPickup(self.cargoTZC)
-- Get transport path. -- Get transport path.
if path and oldstatus~=OPSGROUP.CarrierStatus.NOTCARRIER then if path and oldstatus~=OPSGROUP.CarrierStatus.NOTCARRIER then
@ -9444,7 +9444,7 @@ function OPSGROUP:onafterDelivered(From, Event, To, CargoTransport)
end end
else else
-- Army & Navy: give Cruise command to "wake up" from waiting status. -- Army & Navy: give Cruise command to "wake up" from waiting status.
self:__Cruise(0.1) self:__Cruise(-0.1)
end end
-- Set carrier transport status. -- Set carrier transport status.
@ -9869,14 +9869,14 @@ function OPSGROUP:_CheckGroupDone(delay)
if delay and delay>0 then if delay and delay>0 then
-- Debug info. -- Debug info.
self:T(self.lid..string.format("Check OPSGROUP [state=%s] done in %.3f seconds...", fsmstate, delay)) self:T(self.lid..string.format("Check OPSGROUP done? [state=%s] in %.3f seconds...", fsmstate, delay))
-- Delayed call. -- Delayed call.
self:ScheduleOnce(delay, self._CheckGroupDone, self) self:ScheduleOnce(delay, self._CheckGroupDone, self)
else else
-- Debug info. -- Debug info.
self:T(self.lid..string.format("Check OSGROUP [state=%s] done?", fsmstate)) self:T(self.lid..string.format("Check OSGROUP done? [state=%s]", fsmstate))
-- Group is engaging something. -- Group is engaging something.
if self:IsEngaging() then if self:IsEngaging() then