Warehouse 0.1.4

zone: fixed GetRandomCoordinate inner, outer missing
controllable: fixed path cannot be found
group: added getrange
unit: added getrange
This commit is contained in:
funkyfranky
2018-08-13 00:36:34 +02:00
parent 195459d6d8
commit d91166c3c4
8 changed files with 782 additions and 331 deletions

View File

@@ -2026,7 +2026,8 @@ do -- Route methods
-- @param #number Speed (Optional) Speed in km/h. The default speed is 20 km/h.
-- @param #string OffRoadFormation (Optional) The formation at initial and final waypoint. Default is "Off Road".
-- @param #boolean Shortcut (Optional) If true, controllable will take the direct route if the path on road is 10x longer or path on road is less than 5% of total path.
-- @return Task
-- @return DCS#Task Task.
-- @return #boolean If true, path on road is possible. If false, task will route the group directly to its destination.
function CONTROLLABLE:TaskGroundOnRoad( ToCoordinate, Speed, OffRoadFormation, Shortcut )
self:F2({ToCoordinate=ToCoordinate, Speed=Speed, OffRoadFormation=OffRoadFormation})
@@ -2044,28 +2045,36 @@ do -- Route methods
local _,LengthRoad=FromCoordinate:GetPathOnRoad(ToCoordinate, false)
-- Off road part of the rout: Total=OffRoad+OnRoad.
local LengthOffRoad=LengthOnRoad-LengthRoad
local LengthOffRoad
local LongRoad
-- Calculate the direct distance between the initial and final points.
local LengthDirect=FromCoordinate:Get2DDistance(ToCoordinate)
-- Debug info.
self:T(string.format("Length on road = %.3f km", LengthOnRoad/1000))
self:T(string.format("Length directly = %.3f km", LengthDirect/1000))
self:T(string.format("Length fraction = %.3f km", LengthOnRoad/LengthDirect))
self:T(string.format("Length only road = %.3f km", LengthRoad/1000))
self:T(string.format("Length off road = %.3f km", LengthOffRoad/1000))
self:T(string.format("Percent on road = %.1f", LengthRoad/LengthOnRoad*100))
if PathOnRoad then
-- Off road part of the rout: Total=OffRoad+OnRoad.
LengthOffRoad=LengthOnRoad-LengthRoad
-- Length on road is 10 times longer than direct route or path on road is very short (<5% of total path).
LongRoad=LengthOnRoad and ((LengthOnRoad > LengthDirect*10) or (LengthRoad/LengthOnRoad*100<5))
-- Debug info.
self:T(string.format("Length on road = %.3f km", LengthOnRoad/1000))
self:T(string.format("Length directly = %.3f km", LengthDirect/1000))
self:T(string.format("Length fraction = %.3f km", LengthOnRoad/LengthDirect))
self:T(string.format("Length only road = %.3f km", LengthRoad/1000))
self:T(string.format("Length off road = %.3f km", LengthOffRoad/1000))
self:T(string.format("Percent on road = %.1f", LengthRoad/LengthOnRoad*100))
end
-- Route, ground waypoints along road.
local route={}
-- Length on road is 10 times longer than direct route or path on road is very short (<5% of total path).
local LongRoad=LengthOnRoad and ((LengthOnRoad > LengthDirect*10) or (LengthRoad/LengthOnRoad*100<5))
local canroad=false
-- Check if a valid path on road could be found.
if PathOnRoad then
-- Check whether the road is very long compared to direct path.
if LongRoad and Shortcut then
@@ -2088,6 +2097,7 @@ do -- Route methods
end
canroad=true
else
-- No path on road could be found (can happen!) ==> Route group directly from A to B.
@@ -2096,7 +2106,7 @@ do -- Route methods
end
return route
return route, canroad
end
--- Make a task for a TRAIN Controllable to drive towards a specific point using railroad.