mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2025-08-15 06:17:22 +00:00
fixes
This commit is contained in:
parent
75c9d0bf68
commit
888d949234
32
CTLD.lua
32
CTLD.lua
@ -2030,17 +2030,16 @@ function ctld.repackVehicle(_params, t) -- scan rrs table 'repackRequestsStack'
|
||||
if repackableUnit:isExist() then
|
||||
--ici calculer le heading des spwans à effectuer
|
||||
local _playerHeading = mist.getHeading(PlayerTransportUnit)
|
||||
local _offset = 5
|
||||
trigger.action.outText("heading = " .. _playerHeading, 5)
|
||||
local refPoint = ctld.getPointAtDirection(PlayerTransportUnit, _offset, ctld.random(_playerHeading - math.pi/4, _playerHeading + math.pi/4))
|
||||
local playerPoint = PlayerTransportUnit:getPoint()
|
||||
local offset = 5
|
||||
--local refPoint = ctld.getPointAtDirection(PlayerTransportUnit, offset, ctld.random(_playerHeading - math.pi/4, _playerHeading + math.pi/4))
|
||||
local randomHeading = RandomReal(_playerHeading - math.pi/4, _playerHeading + math.pi/4)
|
||||
for i = 0, v[1].cratesRequired - 1 do
|
||||
--local _point = { x = spawnRefPoint.x + 5 + (i * 3), z = spawnRefPoint.z }
|
||||
local _point = { x = refPoint.x + 5 + (i * _offset), z = refPoint.z }
|
||||
|
||||
-- see to spawn the crate at random position heading the transport unit with ctld.getPointAtDirection(_unit, _offset, _directionInRadian)
|
||||
-- see to spawn the crate at random position heading the transport unit with ctld.getPointAtDirection(_unit, offset, _directionInRadian)
|
||||
local _unitId = ctld.getNextUnitId()
|
||||
local _name = string.format("%s_%i", v[1].desc, _unitId)
|
||||
ctld.spawnCrateStatic(PlayerTransportUnit:getCountry(), _unitId, _point, _name, crateWeight,
|
||||
local relativePoint = ctld.getRelativePoint(playerPoint, i * offset, randomHeading)
|
||||
ctld.spawnCrateStatic(PlayerTransportUnit:getCountry(), _unitId, relativePoint, _name, crateWeight,
|
||||
PlayerTransportUnit:getCoalition(), mist.getHeading(PlayerTransportUnit, true))
|
||||
end
|
||||
|
||||
@ -2628,6 +2627,17 @@ function ctld.getPointAtDirection(_unit, _offset, _directionInRadian)
|
||||
return { x = _point.x + _xOffset, z = _point.z + _zOffset, y = _point.y }
|
||||
end
|
||||
|
||||
function ctld.getRelativePoint(_refPointXZTable, _distance, _angle_radians) -- return coord point at distance and angle from _refPoint
|
||||
local relativePoint = {}
|
||||
relativePoint.x = _refPointXZTable.x + _distance * math.cos(_angle_radians)
|
||||
if _refPointXZTable.z == nil then
|
||||
relativePoint.y = _refPointXZTable.y + _distance * math.sin(_angle_radians)
|
||||
else
|
||||
relativePoint.z = _refPointXZTable.z + _distance * math.sin(_angle_radians)
|
||||
end
|
||||
return relativePoint
|
||||
end
|
||||
|
||||
function ctld.troopsOnboard(_heli, _troops)
|
||||
if ctld.inTransitTroops[_heli:getName()] ~= nil then
|
||||
local _onboard = ctld.inTransitTroops[_heli:getName()]
|
||||
@ -8270,6 +8280,12 @@ end
|
||||
-- initialize the random number generator to make it almost random
|
||||
math.random(); math.random(); math.random()
|
||||
|
||||
function ctld.RandomReal(mini, maxi)
|
||||
local rand = math.random() --random value between 0 and 1
|
||||
local result = mini + rand * (maxi - mini) -- scale the random value between [mini, maxi]
|
||||
return result
|
||||
end
|
||||
|
||||
--- Enable/Disable error boxes displayed on screen.
|
||||
env.setErrorMessageBoxEnabled(false)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user