mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
ARMYGROUP
- Fixed opstransport not being readded to brigade
This commit is contained in:
parent
3f8efae23f
commit
d4b5e24364
@ -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,76 +1093,131 @@ 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)
|
||||||
|
|
||||||
-- Loop over waypoints.
|
-- Check if route consists of more than one waypoint.
|
||||||
for j=n, N do
|
if N-n>0 then
|
||||||
|
|
||||||
-- Index of previous waypoint.
|
-- Loop over waypoints.
|
||||||
local i=j-1
|
for j=n, N do
|
||||||
|
|
||||||
-- If we go to the first waypoint j=1 ==> i=0, so we take the last waypoint passed. E.g. when adinfinitum and passed final waypoint.
|
-- Index of previous waypoint.
|
||||||
if i==0 then
|
local i=j-1
|
||||||
i=self.currentwp
|
|
||||||
|
-- If we go to the first waypoint j=1 ==> i=0, so we take the last waypoint passed. E.g. when adinfinitum and passed final waypoint.
|
||||||
|
if i==0 then
|
||||||
|
i=self.currentwp
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Next waypoint.
|
||||||
|
local wp=UTILS.DeepCopy(self.waypoints[j]) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
|
-- Previous waypoint. Index is i and not i-1 because we added the current position.
|
||||||
|
local wp0=self.waypoints[i] --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
|
-- Debug
|
||||||
|
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.
|
||||||
|
if Speed then
|
||||||
|
wp.speed=UTILS.KnotsToMps(tonumber(Speed))
|
||||||
|
else
|
||||||
|
-- Take default waypoint speed. But make sure speed>0 if patrol ad infinitum.
|
||||||
|
if wp.speed<0.1 then
|
||||||
|
wp.speed=UTILS.KmphToMps(self.speedCruise)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Formation.
|
||||||
|
if self.formationPerma then
|
||||||
|
wp.action=self.formationPerma
|
||||||
|
elseif Formation then
|
||||||
|
wp.action=Formation
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
-- Add "On Road" waypoint in between.
|
||||||
|
local wproad=wp0.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
|
-- Insert road waypoint.
|
||||||
|
table.insert(waypoints, wproad)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
-- The real waypoint is actually off road.
|
||||||
|
wp.action=ENUMS.Formation.Vehicle.OffRoad
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
|
||||||
|
-- Add waypoint.
|
||||||
|
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.
|
-- Next waypoint.
|
||||||
local wp=UTILS.DeepCopy(self.waypoints[j]) --Ops.OpsGroup#OPSGROUP.Waypoint
|
local wp=UTILS.DeepCopy(self.waypoints[n]) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
-- 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 text=string.format("FF Update: i=%d, wp[i]=%s, wp[i-1]=%s", i, wp.action, wp0.action)
|
|
||||||
--env.info(text)
|
|
||||||
|
|
||||||
-- Speed.
|
-- Speed.
|
||||||
if Speed then
|
if wp.speed<0.1 then
|
||||||
wp.speed=UTILS.KnotsToMps(tonumber(Speed))
|
wp.speed=UTILS.KmphToMps(self.speedCruise)
|
||||||
else
|
|
||||||
-- Take default waypoint speed. But make sure speed>0 if patrol ad infinitum.
|
|
||||||
if wp.speed<0.1 then
|
|
||||||
wp.speed=UTILS.KmphToMps(self.speedCruise)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Formation.
|
-- Formation.
|
||||||
|
local formation=wp.action
|
||||||
if self.formationPerma then
|
if self.formationPerma then
|
||||||
wp.action=self.formationPerma
|
formation=self.formationPerma
|
||||||
elseif Formation then
|
elseif Formation then
|
||||||
wp.action=Formation
|
formation=Formation
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add waypoint in between because this waypoint is "On Road" but lies "Off Road".
|
-- Add road waypoint.
|
||||||
if wp.action==ENUMS.Formation.Vehicle.OnRoad and wp0.roaddist>=0 then
|
if formation==ENUMS.Formation.Vehicle.OnRoad then
|
||||||
|
|
||||||
--env.info("FF adding waypoint0 on road #"..i)
|
if roaddist>10 then
|
||||||
|
|
||||||
-- 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=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
|
||||||
|
|
||||||
-- Insert road waypoint.
|
|
||||||
table.insert(waypoints, wproad)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add waypoint in between because this waypoint is "On Road" but lies "Off Road".
|
-- Add actual waypoint.
|
||||||
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.
|
|
||||||
wp.action=ENUMS.Formation.Vehicle.OffRoad
|
|
||||||
|
|
||||||
-- 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
|
|
||||||
|
|
||||||
|
|
||||||
-- Add waypoint.
|
|
||||||
table.insert(waypoints, wp)
|
table.insert(waypoints, wp)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- First (next wp).
|
-- First (next wp).
|
||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user