mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2025-08-15 06:17:22 +00:00
debug
This commit is contained in:
46
CTLD.lua
46
CTLD.lua
@@ -7776,16 +7776,16 @@ function ctld.InOrbitList(_grpName)
|
|||||||
end
|
end
|
||||||
-------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------
|
||||||
-- return the WayPoint number (on the JTAC route) the most near from the target
|
-- return the WayPoint number (on the JTAC route) the most near from the target
|
||||||
function ctld.NearWP(_unitTargetName, _jtacUnitName)
|
function ctld.getNearestWP(_referenceUnitName)
|
||||||
local WP = 0
|
local WP = 0
|
||||||
local memoDist = nil -- Lower distance checked
|
local memoDist = nil -- Lower distance checked
|
||||||
local jtacGroupName = Unit.getByName(_jtacUnitName):getGroup():getName()
|
local refGroupName = Unit.getByName(_referenceUnitName):getGroup():getName()
|
||||||
local JTACRoute = mist.getGroupRoute (jtacGroupName, true) -- get the initial editor route of the current group
|
local JTACRoute = mist.getGroupRoute (refGroupName, true) -- get the initial editor route of the current group
|
||||||
if Unit.getByName(_jtacUnitName) ~= nil and Unit.getByName(_unitTargetName) ~= nil then --JTAC et unit must exist
|
if Unit.getByName(_referenceUnitName) ~= nil then --JTAC et unit must exist
|
||||||
for i=1, #JTACRoute do
|
for i=1, #JTACRoute do
|
||||||
local ptJTAC = {x = JTACRoute[i].x, y = JTACRoute[i].y}
|
local ptWP = {x = JTACRoute[i].x, y = JTACRoute[i].y}
|
||||||
local ptTarget = mist.utils.makeVec2(Unit.getByName(_unitTargetName):getPoint())
|
local ptRef = mist.utils.makeVec2(Unit.getByName(_referenceUnitName):getPoint())
|
||||||
local dist = mist.utils.get2DDist(ptJTAC, ptTarget) -- distance between 2 points
|
local dist = mist.utils.get2DDist(ptRef, ptWP) -- distance between 2 points
|
||||||
if memoDist == nil then
|
if memoDist == nil then
|
||||||
memoDist = dist
|
memoDist = dist
|
||||||
WP = i
|
WP = i
|
||||||
@@ -7814,6 +7814,38 @@ function ctld.backToRoute(_jtacUnitName)
|
|||||||
return Mission
|
return Mission
|
||||||
end
|
end
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
|
function ctld.adjustRoute(_initialRouteTable, _firstWpOfNewRoute) -- create a route based on inital one, starting at _firstWpOfNewRoute WP
|
||||||
|
-- if the last WP switch to the first this cycle is recreated
|
||||||
|
local adjustedRoute = {}
|
||||||
|
local lastRouteTasks = _initialRouteTable{#_initialRouteTable].task.params.tasks
|
||||||
|
for i=1, #lastRouteTasks do -- look at each task of last WP
|
||||||
|
if lastRouteTasks[i].params.action.id == "SwitchWaypoint" then
|
||||||
|
local fromWaypointIndex = lastRouteTasks[i].params.action.params.fromWaypointIndex
|
||||||
|
local goToWaypointIndex = lastRouteTasks[i].params.action.params.goToWaypointIndex
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local idx = 1
|
||||||
|
for i=1, #_initialRouteTable do -- look at each task of last WP
|
||||||
|
if i >= _firstWpOfNewRoute then
|
||||||
|
adjustedRoute[idx] = _initialRouteTable[i]
|
||||||
|
idx = idx + 1
|
||||||
|
if i == #_initialRouteTable then -- if on last initial WP => delete initial switch action
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if _firstWpOfNewRoute > 1 then -- add firsts WPs at the end of adjustedRoute
|
||||||
|
for i=1, _firstWpOfNewRoute-1 do -- look at each WP skeeped in pass 1
|
||||||
|
adjustedRoute[idx] = _initialRouteTable[i]
|
||||||
|
idx = idx + 1
|
||||||
|
if i == _firstWpOfNewRoute-1 then -- if on final adjustedRoute WP => add new switch action on _firstWpOfNewRoute-1 WP
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
----------------------------------------------------------------------------
|
||||||
function ctld.isFlyingJtac(_jtacUnitName)
|
function ctld.isFlyingJtac(_jtacUnitName)
|
||||||
if Unit.getByName(_jtacUnitName) then
|
if Unit.getByName(_jtacUnitName) then
|
||||||
if Unit.getByName(_jtacUnitName):getCategoryEx() == 0 then -- it's an airplane JTAC
|
if Unit.getByName(_jtacUnitName):getCategoryEx() == 0 then -- it's an airplane JTAC
|
||||||
|
|||||||
Reference in New Issue
Block a user