mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2025-08-15 06:17:22 +00:00
Merge pull request #11 from jmontleon/priority-system
add means to prioritize targets
This commit is contained in:
commit
36dfa4f484
62
CTLD.lua
62
CTLD.lua
@ -4696,6 +4696,48 @@ function ctld.findNearestVisibleEnemy(_jtacUnit, _targetType,_distance)
|
|||||||
local _tempDist = nil
|
local _tempDist = nil
|
||||||
|
|
||||||
-- finish this function
|
-- finish this function
|
||||||
|
local _vhpriority = false
|
||||||
|
local _vpriority = false
|
||||||
|
local _thpriority = false
|
||||||
|
local _tpriority = false
|
||||||
|
for _i = 1, #_enemyGroups do
|
||||||
|
if _enemyGroups[_i] ~= nil then
|
||||||
|
_groupName = _enemyGroups[_i]:getName()
|
||||||
|
_units = ctld.getGroup(_groupName)
|
||||||
|
if #_units > 0 then
|
||||||
|
for _y = 1, #_units do
|
||||||
|
local _targeted = false
|
||||||
|
if not _distance then
|
||||||
|
_targeted = ctld.alreadyTarget(_jtacUnit, _units[_x])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- calc distance
|
||||||
|
_tempPoint = _units[_y]:getPoint()
|
||||||
|
_tempDist = ctld.getDistance(_tempPoint, _jtacPoint)
|
||||||
|
|
||||||
|
if _tempDist < _maxDistance and _tempDist < _nearestDistance then
|
||||||
|
|
||||||
|
local _offsetEnemyPos = { x = _tempPoint.x, y = _tempPoint.y + 2.0, z = _tempPoint.z }
|
||||||
|
local _offsetJTACPos = { x = _jtacPoint.x, y = _jtacPoint.y + 2.0, z = _jtacPoint.z }
|
||||||
|
-- calc visible
|
||||||
|
|
||||||
|
if land.isVisible(_offsetEnemyPos, _offsetJTACPos) and _targeted == false then
|
||||||
|
if (string.match(_units[_y]:getName(), "hpriority") ~= nil) and ctld.isVehicle(_units[_y]) then
|
||||||
|
_vhpriority = true
|
||||||
|
elseif (string.match(_units[_y]:getName(), "priority") ~= nil) and ctld.isVehicle(_units[_y]) then
|
||||||
|
_vpriority = true
|
||||||
|
elseif (string.match(_units[_y]:getName(), "hpriority") ~= nil) and ctld.isInfantry(_units[_y]) then
|
||||||
|
_thpriority = true
|
||||||
|
elseif (string.match(_units[_y]:getName(), "priority") ~= nil) and ctld.isInfantry(_units[_y]) then
|
||||||
|
_tpriority = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for _i = 1, #_enemyGroups do
|
for _i = 1, #_enemyGroups do
|
||||||
if _enemyGroups[_i] ~= nil then
|
if _enemyGroups[_i] ~= nil then
|
||||||
_groupName = _enemyGroups[_i]:getName()
|
_groupName = _enemyGroups[_i]:getName()
|
||||||
@ -4714,13 +4756,24 @@ function ctld.findNearestVisibleEnemy(_jtacUnit, _targetType,_distance)
|
|||||||
|
|
||||||
local _allowedTarget = true
|
local _allowedTarget = true
|
||||||
|
|
||||||
if _targetType == "vehicle" then
|
if _targetType == "vehicle" and _vhpriority == true then
|
||||||
|
_allowedTarget = (string.match(_units[_x]:getName(), "hpriority") ~= nil) and ctld.isVehicle(_units[_x])
|
||||||
|
elseif _targetType == "vehicle" and _vpriority == true then
|
||||||
|
_allowedTarget = (string.match(_units[_x]:getName(), "priority") ~= nil) and ctld.isVehicle(_units[_x])
|
||||||
|
elseif _targetType == "vehicle" then
|
||||||
_allowedTarget = ctld.isVehicle(_units[_x])
|
_allowedTarget = ctld.isVehicle(_units[_x])
|
||||||
|
elseif _targetType == "troop" and _hpriority == true then
|
||||||
|
_allowedTarget = (string.match(_units[_x]:getName(), "hpriority") ~= nil) and ctld.isInfantry(_units[_x])
|
||||||
|
elseif _targetType == "troop" and _priority == true then
|
||||||
|
_allowedTarget = (string.match(_units[_x]:getName(), "priority") ~= nil) and ctld.isInfantry(_units[_x])
|
||||||
elseif _targetType == "troop" then
|
elseif _targetType == "troop" then
|
||||||
|
|
||||||
_allowedTarget = ctld.isInfantry(_units[_x])
|
_allowedTarget = ctld.isInfantry(_units[_x])
|
||||||
|
elseif _vhpriority == true or _thpriority == true then
|
||||||
|
_allowedTarget = (string.match(_units[_x]:getName(), "hpriority") ~= nil)
|
||||||
|
elseif _vpriority == true or _tpriority == true then
|
||||||
|
_allowedTarget = (string.match(_units[_x]:getName(), "priority") ~= nil)
|
||||||
|
else
|
||||||
|
_allowedTarget = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if _units[_x]:isActive() == true and _targeted == false and _allowedTarget == true then
|
if _units[_x]:isActive() == true and _targeted == false and _allowedTarget == true then
|
||||||
@ -4748,7 +4801,6 @@ function ctld.findNearestVisibleEnemy(_jtacUnit, _targetType,_distance)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if _nearestUnit == nil then
|
if _nearestUnit == nil then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|||||||
@ -478,6 +478,8 @@ Smoke colours are: Green = 0 , Red = 1, White = 2, Orange = 3, Blue = 4
|
|||||||
The script doesn't care if the unit isn't activated when run, as it'll automatically activate when the JTAC is activated in
|
The script doesn't care if the unit isn't activated when run, as it'll automatically activate when the JTAC is activated in
|
||||||
the mission but there can be a delay of up to 30 seconds after activation for the JTAC to start searching for targets.
|
the mission but there can be a delay of up to 30 seconds after activation for the JTAC to start searching for targets.
|
||||||
|
|
||||||
|
You can also change the name of a unit (unit, not group) to include "hpriority" to make it high priority for the JTAC, or "priority" to set it to be medium priority. JTAC's will prioritize targets within view by first marking hpriority targets, then priority targets, and finally all others. This works seemlessly with the all/vehicle/troop functionality as well. In this way you can have them lase SAMS, then AAA, then armor, or any other order you decide is preferable.
|
||||||
|
|
||||||
### Pickup and Dropoff Zones Setup
|
### Pickup and Dropoff Zones Setup
|
||||||
Pickup zones are used by transport aircraft and helicopters to load troops and vehicles. A transport unit must be inside of the radius of the trigger and the right side (RED or BLUE or BOTH) in order to load troops and vehicles.
|
Pickup zones are used by transport aircraft and helicopters to load troops and vehicles. A transport unit must be inside of the radius of the trigger and the right side (RED or BLUE or BOTH) in order to load troops and vehicles.
|
||||||
The pickup zone needs to be named the same as one of the pickup zones in the ```ctld.pickupZones``` list or the list can be edited to match the name in the mission editor.
|
The pickup zone needs to be named the same as one of the pickup zones in the ```ctld.pickupZones``` list or the list can be edited to match the name in the mission editor.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user