mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2025-08-15 06:17:22 +00:00
fixes ctld.getSecureDistanceFromUnit
This commit is contained in:
parent
ef1d3d57e5
commit
0c74729837
20
CTLD.lua
20
CTLD.lua
@ -1923,6 +1923,22 @@ function ctld.spawnCrateAtPoint(_side, _weight, _point, _hdg)
|
||||
end
|
||||
|
||||
function ctld.getSecureDistanceFromUnit(_unitName) -- return a distance between the center of unitName, to be sure not touch the unitName
|
||||
if Unit.getByName(_unitName) then
|
||||
local unitBoundingBox = Unit.getByName(_unitName):getDesc().box
|
||||
local widht = unitBoundingBox.max.x - unitBoundingBox.min.x
|
||||
local longer = unitBoundingBox.max.z - unitBoundingBox.min.z
|
||||
local hight = unitBoundingBox.max.y - unitBoundingBox.min.y
|
||||
|
||||
-- distanceFromCenterToCorner = 1/2√(l² + w² + h²)
|
||||
local squaresSum = longer^2 + widht^2 + hight^2 -- sum of squares
|
||||
local squareRoots = math.sqrt(squaresSum) -- square roots
|
||||
local distanceFromCenterToCorner = squareRoots / 2 -- Calculating distance (half square root)
|
||||
return distanceFromCenterToCorner
|
||||
end
|
||||
return nil
|
||||
end
|
||||
--[[
|
||||
function ctld.getSecureDistanceFromUnit_old(_unitName) -- return a distance between the center of unitName, to be sure not touch the unitName
|
||||
if Unit.getByName(_unitName) then
|
||||
local unitBoundingBox = Unit.getByName(_unitName):getDesc().box
|
||||
local deltaX = unitBoundingBox.max.x - unitBoundingBox.min.x
|
||||
@ -1934,10 +1950,10 @@ function ctld.getSecureDistanceFromUnit(_unitName) -- return a distance between
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end ]]--
|
||||
|
||||
-- ***************************************************************
|
||||
-- Repack vehicules crates functions
|
||||
-- Repack vehicules crates functions
|
||||
-- ***************************************************************
|
||||
ctld.repackRequestsStack = {} -- table to store the repack request
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user