5 Commits

Author SHA1 Message Date
David Pierron
b47614ecec wip 2024-12-28 17:23:18 +01:00
David Pierron
a26c0f6a5d Release 202412.01
**Release 202412.01**

Pulled some code from @atcz, @marcos2221, and @Queton1-1.

Added some features developped internally by the Virtual European Air Force (VEAF) team.

Changelog:
- VEAF: multipart AA Systems / AA crates stacking features
- VEAF: hardened legacy code to make it more resilient (less errors)
- Queton1-1: Allow units to CTLD by aircraft type and not by pilot name
- atcz: Use crate headings to spawn units
- marcos2221: multiple crate capability for mi8 and ch-47
- atcz: added pagination to the radio menus
- atcz: smartly used decimals to facilitate having a lot of units to load in our crates
- atcz: added lots of vehicles to transport
- VEAF: use DCS events to register pilots with CTLD
- VEAF: it's now possible to allow both sling, conventional (DCS, CH-47 only for now) and simulated sling (CTLD) loading at the same time, letting players choose
- VEAF: units capable of conventional loading (CH-47) now have the crates spawned at their 6-o'clock
- moved smoke marker randomly away from the JTAC target
- atcz: updated the soldier type for troops transport
- updated the cargo + troops load report (details the weight)
2024-12-17 17:55:18 +01:00
David Pierron
76a6dca72a updated test mission 2024-12-17 17:54:36 +01:00
David Pierron
55846e3109 hardened the code to avoid a nil value in ctld.setGrpROE 2024-12-17 09:02:41 +01:00
David Pierron
ebf72aaa44 updated test mission 2024-12-10 11:30:48 +01:00
2 changed files with 43 additions and 33 deletions

View File

@@ -34,11 +34,11 @@ ctld = {} -- DONT REMOVE!
ctld.Id = "CTLD - " ctld.Id = "CTLD - "
--- Version. --- Version.
ctld.Version = "202412.01" ctld.Version = "202412.02"
-- 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`
ctld.Debug = false ctld.Debug = true
ctld.Trace = false ctld.Trace = true
ctld.alreadyInitialized = false -- if true, ctld.initialize() will not run ctld.alreadyInitialized = false -- if true, ctld.initialize() will not run
@@ -50,7 +50,7 @@ ctld.staticBugWorkaround = false -- DCS had a bug where destroying statics woul
ctld.disableAllSmoke = false -- if true, all smoke is diabled at pickup and drop off zones regardless of settings below. Leave false to respect settings below ctld.disableAllSmoke = false -- if true, all smoke is diabled at pickup and drop off zones regardless of settings below. Leave false to respect settings below
-- Allow units to CTLD by aircraft type and not by pilot name - this is done everytime a player enters a new unit -- Allow units to CTLD by aircraft type and not by pilot name - this is done everytime a player enters a new unit
ctld.addPlayerAircraftByType = false ctld.addPlayerAircraftByType = true
ctld.hoverPickup = true -- if set to false you can load crates with the F10 menu instead of hovering... Only if not using real crates! ctld.hoverPickup = true -- if set to false you can load crates with the F10 menu instead of hovering... Only if not using real crates!
ctld.loadCrateFromMenu = false -- if set to true, you can load crates with the F10 menu OR hovering, in case of using choppers and planes for example. ctld.loadCrateFromMenu = false -- if set to true, you can load crates with the F10 menu OR hovering, in case of using choppers and planes for example.
@@ -682,15 +682,15 @@ ctld.loadableGroups = {
{name = "Mortar Squad", mortar = 6 }, {name = "Mortar Squad", mortar = 6 },
{name = "JTAC Group", inf = 4, jtac = 1 }, -- will make a loadable group with 4 infantry and a JTAC soldier for both coalitions {name = "JTAC Group", inf = 4, jtac = 1 }, -- will make a loadable group with 4 infantry and a JTAC soldier for both coalitions
{name = "Single JTAC", jtac = 1 }, -- will make a loadable group witha single JTAC soldier for both coalitions {name = "Single JTAC", jtac = 1 }, -- will make a loadable group witha single JTAC soldier for both coalitions
{name = "2x - Standard Groups", inf = 12, mg = 4, at = 4 }, {name = "2x - Standard Groups", list = {"Standard Group", "Standard Group"}},
{name = "2x - Anti Air", inf = 4, aa = 6 }, {name = "2x - Anti Airs", list = {"Anti Air", "Anti Air"}},
{name = "2x - Anti Tank", inf = 4, at = 12 }, {name = "2x - Anti Tanks", list = {"Anti Tank", "Anti Tank"}},
{name = "2x - Standard Groups + 2x Mortar", inf = 12, mg = 4, at = 4, mortar = 12 }, {name = "2x - Standard Groups + 2x Mortar", list = {"Standard Group", "Standard Group", "Mortar Squad", "Mortar Squad"}},
{name = "3x - Standard Groups", inf = 18, mg = 6, at = 6 }, {name = "2x - Standard Groups", list = {"Standard Group", "Standard Group", "Standard Group"}},
{name = "3x - Anti Air", inf = 6, aa = 9 }, {name = "2x - Anti Airs", list = {"Anti Air", "Anti Air", "Anti Air"}},
{name = "3x - Anti Tank", inf = 6, at = 18 }, {name = "2x - Anti Tanks", list = {"Anti Tank", "Anti Tank", "Anti Tank"}},
{name = "3x - Mortar Squad", mortar = 18}, {name = "3x - Mortar Squad", list = {"Mortar Squad", "Mortar Squad", "Mortar Squad"}},
{name = "5x - Mortar Squad", mortar = 30}, {name = "5x - Mortar Squad", list = {"Mortar Squad", "Mortar Squad", "Mortar Squad", "Mortar Squad", "Mortar Squad"}},
-- {name = "Mortar Squad Red", inf = 2, mortar = 5, side =1 }, --would make a group loadable by RED only -- {name = "Mortar Squad Red", inf = 2, mortar = 5, side =1 }, --would make a group loadable by RED only
} }
@@ -5276,12 +5276,13 @@ function ctld.addTransportF10MenuOptions(_unitName)
local status, error = pcall(function() local status, error = pcall(function()
local _unit = ctld.getTransportUnit(_unitName) local _unit = ctld.getTransportUnit(_unitName)
ctld.logTrace("_unit = %s", ctld.p(_unit))
if _unit then if _unit then
local _unitTypename = _unit:getTypeName() local _unitTypename = _unit:getTypeName()
local _groupId = ctld.getGroupId(_unit) local _groupId = ctld.getGroupId(_unit)
if _groupId then if _groupId then
ctld.logTrace("_groupId = %s", ctld.p(_groupId))
if ctld.addedTo[tostring(_groupId)] == nil then if ctld.addedTo[tostring(_groupId)] == nil then
local _rootPath = missionCommands.addSubMenuForGroup(_groupId, "CTLD") local _rootPath = missionCommands.addSubMenuForGroup(_groupId, "CTLD")
@@ -5317,7 +5318,7 @@ function ctld.addTransportF10MenuOptions(_unitName)
menuPath = missionCommands.addSubMenuForGroup(_groupId, "Next page", menuPath) menuPath = missionCommands.addSubMenuForGroup(_groupId, "Next page", menuPath)
itemNb = 1 itemNb = 1
end end
missionCommands.addCommandForGroup(_groupId, _menu.text, menuPath, ctld.loadTroopsFromZone, { _unitName, true,_menu.group,false }) missionCommands.addCommandForGroup(_groupId, _menu.text, menuPath, ctld.loadTroopsFromZone, { _unitName, true, _menu.group, false })
end end
if ctld.unitCanCarryVehicles(_unit) then if ctld.unitCanCarryVehicles(_unit) then
@@ -6770,9 +6771,7 @@ function ctld.setGrpROE(_grp, _ROE)
_ROE = AI.Option.Ground.val.ROE.OPEN_FIRE _ROE = AI.Option.Ground.val.ROE.OPEN_FIRE
end end
_grp = ctld.getAliveGroup(_grp) if _grp and _grp:isExist() == true and #_grp:getUnits() > 0 then -- check if the group truly exists
if _grp ~= nil then
local _controller = _grp:getController(); local _controller = _grp:getController();
Controller.setOption(_controller, AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO) Controller.setOption(_controller, AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO)
Controller.setOption(_controller, AI.Option.Ground.id.ROE, _ROE) Controller.setOption(_controller, AI.Option.Ground.id.ROE, _ROE)
@@ -7242,34 +7241,41 @@ function ctld.initialize(force)
end end
end end
-- add total count local function countGroup(group)
local result = 0
for _,_loadGroup in pairs(ctld.loadableGroups) do if group.aa then
result = group.aa + result
_loadGroup.total = 0
if _loadGroup.aa then
_loadGroup.total = _loadGroup.aa + _loadGroup.total
end end
if _loadGroup.inf then if group.inf then
_loadGroup.total = _loadGroup.inf + _loadGroup.total result = group.inf + result
end end
if _loadGroup.mg then if group.mg then
_loadGroup.total = _loadGroup.mg + _loadGroup.total result = group.mg + result
end end
if _loadGroup.at then if group.at then
_loadGroup.total = _loadGroup.at + _loadGroup.total result = group.at + result
end end
if _loadGroup.mortar then if group.mortar then
_loadGroup.total = _loadGroup.mortar + _loadGroup.total result = group.mortar + result
end end
return result
end end
-- add total count
for _, group in pairs(ctld.loadableGroups) do
group.total = countGroup(group)
if group.list then
for _, subGroup in pairs(group.list) do
group.total = group.total + countGroup(subGroup)
end
end
end
-- Scheduled functions (run cyclically) -- but hold execution for a second so we can override parts -- Scheduled functions (run cyclically) -- but hold execution for a second so we can override parts
@@ -7367,6 +7373,7 @@ end
--- Handle world events. --- Handle world events.
ctld.eventHandler = {} ctld.eventHandler = {}
function ctld.eventHandler:onEvent(event) function ctld.eventHandler:onEvent(event)
ctld.logTrace("ctld.eventHandler:onEvent(), event = %s", ctld.p(event))
if event == nil then if event == nil then
ctld.logError("Event handler was called with a nil event!") ctld.logError("Event handler was called with a nil event!")
return return
@@ -7384,6 +7391,7 @@ function ctld.eventHandler:onEvent(event)
local unitName = nil local unitName = nil
if event.initiator ~= nil and event.initiator.getName then if event.initiator ~= nil and event.initiator.getName then
unitName = event.initiator:getName() unitName = event.initiator:getName()
ctld.logTrace("unitName = %s", ctld.p(unitName))
end end
if not unitName then if not unitName then
ctld.logWarning("no unitname found in event %s", ctld.p(event)) ctld.logWarning("no unitname found in event %s", ctld.p(event))
@@ -7404,6 +7412,7 @@ function ctld.eventHandler:onEvent(event)
if ctld.addPlayerAircraftByType then if ctld.addPlayerAircraftByType then
for _,aircraftType in pairs(ctld.aircraftTypeTable) do for _,aircraftType in pairs(ctld.aircraftTypeTable) do
if aircraftType == playerTypeName then if aircraftType == playerTypeName then
ctld.logTrace("adding by aircraft type, unitName = %s", ctld.p(unitName))
-- add transport unit to the list -- add transport unit to the list
table.insert(ctld.transportPilotNames, unitName) table.insert(ctld.transportPilotNames, unitName)
-- add transport radio menu -- add transport radio menu
@@ -7414,6 +7423,7 @@ function ctld.eventHandler:onEvent(event)
else else
for _, _unitName in pairs(ctld.transportPilotNames) do for _, _unitName in pairs(ctld.transportPilotNames) do
if _unitName == unitName then if _unitName == unitName then
ctld.logTrace("adding by transportPilotNames, unitName = %s", ctld.p(unitName))
-- add transport radio menu -- add transport radio menu
ctld.addTransportF10MenuOptions(unitName) ctld.addTransportF10MenuOptions(unitName)
break break

Binary file not shown.