mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2026-08-22 16:05:07 +00:00
fixes
This commit is contained in:
@@ -1981,14 +1981,13 @@ function ctld.getUnitsInRepackRadius(_PlayerTransportUnitName, _radius)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local playerCoalition = unit:getCoalition()
|
local unitsNamesList = ctld.getNearbyUnits(unit:getPoint(), _radius, unit:getCoalition())
|
||||||
local point = unit:getPoint()
|
|
||||||
local unitList = ctld.getNearbyUnits(point, _radius, playerCoalition)
|
|
||||||
local repackableUnits = {}
|
local repackableUnits = {}
|
||||||
for i=1, #unitList do
|
for i=1, #unitsNamesList do
|
||||||
local repackableUnit = ctld.isRepackableUnit(unitList[i])
|
local unitObject = Unit.getByName(unitsNamesList[i])
|
||||||
|
local repackableUnit = ctld.isRepackableUnit(unitsNamesList[i])
|
||||||
if repackableUnit then
|
if repackableUnit then
|
||||||
repackableUnit["repackableUnitGroupID"] = unitList[i]:getGroup():getID()
|
repackableUnit["repackableUnitGroupID"] = unitObject:getGroup():getID()
|
||||||
table.insert(repackableUnits, mist.utils.deepCopy(repackableUnit))
|
table.insert(repackableUnits, mist.utils.deepCopy(repackableUnit))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2007,21 +2006,22 @@ function ctld.getNearbyUnits(_point, _radius, _coalition)
|
|||||||
--local _dist = ctld.getDistance(u:getPoint(), _point)
|
--local _dist = ctld.getDistance(u:getPoint(), _point)
|
||||||
local _dist = mist.utils.get2DDist(u:getPoint(), _point)
|
local _dist = mist.utils.get2DDist(u:getPoint(), _point)
|
||||||
if _dist <= _radius then
|
if _dist <= _radius then
|
||||||
table.insert(_units, u)
|
table.insert(_units, k) -- insert nearby unitName
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return _units
|
return _units
|
||||||
end
|
end
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
function ctld.isRepackableUnit(_unitId)
|
function ctld.isRepackableUnit(_unitName)
|
||||||
local unitType = _unitId:getTypeName()
|
local unitObject = Unit.getByName(_unitName)
|
||||||
|
local unitType = unitObject:getTypeName()
|
||||||
for k,v in pairs(ctld.spawnableCrates) do
|
for k,v in pairs(ctld.spawnableCrates) do
|
||||||
for i=1, #ctld.spawnableCrates[k] do
|
for i=1, #ctld.spawnableCrates[k] do
|
||||||
if _unitId then
|
if _unitName then
|
||||||
if ctld.spawnableCrates[k][i].unit == unitType then
|
if ctld.spawnableCrates[k][i].unit == unitType then
|
||||||
local repackableUnit = mist.utils.deepCopy(ctld.spawnableCrates[k][i])
|
local repackableUnit = mist.utils.deepCopy(ctld.spawnableCrates[k][i])
|
||||||
repackableUnit["vehicleId"] = _unitId
|
repackableUnit["repackableUnitName"] = _unitName
|
||||||
return repackableUnit
|
return repackableUnit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2030,12 +2030,25 @@ function ctld.isRepackableUnit(_unitId)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
|
function ctld.getCrateDesc(_crateWeight)
|
||||||
|
for k,v in pairs(ctld.spawnableCrates) do
|
||||||
|
for i=1, #ctld.spawnableCrates[k] do
|
||||||
|
if _crateWeight then
|
||||||
|
if ctld.spawnableCrates[k][i].weight == _crateWeight then
|
||||||
|
return ctld.spawnableCrates[k][i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
-- ***************************************************************
|
||||||
function ctld.repackVehicleRequest(_params) -- update rrs table 'repackRequestsStack' with the request
|
function ctld.repackVehicleRequest(_params) -- update rrs table 'repackRequestsStack' with the request
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
local repackableUnit = _params[1]
|
local repackableUnit = _params[1]
|
||||||
local PlayerTransportUnitName = _params[2]
|
local PlayerTransportUnitName = _params[2]
|
||||||
local PlayerTransportUnit = Unit.getByName(PlayerTransportUnitName)
|
local PlayerTransportUnit = Unit.getByName(PlayerTransportUnitName)
|
||||||
local TransportUnit = ctld.getTransportUnit(PlayerTransportUnitName)
|
local TransportUnit = ctld.getTransportUnit(PlayerTransportUnitName)
|
||||||
local spawnRefPoint = PlayerTransportUnit:getPoint()
|
local spawnRefPoint = PlayerTransportUnit:getPoint()
|
||||||
local refCountry = PlayerTransportUnit:getCountry()
|
local refCountry = PlayerTransportUnit:getCountry()
|
||||||
@@ -2048,7 +2061,7 @@ function ctld.repackVehicle(_params,t) -- scan rrs table 'repackRequestsStack'
|
|||||||
if t == nil then
|
if t == nil then
|
||||||
t = timer.getTime()
|
t = timer.getTime()
|
||||||
end
|
end
|
||||||
|
ctld.logTrace("FG_ ctld.repackVehicle = %s", ctld.p(mist.utils.tableShow(ctld.repackRequestsStack)))
|
||||||
for ii, v in ipairs(ctld.repackRequestsStack) do
|
for ii, v in ipairs(ctld.repackRequestsStack) do
|
||||||
local repackableUnit = v[1]
|
local repackableUnit = v[1]
|
||||||
local PlayerTransportUnitName = v[2]
|
local PlayerTransportUnitName = v[2]
|
||||||
@@ -2149,7 +2162,12 @@ function ctld.getUnitsInLogisticZone(_logisticUnitName, _coalition)
|
|||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
function ctld.isUnitInNamedLogisticZone(_unit, _logisticUnitName) -- check if a unit is in the named logistic zone
|
function ctld.isUnitInNamedLogisticZone(_unitName, _logisticUnitName) -- check if a unit is in the named logistic zone
|
||||||
|
trigger.action.outText('ctld.isUnitInNamedLogisticZone._logisticUnitName = ',tostring(_logisticUnitName), 10)
|
||||||
|
local _unit = Unit.getByName(_unitName)
|
||||||
|
if _unit == nil then
|
||||||
|
return false
|
||||||
|
end
|
||||||
local unitPoint = _unit:getPoint()
|
local unitPoint = _unit:getPoint()
|
||||||
local logisticUnitPoint = StaticObject.getByName(_logisticUnitName):getPoint()
|
local logisticUnitPoint = StaticObject.getByName(_logisticUnitName):getPoint()
|
||||||
|
|
||||||
@@ -2160,9 +2178,9 @@ function ctld.isUnitInNamedLogisticZone(_unit, _logisticUnitName) -- check if a
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
function ctld.isUnitInALogisticZone(_unit) -- check if a unit is in a logistic zone if true then return the logisticUnitName of the zone
|
function ctld.isUnitInALogisticZone(_unitName) -- check if a unit is in a logistic zone if true then return the logisticUnitName of the zone
|
||||||
for i, logUnit in ipairs(ctld.logisticUnits) do
|
for i, logUnit in ipairs(ctld.logisticUnits) do
|
||||||
if ctld.isUnitInNamedLogisticZone(_unit, logUnit) then
|
if ctld.isUnitInNamedLogisticZone(_unitName, logUnit) then
|
||||||
return logUnit
|
return logUnit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user