mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2025-08-15 06:17:22 +00:00
Small corrections
This commit is contained in:
78
CTLD.lua
78
CTLD.lua
@@ -774,8 +774,7 @@ ctld.loadableGroups = {
|
|||||||
ctld.spawnableCratesModels = {
|
ctld.spawnableCratesModels = {
|
||||||
["load"] = {
|
["load"] = {
|
||||||
["category"] = "Fortifications",
|
["category"] = "Fortifications",
|
||||||
["shape_name"] = "GeneratorF",
|
["type"] = "Cargo04",
|
||||||
["type"] = "GeneratorF",
|
|
||||||
["canCargo"] = false,
|
["canCargo"] = false,
|
||||||
},
|
},
|
||||||
["sling"] = {
|
["sling"] = {
|
||||||
@@ -785,9 +784,8 @@ ctld.loadableGroups = {
|
|||||||
["canCargo"] = true
|
["canCargo"] = true
|
||||||
},
|
},
|
||||||
["dynamic"] = {
|
["dynamic"] = {
|
||||||
["category"] = "Cargos",
|
["category"] = "Cargos",
|
||||||
["shape_name"] = "m117_cargo",
|
["type"] = "ammo_cargo",
|
||||||
["type"] = "m117_cargo",
|
|
||||||
["canCargo"] = true
|
["canCargo"] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1543,7 +1541,7 @@ function ctld.spawnCrateAtZone(_side, _weight,_zone)
|
|||||||
|
|
||||||
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
||||||
|
|
||||||
local _spawnedCrate = ctld.spawnCrateStatic(_country, _unitId, _point, _name, _crateType.weight,_side)
|
ctld.spawnCrateStatic(_country, _unitId, _point, _name, _crateType.weight, _side)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1578,7 +1576,7 @@ function ctld.spawnCrateAtPoint(_side, _weight, _point,_hdg)
|
|||||||
|
|
||||||
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
||||||
|
|
||||||
local _spawnedCrate = ctld.spawnCrateStatic(_country, _unitId, _point, _name, _crateType.weight, _side,_hdg)
|
ctld.spawnCrateStatic(_country, _unitId, _point, _name, _crateType.weight, _side, _hdg)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1958,7 +1956,16 @@ function ctld.spawnCrate(_arguments)
|
|||||||
|
|
||||||
local _heli = ctld.getTransportUnit(_args[1])
|
local _heli = ctld.getTransportUnit(_args[1])
|
||||||
|
|
||||||
|
local _model_type = nil
|
||||||
|
|
||||||
local _point = ctld.getPointAt12Oclock(_heli, 30)
|
local _point = ctld.getPointAt12Oclock(_heli, 30)
|
||||||
|
local _position = "12"
|
||||||
|
|
||||||
|
if ctld.unitDynamicCargoCapable(_heli) then
|
||||||
|
_model_type = "dynamic"
|
||||||
|
_point = ctld.getPointAt6Oclock(_heli, 15)
|
||||||
|
_position = "6"
|
||||||
|
end
|
||||||
|
|
||||||
local _unitId = ctld.getNextUnitId()
|
local _unitId = ctld.getNextUnitId()
|
||||||
|
|
||||||
@@ -1966,18 +1973,12 @@ function ctld.spawnCrate(_arguments)
|
|||||||
|
|
||||||
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
||||||
|
|
||||||
local _model_type = nil
|
ctld.spawnCrateStatic(_heli:getCountry(), _unitId, _point, _name, _crateType.weight, _side, 0, _model_type)
|
||||||
|
|
||||||
if ctld.unitDynamicCargoCapable(_heli) then
|
|
||||||
_model_type = "dynamic"
|
|
||||||
end
|
|
||||||
|
|
||||||
ctld.spawnCrateStatic(_heli:getCountry(), _unitId, _point, _name, _crateType.weight, _side, _model_type)
|
|
||||||
|
|
||||||
-- add to move table
|
-- add to move table
|
||||||
ctld.crateMove[_name] = _name
|
ctld.crateMove[_name] = _name
|
||||||
|
|
||||||
ctld.displayMessageToGroup(_heli, string.format("A %s crate weighing %s kg has been brought out and is at your 12 o'clock ", _crateType.desc, _crateType.weight), 20)
|
ctld.displayMessageToGroup(_heli, string.format("A %s crate weighing %s kg has been brought out and is at your %s o'clock ", _crateType.desc, _crateType.weight, _position), 20)
|
||||||
|
|
||||||
else
|
else
|
||||||
env.info("Couldn't find crate item to spawn")
|
env.info("Couldn't find crate item to spawn")
|
||||||
@@ -2000,6 +2001,17 @@ function ctld.getPointAt12Oclock(_unit, _offset)
|
|||||||
return { x = _point.x + _xOffset, z = _point.z + _yOffset, y = _point.y }
|
return { x = _point.x + _xOffset, z = _point.z + _yOffset, y = _point.y }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ctld.getPointAt6Oclock(_unit, _offset)
|
||||||
|
|
||||||
|
local _position = _unit:getPosition()
|
||||||
|
local _angle = math.atan2(_position.x.z, _position.x.x) + math.pi
|
||||||
|
local _xOffset = math.cos(_angle) * _offset
|
||||||
|
local _yOffset = math.sin(_angle) * _offset
|
||||||
|
|
||||||
|
local _point = _unit:getPoint()
|
||||||
|
return { x = _point.x + _xOffset, z = _point.z + _yOffset, y = _point.y }
|
||||||
|
end
|
||||||
|
|
||||||
function ctld.troopsOnboard(_heli, _troops)
|
function ctld.troopsOnboard(_heli, _troops)
|
||||||
|
|
||||||
if ctld.inTransitTroops[_heli:getName()] ~= nil then
|
if ctld.inTransitTroops[_heli:getName()] ~= nil then
|
||||||
@@ -3253,7 +3265,7 @@ function ctld.getClosestCrate(_heli, _crates, _type)
|
|||||||
local _closetCrate = nil
|
local _closetCrate = nil
|
||||||
local _shortestDistance = -1
|
local _shortestDistance = -1
|
||||||
local _distance = 0
|
local _distance = 0
|
||||||
local _minimumDistance = 5 -- prevents dynamic cargo crates from unpacking while in cargo hold
|
local _minimumDistance = 5 -- prevents dynamic cargo crates from unpacking while in cargo hold
|
||||||
|
|
||||||
for _, _crate in pairs(_crates) do
|
for _, _crate in pairs(_crates) do
|
||||||
|
|
||||||
@@ -3385,8 +3397,6 @@ function ctld.unpackCrates(_arguments)
|
|||||||
local _crateName = _crate.crateUnit:getName()
|
local _crateName = _crate.crateUnit:getName()
|
||||||
local _crateHdg = mist.getHeading(_crate.crateUnit, true)
|
local _crateHdg = mist.getHeading(_crate.crateUnit, true)
|
||||||
|
|
||||||
-- ctld.spawnCrateStatic( _heli:getCoalition(),ctld.getNextUnitId(),{x=100,z=100},_crateName,100)
|
|
||||||
|
|
||||||
--remove crate
|
--remove crate
|
||||||
-- if ctld.slingLoad == false then
|
-- if ctld.slingLoad == false then
|
||||||
_crate.crateUnit:destroy()
|
_crate.crateUnit:destroy()
|
||||||
@@ -3587,7 +3597,7 @@ function ctld.dropSlingCrate(_args)
|
|||||||
--remove crate from cargo
|
--remove crate from cargo
|
||||||
table.remove(ctld.inTransitSlingLoadCrates[_unitName],#ctld.inTransitSlingLoadCrates[_unitName])
|
table.remove(ctld.inTransitSlingLoadCrates[_unitName],#ctld.inTransitSlingLoadCrates[_unitName])
|
||||||
ctld.adaptWeightToCargo(_unitName)
|
ctld.adaptWeightToCargo(_unitName)
|
||||||
local _spawnedCrate = ctld.spawnCrateStatic(_heli:getCountry(), _unitId, _point, _name, _currentCrate.weight, _side,_hdg)
|
ctld.spawnCrateStatic(_heli:getCountry(), _unitId, _point, _name, _currentCrate.weight, _side, _hdg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5037,17 +5047,23 @@ function ctld.unitCanCarryVehicles(_unit)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ctld.unitDynamicCargoCapable(_unit)
|
function ctld.unitDynamicCargoCapable(_unit)
|
||||||
|
local cache = {}
|
||||||
local _type = string.lower(_unit:getTypeName())
|
local _type = string.lower(_unit:getTypeName())
|
||||||
|
local result = cache[_type]
|
||||||
for _, _name in ipairs(ctld.dynamicCargoUnits) do
|
if result == nil then
|
||||||
local _nameLower = string.lower(_name)
|
result = false
|
||||||
if string.find(_type, _nameLower, 1, true) then --string.match does not work with patterns containing '-' as it is a magic character
|
ctld.logDebug("ctld.unitDynamicCargoCapable(_type=[%s])", ctld.p(_type))
|
||||||
return true
|
for _, _name in ipairs(ctld.dynamicCargoUnits) do
|
||||||
end
|
local _nameLower = string.lower(_name)
|
||||||
end
|
if string.find(_type, _nameLower, 1, true) then --string.match does not work with patterns containing '-' as it is a magic character
|
||||||
|
result = true
|
||||||
return false
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cache[_type] = result
|
||||||
|
ctld.logDebug("result=[%s]", ctld.p(result))
|
||||||
|
end
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function ctld.isJTACUnitType(_type)
|
function ctld.isJTACUnitType(_type)
|
||||||
@@ -6028,7 +6044,7 @@ function ctld.createSmokeMarker(_enemyUnit, _colour)
|
|||||||
ctld.jtacSmokeMarks[_enemyUnit:getName()] = timer.getTime() + 300.0
|
ctld.jtacSmokeMarks[_enemyUnit:getName()] = timer.getTime() + 300.0
|
||||||
|
|
||||||
local _enemyPoint = _enemyUnit:getPoint()
|
local _enemyPoint = _enemyUnit:getPoint()
|
||||||
trigger.action.smoke({ x = _enemyPoint.x + math.random(0, ctld.JTAC_smokeMarginOfError) + ctld.JTAC_smokeOffset_x, y = _enemyPoint.y + ctld.JTAC_smokeOffset_y, z = _enemyPoint.z + math.random(0, ctld.JTAC_smokeMarginOfError) + ctld.JTAC_smokeOffset_z }, _colour)
|
trigger.action.smoke({ x = _enemyPoint.x + math.random(-ctld.JTAC_smokeMarginOfError, ctld.JTAC_smokeMarginOfError) + ctld.JTAC_smokeOffset_x, y = _enemyPoint.y + ctld.JTAC_smokeOffset_y, z = _enemyPoint.z + math.random(-ctld.JTAC_smokeMarginOfError, ctld.JTAC_smokeMarginOfError) + ctld.JTAC_smokeOffset_z }, _colour)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ctld.cancelLase(_jtacGroupName)
|
function ctld.cancelLase(_jtacGroupName)
|
||||||
|
|||||||
Reference in New Issue
Block a user