mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2025-08-15 06:17:22 +00:00
Add menu F10 cdes for F10 map Marks of targets in LOS
This commit is contained in:
parent
e4bc932d28
commit
4146408fe8
163
CTLD.lua
163
CTLD.lua
@ -5703,6 +5703,11 @@ function ctld.addOtherF10MenuOptions()
|
||||
ctld.addJTACRadioCommand(2) -- get all BLUE players
|
||||
ctld.addJTACRadioCommand(1) -- get all RED players
|
||||
end
|
||||
|
||||
if ctld.reconF10Menu then
|
||||
ctld.addReconRadioCommand(2) -- get all BLUE players
|
||||
ctld.addReconRadioCommand(1) -- get all RED players
|
||||
end
|
||||
end)
|
||||
|
||||
if (not status) then
|
||||
@ -7267,15 +7272,14 @@ function ctld.getPositionString(_unit)
|
||||
end
|
||||
|
||||
--**********************************************************************
|
||||
-- RECOGNITION SUPPORT FUNCTIONS
|
||||
-- RECOGNITION SUPPORT FUNCTIONS
|
||||
-- Shows/remove/refresh marks in F10 map on targets in LOS of a unit passed in params
|
||||
---------------------------------------------------------------------
|
||||
-- examples ---------------------------------------------------------
|
||||
--ctld.showTargetsInLosOnF10Map(Unit.getByName("uh2-1"), 2000, 200)
|
||||
--ctld.removeTargetsInLosOnF10Map(Unit.getByName("uh2-1"))
|
||||
--
|
||||
--ctld.showTargetsInLosOnF10Map(Unit.getByName("uh2-1"), 2000, 200)
|
||||
--ctld.refreshTargetsInLosOnF10Map(Unit.getByName("uh2-1"), 2000, 200)
|
||||
--ctld.reconRefreshTargetsInLosOnF10Map(Unit.getByName("uh2-1"), 2000, 200)
|
||||
--ctld.reconRemoveTargetsInLosOnF10Map(Unit.getByName("uh2-1"))
|
||||
|
||||
--ctld.reconShowTargetsInLosOnF10Map(Unit.getByName("uh2-1"), 2000, 200)
|
||||
----------------------------------------------------------------------
|
||||
if ctld == nil then
|
||||
ctld = {}
|
||||
@ -7283,61 +7287,168 @@ end
|
||||
if ctld.lastMarkId == nil then
|
||||
ctld.lastMarkId = 0
|
||||
end
|
||||
|
||||
-- ***************** RECON CONFIGURATION *****************
|
||||
ctld.reconF10Menu = true -- enables F10 RECON menu
|
||||
ctld.reconMenuName = ctld.i18n_translate("RECON") --name of the CTLD JTAC radio menu
|
||||
ctld.reconRadioAdded = {} --stores the groups that have had the radio menu added
|
||||
ctld.reconLosSearchRadius = 2000 -- search radius in meters
|
||||
ctld.reconLosMarkRadius = 100 -- mark radius dimension in meters
|
||||
ctld.reconAutoRefreshLosTargetMarks = true -- if true recon LOS marks are automaticaly refreshed on F10 map
|
||||
ctld.reconLastScheduleIdAutoRefresh = 0
|
||||
|
||||
---- F10 RECON Menus ------------------------------------------------------------------
|
||||
function ctld.addReconRadioCommand(_side) -- _side = 1 or 2 (red or blue)
|
||||
if ctld.reconF10Menu then
|
||||
if _side == 1 or _side == 2 then
|
||||
local _players = coalition.getPlayers(_side)
|
||||
if _players ~= nil then
|
||||
for _, _playerUnit in pairs(_players) do
|
||||
local _groupId = ctld.getGroupId(_playerUnit)
|
||||
if _groupId then
|
||||
if ctld.reconRadioAdded[tostring(_groupId)] == nil then
|
||||
ctld.logDebug("ctld.addReconRadioCommand - adding RECON radio menu for unit [%s]", ctld.p(_playerUnit:getName()))
|
||||
local RECONpath = missionCommands.addSubMenuForGroup(_groupId, ctld.reconMenuName)
|
||||
missionCommands.addCommandForGroup( _groupId, ctld.i18n_translate("Show targets in LOS (refresh)"), RECONpath,
|
||||
ctld.reconRefreshTargetsInLosOnF10Map, { _groupId = _groupId,
|
||||
_playerUnit = _playerUnit,
|
||||
_searchRadius = ctld.reconLosSearchRadius,
|
||||
_markRadius = ctld.reconLosMarkRadius,
|
||||
_boolRemove = true})
|
||||
missionCommands.addCommandForGroup(_groupId, ctld.i18n_translate("Hide targets in LOS"), RECONpath, ctld.reconRemoveTargetsInLosOnF10Map, _playerUnit)
|
||||
if ctld.reconAutoRefreshLosTargetMarks then
|
||||
local c1 = missionCommands.addCommandForGroup( _groupId, ctld.i18n_translate("STOP autoRefresh targets in LOS"), RECONpath,
|
||||
ctld.reconStopAutorefreshTargetsInLosOnF10Map, _groupId, _playerUnit)
|
||||
trigger.action.outText(tostring(_groupId).." - " .. mist.utils.tableShow(c1), 20)
|
||||
else
|
||||
local c2 = missionCommands.addCommandForGroup( _groupId, ctld.i18n_translate("START autoRefresh targets in LOS"), RECONpath,
|
||||
ctld.reconStartAutorefreshTargetsInLosOnF10Map,
|
||||
_groupId,
|
||||
_playerUnit,
|
||||
ctld.reconLosSearchRadius,
|
||||
ctld.reconLosMarkRadius,
|
||||
true
|
||||
)
|
||||
trigger.action.outText(tostring(_groupId).." - " .. mist.utils.tableShow(c2), 20)
|
||||
end
|
||||
ctld.reconRadioAdded[tostring(_groupId)] = timer.getTime() --fetch the time to check for a regular refresh
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--------------------------------------------------------------------
|
||||
function ctld.showTargetsInLosOnF10Map(_unitObject, _searchRadius, _markRadius) -- _unitObject targeting
|
||||
-- _searchRadius and _markRadius in meters
|
||||
if _unitObject then
|
||||
function ctld.reconStopAutorefreshTargetsInLosOnF10Map(_groupId, _playerUnit)
|
||||
ctld.reconAutoRefreshLosTargetMarks = false
|
||||
|
||||
if ctld.reconLastScheduleIdAutoRefresh ~= 0 then
|
||||
timer.removeFunction(ctld.reconLastScheduleIdAutoRefresh) -- reset last schedule
|
||||
end
|
||||
|
||||
ctld.reconRemoveTargetsInLosOnF10Map(_playerUnit)
|
||||
missionCommands.removeItemForGroup(_groupId, {ctld.reconMenuName, ctld.i18n_translate("STOP autoRefresh targets in LOS")})
|
||||
missionCommands.addCommandForGroup( _groupId, ctld.i18n_translate("START autoRefresh targets in LOS"), {ctld.reconMenuName},
|
||||
ctld.reconStartAutorefreshTargetsInLosOnF10Map,
|
||||
_groupId,
|
||||
_playerUnit,
|
||||
_searchRadius,
|
||||
_markRadius,
|
||||
_boolRemove)
|
||||
end
|
||||
--------------------------------------------------------------------
|
||||
function ctld.reconStartAutorefreshTargetsInLosOnF10Map(_groupId, _playerUnit, _searchRadius, _markRadius, _boolRemove)
|
||||
ctld.reconAutoRefreshLosTargetMarks = true
|
||||
ctld.reconRefreshTargetsInLosOnF10Map({ _groupId = _groupId,
|
||||
_playerUnit = _playerUnit,
|
||||
_searchRadius = ctld.reconLosSearchRadius,
|
||||
_markRadius = ctld.reconLosMarkRadius,
|
||||
_boolRemove = true},
|
||||
timer.getTime())
|
||||
missionCommands.removeItemForGroup( _groupId, {ctld.reconMenuName, ctld.i18n_translate("START autoRefresh targets in LOS")})
|
||||
missionCommands.addCommandForGroup( _groupId, ctld.i18n_translate("STOP autoRefresh targets in LOS"), {ctld.reconMenuName},
|
||||
ctld.reconStopAutorefreshTargetsInLosOnF10Map,
|
||||
_groupId,
|
||||
_playerUnit)
|
||||
end
|
||||
--------------------------------------------------------------------
|
||||
function ctld.reconShowTargetsInLosOnF10Map(_playerUnit, _searchRadius, _markRadius) -- _groupId targeting
|
||||
-- _searchRadius and _markRadius in meters
|
||||
if _playerUnit then
|
||||
local TargetsInLOS = {}
|
||||
|
||||
local enemyCoa = 1
|
||||
local enemyColor = "red"
|
||||
local color = {1, 0, 0, 0.2} -- red
|
||||
|
||||
if _unitObject:getCoalition() == 1 then
|
||||
if _playerUnit:getCoalition() == 1 then
|
||||
enemyCoa = 2
|
||||
enemyColor = "blue"
|
||||
color = {51/255, 51/255, 1, 0.2} -- blue
|
||||
end
|
||||
|
||||
local t = mist.getUnitsLOS({_unitObject:getName()}, 180, mist.makeUnitTable({'['..enemyColor..'][vehicle]'}),180, _searchRadius)
|
||||
local t = mist.getUnitsLOS({_playerUnit:getName()}, 180, mist.makeUnitTable({'['..enemyColor..'][vehicle]'}),180, _searchRadius)
|
||||
|
||||
local MarkIds = {}
|
||||
if t then
|
||||
for i=1, #t do -- for each unit having los on enemies
|
||||
for j=1, #t[i].vis do
|
||||
local targetPoint = t[i].vis[j]:getPoint() -- point of each target on LOS
|
||||
for i=1, #t do -- for each unit having los on enemies
|
||||
for j=1, #t[i].vis do -- for each enemy unit in los
|
||||
local targetPoint = t[i].vis[j]:getPoint() -- point of each target on LOS
|
||||
ctld.lastMarkId = ctld.lastMarkId + 1
|
||||
trigger.action.circleToAll(_unitObject:getCoalition(), ctld.lastMarkId, targetPoint, _markRadius , color, color, 1, false, nil)
|
||||
trigger.action.circleToAll(_playerUnit:getCoalition(), ctld.lastMarkId, targetPoint, _markRadius , color, color, 1, false, nil)
|
||||
MarkIds[#MarkIds+1] = ctld.lastMarkId
|
||||
TargetsInLOS[#TargetsInLOS+1] = {targetObject=t[i].vis[j]:getName(), targetTypeName=t[i].vis[j]:getTypeName(), targetPoint=targetPoint}
|
||||
TargetsInLOS[#TargetsInLOS+1] = {targetObject = t[i].vis[j]:getName(),
|
||||
targetTypeName = t[i].vis[j]:getTypeName(),
|
||||
targetPoint = targetPoint}
|
||||
end
|
||||
end
|
||||
end
|
||||
mist.DBs.humansByName[_unitObject:getName()].losMarkIds = MarkIds -- store list of marksIds generated and show on F10 map
|
||||
mist.DBs.humansByName[_playerUnit:getName()].losMarkIds = MarkIds -- store list of marksIds generated and showed on F10 map
|
||||
return TargetsInLOS
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
---------------------------------------------------------
|
||||
function ctld.removeTargetsInLosOnF10Map(_unitObject)
|
||||
local unitName = _unitObject:getName()
|
||||
function ctld.reconRemoveTargetsInLosOnF10Map(_playerUnit)
|
||||
local unitName = _playerUnit:getName()
|
||||
if mist.DBs.humansByName[unitName].losMarkIds then
|
||||
for i=1, #mist.DBs.humansByName[_unitObject:getName()].losMarkIds do -- for each unit having los on enemies
|
||||
for i=1, #mist.DBs.humansByName[unitName].losMarkIds do -- for each unit having los on enemies
|
||||
trigger.action.removeMark(mist.DBs.humansByName[unitName].losMarkIds[i])
|
||||
end
|
||||
mist.DBs.humansByName[unitName].losMarkIds = nil
|
||||
end
|
||||
end
|
||||
---------------------------------------------------------
|
||||
function ctld.refreshTargetsInLosOnF10Map(_unitObject, _searchRadius, _markRadius)
|
||||
ctld.removeTargetsInLosOnF10Map(_unitObject)
|
||||
return ctld.showTargetsInLosOnF10Map(_unitObject, _searchRadius, _markRadius) -- returns TargetsInLOS table
|
||||
function ctld.reconRefreshTargetsInLosOnF10Map(_params, _t) -- _params._playerUnit targeting
|
||||
-- _params._searchRadius and _params._markRadius in meters
|
||||
-- _params._boolRemove = true to remove previous marksIds
|
||||
if _t == nil then _t = timer.getTime() end
|
||||
|
||||
if ctld.reconAutoRefreshLosTargetMarks then -- to follow mobile enemy targets
|
||||
ctld.reconLastScheduleIdAutoRefresh = timer.scheduleFunction(ctld.reconRefreshTargetsInLosOnF10Map, {_groupId = _params._groupId,
|
||||
_playerUnit = _params._playerUnit,
|
||||
_searchRadius = _params._searchRadius,
|
||||
_markRadius = _params._markRadius,
|
||||
_boolRemove = _params._boolRemove
|
||||
},
|
||||
timer.getTime() + 10)
|
||||
end
|
||||
|
||||
if _params._boolRemove == true then
|
||||
ctld.reconRemoveTargetsInLosOnF10Map(_params._playerUnit)
|
||||
end
|
||||
|
||||
return ctld.reconShowTargetsInLosOnF10Map(_params._playerUnit, _params._searchRadius, _params._markRadius) -- returns TargetsInLOS table
|
||||
end
|
||||
--- test ------------------------------------------------------
|
||||
--"uh1-1" --"uh2-1"
|
||||
--local unitName = "uh2-1"
|
||||
--ctld.showTargetsInLosOnF10Map(Unit.getByName(unitName),2000,200)
|
||||
--local unitName = "uh2-1" --"uh1-1" --"uh2-1"
|
||||
--ctld.reconShowTargetsInLosOnF10Map(Unit.getByName(unitName),2000,200)
|
||||
|
||||
|
||||
--**********************************************************************
|
||||
|
||||
-- ***************** SETUP SCRIPT ****************
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user