mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2025-08-15 06:17:22 +00:00
ctld.getNearbyUnits
This commit is contained in:
46
CTLD.lua
46
CTLD.lua
@@ -1958,6 +1958,44 @@ function ctld.spawnCrateAtPoint(_side, _weight, _point,_hdg)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ctld.getUnitsInRepackRadius(_PlayerTransportUnitName, _radius)
|
||||||
|
local _unit = ctld.getTransportUnit(_PlayerTransportUnitName)
|
||||||
|
|
||||||
|
if _unit == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local _point = _unit:getPoint()
|
||||||
|
local _units = {}
|
||||||
|
local _unitList = ctld.getNearbyUnits(_point, _radius)
|
||||||
|
|
||||||
|
for _, _nearbyUnit in pairs(_unitList) do
|
||||||
|
if _nearbyUnit:isActive() then
|
||||||
|
table.insert(_units, _nearbyUnit)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return _units
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function ctld.getNearbyUnits(_point, _radius)
|
||||||
|
local _units = {}
|
||||||
|
local _unitList = mist.DBs.unitsByName
|
||||||
|
for k, _unit in pairs(mist.DBs.unitsByName) do
|
||||||
|
local u = Unit.getByName(k)
|
||||||
|
if u and u:isActive() then
|
||||||
|
--local _dist = ctld.getDistance(u:getPoint(), _point)
|
||||||
|
local _dist = mist.utils.get2DDist(u:getPoin(), _point)
|
||||||
|
if _dist <= _radius then
|
||||||
|
table.insert(_units, u)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return _units
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
-- **************** BE CAREFUL BELOW HERE ************************
|
-- **************** BE CAREFUL BELOW HERE ************************
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
@@ -2161,16 +2199,14 @@ ctld.getNextGroupId = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ctld.getTransportUnit(_unitName)
|
function ctld.getTransportUnit(_unitName)
|
||||||
|
|
||||||
if _unitName == nil then
|
if _unitName == nil then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local _heli = Unit.getByName(_unitName)
|
local transportUnitObject = Unit.getByName(_unitName)
|
||||||
|
|
||||||
if _heli ~= nil and _heli:isActive() and _heli:getLife() > 0 then
|
if _hetransportUnitObjectli ~= nil and transportUnitObject:isActive() and transportUnitObject:getLife() > 0 then
|
||||||
|
return transportUnitObject
|
||||||
return _heli
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user