RANGE v1.2 and other changes

RANGE:
-Optimized performance. Bombs are now only tracked if the player is within a certain distance of the range.

CONTROLLABLE:
- Added speed unit to @param description. Sometimes it was unclear if speed needs to be given in m/s or km/h.
- Fixed some default speed and conversions.
COORDINATE:
- Cleaned up some speed unit stuff.
- Reintroduced PathOnRoad function to contain the full path. Useful as interface to DCS API function.
- Fixed some default speed and conversions.

AI_CARGO_APC:
Speed is not fixed any more but set to 50% of the max speed a given unit can move at.
This commit is contained in:
funkyfranky
2018-05-26 14:46:23 +02:00
parent d98f207bcf
commit ad75a7ddb5
5 changed files with 212 additions and 190 deletions

View File

@@ -777,7 +777,7 @@ do -- COORDINATE
-- @param #COORDINATE.WaypointAltType AltType The altitude type.
-- @param #COORDINATE.WaypointType Type The route point type.
-- @param #COORDINATE.WaypointAction Action The route point action.
-- @param Dcs.DCSTypes#Speed Speed Airspeed in km/h.
-- @param Dcs.DCSTypes#Speed Speed Airspeed in km/h. Default is 500 km/h.
-- @param #boolean SpeedLocked true means the speed is locked.
-- @return #table The route point.
function COORDINATE:WaypointAir( AltType, Type, Action, Speed, SpeedLocked )
@@ -887,7 +887,7 @@ do -- COORDINATE
--- Build an ground type route point.
-- @param #COORDINATE self
-- @param #number Speed (optional) Speed in km/h. The default speed is 999 km/h.
-- @param #number Speed (optional) Speed in km/h. The default speed is 20 km/h.
-- @param #string Formation (optional) The route point Formation, which is a text string that specifies exactly the Text in the Type of the route point, like "Vee", "Echelon Right".
-- @return #table The route point.
function COORDINATE:WaypointGround( Speed, Formation )
@@ -935,22 +935,30 @@ do -- COORDINATE
return COORDINATE:NewFromVec2(vec2)
end
--- Returns a table of coordinates to a destination.
--- Returns a table of coordinates to a destination using only roads.
-- The first point is the closest point on road of the given coordinate. The last point is the closest point on road of the ToCoord. Hence, the coordinate itself and the final ToCoord are not necessarily included in the path.
-- @param #COORDINATE self
-- @param #COORDINATE ToCoord Coordinate of destination.
-- @return #table Table of coordinates on road.
function COORDINATE:GetPathOnRoad(ToCoord)
local Path={}
-- DCS API function returning a table of vec2.
local path = land.findPathOnRoads("roads", self.x, self.z, ToCoord.x, ToCoord.z)
Path[#Path+1]=COORDINATE:NewFromVec2(path[1])
Path[#Path+1]=COORDINATE:NewFromVec2(path[#path])
--Path[#Path+1]=COORDINATE:NewFromVec2(path[1])
--Path[#Path+1]=COORDINATE:NewFromVec2(path[#path])
--Path[#Path+1]=self:GetClosestPointToRoad()
--Path[#Path+1]=ToCoord:GetClosestPointToRoad()
-- I've removed this stuff because it severely slows down DCS in case of paths with a lot of segments.
-- Just the beginning and the end point is sufficient.
-- for i, v in ipairs(path) do
-- self:I(v)
-- local coord=COORDINATE:NewFromVec2(v)
-- Path[#Path+1]=COORDINATE:NewFromVec2(v)
-- end
local Path={}
--Path[#Path+1]=self
for i, v in ipairs(path) do
Path[#Path+1]=COORDINATE:NewFromVec2(v)
end
--Path[#Path+1]=ToCoord
return Path
end