diff --git a/Moose Development/Moose/AI/AI_Cargo_APC.lua b/Moose Development/Moose/AI/AI_Cargo_APC.lua index 0cb8aed9b..95a5ba04d 100644 --- a/Moose Development/Moose/AI/AI_Cargo_APC.lua +++ b/Moose Development/Moose/AI/AI_Cargo_APC.lua @@ -609,7 +609,7 @@ function AI_CARGO_APC:onafterPickup( APC, From, Event, To, Coordinate ) if Coordinate then self.RoutePickup = true - local Waypoints = APC:TaskGroundOnRoad( Coordinate, 150, "Line abreast" ) + local Waypoints = APC:TaskGroundOnRoad( Coordinate, APC:GetSpeedMax()*0.8, "Line abreast" ) local TaskFunction = APC:TaskFunction( "AI_CARGO_APC._Pickup", self ) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 04576498f..0318c6c47 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -1958,17 +1958,17 @@ do -- Route methods -- Route, ground waypoints along roads. local route={} - table.insert(route, FromCoordinate:WaypointGround(Speed, Formation)) + table.insert(route, FromCoordinate:WaypointGround(Speed, "Off Road")) -- Convert coordinates to ground waypoints and insert into table. for _, coord in ipairs(path) do - table.insert(route, coord:WaypointGround(Speed, Formation)) + table.insert(route, coord:WaypointGround(Speed, "On Road")) end -- Add the final coordinate because the final coordinate in path is last point on road. local dist=ToCoordinate:Get2DDistance(path[#path]) if dist>10 then - table.insert(route, ToCoordinate:WaypointGround(Speed, "Vee")) + table.insert(route, ToCoordinate:WaypointGround(Speed, "Off Road")) end -- Route controllable to destination. @@ -2059,7 +2059,7 @@ do -- Route methods PointFrom.y = ControllablePoint.y PointFrom.type = "Turning Point" PointFrom.action = Formation or "Cone" - PointFrom.speed = 20 / 1.6 + PointFrom.speed = 20 / 3.6 local PointTo = {} @@ -2084,7 +2084,7 @@ do -- Route methods if Speed then PointTo.speed = Speed else - PointTo.speed = 20 / 1.6 + PointTo.speed = 20 / 3.6 end local Points = { PointFrom, PointTo } diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 6f45f873d..dcbee2b90 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -350,6 +350,36 @@ function GROUP:GetCountry() return nil end +--- Returns the maximum speed of the group. +-- If the group is heterogenious and consists of different units, the max speed of the slowest unit is returned. +-- @param #GROUP self +-- @return #number Speed in km/h. +function GROUP:GetSpeedMax() + self:F2( self.GroupName ) + + local DCSGroup = self:GetDCSObject() + if DCSGroup then + + local Units=self:GetUnits() + + local speedmax=nil + + for _,unit in pairs(Units) do + local unit=unit --Wrapper.Unit#UNIT + local speed=unit:GetSpeedMax() + if speedmax==nil then + speedmax=speed + elseif speed The list of @{Unit} objects of the @{Group}. diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 1c4236dc3..bc5a89e3f 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -401,6 +401,23 @@ function UNIT:GetNumber() return nil end + +--- Returns the unit's max speed in km/h derived from the DCS descriptors. +-- @param #UNIT self +-- @return #number Speed in km/h. +function UNIT:GetSpeedMax() + self:F2( self.UnitName ) + + local Desc = self:GetDesc() + + if Desc then + local SpeedMax = Desc.speedMax + return SpeedMax*3.6 + end + + return nil +end + --- Returns the unit's group if it exist and nil otherwise. -- @param Wrapper.Unit#UNIT self -- @return Wrapper.Group#GROUP The Group of the Unit.