dynamic-cargo

This commit is contained in:
spencershepard 2024-08-18 20:33:20 -07:00 committed by Spencer Shepard
parent 892f12fc98
commit 16429df96c
2 changed files with 75 additions and 35 deletions

View File

@ -14,6 +14,7 @@ client_helos = [
player_helos = [ player_helos = [
dcs.helicopters.AH_64D_BLK_II, dcs.helicopters.AH_64D_BLK_II,
dcs.helicopters.CH_47Fbl1,
dcs.helicopters.Ka_50, dcs.helicopters.Ka_50,
dcs.helicopters.Ka_50_3, dcs.helicopters.Ka_50_3,
dcs.helicopters.Mi_8MT, dcs.helicopters.Mi_8MT,

View File

@ -18,6 +18,8 @@
- davidp57 - https://github.com/veaf - davidp57 - https://github.com/veaf
- Queton1-1 - https://github.com/Queton1-1 - Queton1-1 - https://github.com/Queton1-1
- Proxy404 - https://github.com/Proxy404 - Proxy404 - https://github.com/Proxy404
- GRIMM - https://github.com/spencershepard
]] ]]
ctld = {} -- DONT REMOVE! ctld = {} -- DONT REMOVE!
@ -26,7 +28,7 @@
ctld.Id = "CTLD - " ctld.Id = "CTLD - "
--- Version. --- Version.
ctld.Version = "202401.01" ctld.Version = "202408.01"
--https://github.com/spencershepard/DCS-CTLD/tree/rotorops --https://github.com/spencershepard/DCS-CTLD/tree/rotorops
-- To add debugging messages to dcs.log, change the following log levels to `true`; `Debug` is less detailed than `Trace` -- To add debugging messages to dcs.log, change the following log levels to `true`; `Debug` is less detailed than `Trace`
@ -93,7 +95,7 @@
ctld.buildTimeFOB = 120 --time in seconds for the FOB to be built ctld.buildTimeFOB = 120 --time in seconds for the FOB to be built
ctld.crateWaitTime = 120 -- time in seconds to wait before you can spawn another crate ctld.crateWaitTime = 60 -- time in seconds to wait before you can spawn another crate
ctld.forceCrateToBeMoved = true -- a crate must be picked up at least once and moved before it can be unpacked. Helps to reduce crate spam ctld.forceCrateToBeMoved = true -- a crate must be picked up at least once and moved before it can be unpacked. Helps to reduce crate spam
@ -422,6 +424,14 @@
"Hercules", "Hercules",
} }
-- ************** Units able to use DCS dynamic cargo system ******************
-- DCS (version) added the ability to load and unload cargo from aircraft.
-- Units listed here will spawn a cargo static that can be loaded with the standard DCS cargo system
-- We will also use this to make modifications to the menu and other checks and messages
ctld.dynamicCargoUnits = {
"CH-47Fbl1",
}
-- ************** Maximum Units SETUP for UNITS ****************** -- ************** Maximum Units SETUP for UNITS ******************
@ -584,19 +594,28 @@
}, },
} }
--- 3D model that will be used to represent a loadable crate ; by default, a generator ctld.spawnableCratesModels = {
ctld.spawnableCratesModel_load = { ["load"] = {
["category"] = "Fortifications", ["category"] = "Fortifications",
["shape_name"] = "GeneratorF", ["shape_name"] = "GeneratorF",
["type"] = "GeneratorF" ["type"] = "GeneratorF",
} ["canCargo"] = false,
},
--- 3D model that will be used to represent a slingable crate ; by default, a crate ["sling"] = {
ctld.spawnableCratesModel_sling = {
["category"] = "Cargos", ["category"] = "Cargos",
["shape_name"] = "bw_container_cargo", ["shape_name"] = "bw_container_cargo",
["type"] = "container_cargo" ["type"] = "container_cargo",
["canCargo"] = true
},
["dynamic"] = {
["category"] = "Cargos",
["shape_name"] = "ammo_box_cargo",
["type"] = "ammo_cargo",
["canCargo"] = true
} }
}
--[[ Placeholder for different type of cargo containers. Let's say pipes and trunks, fuel for FOB building --[[ Placeholder for different type of cargo containers. Let's say pipes and trunks, fuel for FOB building
["shape_name"] = "ab-212_cargo", ["shape_name"] = "ab-212_cargo",
@ -1536,7 +1555,7 @@
return nil return nil
end end
function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight,_side) function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight, _side, _model_type)
local _crate local _crate
local _spawnedCrate local _spawnedCrate
@ -1570,12 +1589,12 @@
_spawnedCrate = Unit.getByName(_name) _spawnedCrate = Unit.getByName(_name)
else else
if ctld.slingLoad then if _model_type ~= nil then
_crate = mist.utils.deepCopy(ctld.spawnableCratesModel_sling) _crate = mist.utils.deepCopy(ctld.spawnableCratesModels[_model_type])
_crate["canCargo"] = true elseif ctld.slingLoad then
_crate = mist.utils.deepCopy(ctld.spawnableCratesModels["sling"])
else else
_crate = mist.utils.deepCopy(ctld.spawnableCratesModel_load) _crate = mist.utils.deepCopy(ctld.spawnableCratesModels["load"])
_crate["canCargo"] = false
end end
_crate["y"] = _point.z _crate["y"] = _point.z
@ -1733,7 +1752,13 @@
local _name = string.format("%s #%i", _crateType.desc, _unitId) local _name = string.format("%s #%i", _crateType.desc, _unitId)
local _spawnedCrate = ctld.spawnCrateStatic(_heli:getCountry(), _unitId, _point, _name, _crateType.weight,_side) local _model_type = nil
if ctld.unitDynamicCargoCapable(_heli) then
_model_type = "dynamic"
end
local _spawnedCrate = 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
@ -2601,7 +2626,7 @@
local _transUnit = ctld.getTransportUnit(_name) local _transUnit = ctld.getTransportUnit(_name)
--only check transports that are hovering and not planes --only check transports that are hovering and not planes
if _transUnit ~= nil and ctld.inTransitSlingLoadCrates[_name] == nil and ctld.inAir(_transUnit) and ctld.unitCanCarryVehicles(_transUnit) == false then if _transUnit ~= nil and ctld.inTransitSlingLoadCrates[_name] == nil and ctld.inAir(_transUnit) and ctld.unitCanCarryVehicles(_transUnit) == false and not ctld.unitDynamicCargoCapable(_transUnit) then
local _crates = ctld.getCratesAndDistance(_transUnit) local _crates = ctld.getCratesAndDistance(_transUnit)
@ -3105,7 +3130,7 @@
elseif _crate ~= nil and _crate.dist < 200 then elseif _crate ~= nil and _crate.dist < 200 then
if ctld.forceCrateToBeMoved and ctld.crateMove[_crate.crateUnit:getName()] then if ctld.forceCrateToBeMoved and ctld.crateMove[_crate.crateUnit:getName()] and not ctld.unitDynamicCargoCapable(_heli) then
ctld.displayMessageToGroup(_heli,"Sorry you must move this crate before you unpack it!", 20) ctld.displayMessageToGroup(_heli,"Sorry you must move this crate before you unpack it!", 20)
return return
end end
@ -4688,7 +4713,21 @@
for _, _name in ipairs(ctld.vehicleTransportEnabled) do for _, _name in ipairs(ctld.vehicleTransportEnabled) do
local _nameLower = string.lower(_name) local _nameLower = string.lower(_name)
if string.match(_type, _nameLower) then if string.find(_type, _nameLower, 1, true) then
return true
end
end
return false
end
function ctld.unitDynamicCargoCapable(_unit)
local _type = string.lower(_unit:getTypeName())
for _, _name in ipairs(ctld.dynamicCargoUnits) do
local _nameLower = string.lower(_name)
if string.find(_type, _nameLower, 1, true) then --string.match does not work with patterns containing '-' as it is a magic character
return true return true
end end
end end