- added dynamic slots support in MiST v4.5.128-DYNSLOTS-01 (forked from the official MiST 4.5.128)

- added dynamic slots support in CTLD
- added dyn slots in the test mission
This commit is contained in:
David Pierron 2025-01-01 14:37:45 +01:00
parent a26c0f6a5d
commit c69314b5f0
3 changed files with 2878 additions and 615 deletions

View File

@ -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.
@ -5283,8 +5283,9 @@ function ctld.addTransportF10MenuOptions(_unitName)
if _groupId then if _groupId then
ctld.logTrace("_groupId = %s", ctld.p(_groupId)) ctld.logTrace("_groupId = %s", ctld.p(_groupId))
ctld.logTrace("ctld.addedTo = %s", ctld.p(ctld.addedTo))
if ctld.addedTo[tostring(_groupId)] == nil then if ctld.addedTo[tostring(_groupId)] == nil then
ctld.logTrace("adding CTLD menu for _groupId = %s", ctld.p(_groupId))
local _rootPath = missionCommands.addSubMenuForGroup(_groupId, "CTLD") local _rootPath = missionCommands.addSubMenuForGroup(_groupId, "CTLD")
local _unitActions = ctld.getUnitActions(_unitTypename) local _unitActions = ctld.getUnitActions(_unitTypename)
@ -5433,6 +5434,8 @@ function ctld.addTransportF10MenuOptions(_unitName)
end end
ctld.addedTo[tostring(_groupId)] = true ctld.addedTo[tostring(_groupId)] = true
ctld.logTrace("ctld.addedTo = %s", ctld.p(ctld.addedTo))
ctld.logTrace("done adding CTLD menu for _groupId = %s", ctld.p(_groupId))
end end
end end
end end
@ -5492,7 +5495,9 @@ function ctld.addRadioListCommand(_side)
if _groupId then if _groupId then
ctld.logTrace("ctld.addedTo = %s", ctld.p(ctld.addedTo))
if ctld.addedTo[tostring(_groupId)] == nil then if ctld.addedTo[tostring(_groupId)] == nil then
ctld.logTrace("adding List Radio Beacons for _groupId = %s", ctld.p(_groupId))
missionCommands.addCommandForGroup(_groupId, "List Radio Beacons", nil, ctld.listRadioBeacons, { _playerUnit:getName() }) missionCommands.addCommandForGroup(_groupId, "List Radio Beacons", nil, ctld.listRadioBeacons, { _playerUnit:getName() })
ctld.addedTo[tostring(_groupId)] = true ctld.addedTo[tostring(_groupId)] = true
end end
@ -7373,10 +7378,7 @@ function ctld.eventHandler:onEvent(event)
end end
-- check that we know the event -- check that we know the event
if not ( if event.id ~= 20 then -- S_EVENT_PLAYER_ENTER_UNIT
event.id == 15 -- S_EVENT_BIRTH"
or event.id == 20 -- S_EVENT_PLAYER_ENTER_UNIT
) then
return return
end end
@ -7384,47 +7386,63 @@ 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)) ctld.logDebug("caught event S_EVENT_PLAYER_ENTER_UNIT for unit [%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))
return return
end end
if mist.DBs.humansByName[unitName] then -- it's a human unit local nextSteps = coroutine.create(function()
ctld.logDebug("caught event BIRTH for human unit [%s]", ctld.p(unitName)) ctld.logTrace("in the 'nextSteps' coroutine")
local _unit = Unit.getByName(unitName) if mist.DBs.humansByName[unitName] then -- it's a human unit
if _unit ~= nil then ctld.logDebug("caught event S_EVENT_PLAYER_ENTER_UNIT for human unit [%s]", ctld.p(unitName))
-- assign transport pilot local _unit = Unit.getByName(unitName)
ctld.logTrace("_unit = %s", ctld.p(_unit)) if _unit ~= nil then
-- assign transport pilot
ctld.logTrace("_unit = %s", ctld.p(_unit))
local playerTypeName = _unit:getTypeName() local playerTypeName = _unit:getTypeName()
ctld.logTrace("playerTypeName = %s", ctld.p(playerTypeName)) ctld.logTrace("playerTypeName = %s", ctld.p(playerTypeName))
-- Allow units to CTLD by aircraft type and not by pilot name -- Allow units to CTLD by aircraft type and not by pilot name
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)) 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
ctld.addTransportF10MenuOptions(unitName) ctld.addTransportF10MenuOptions(unitName)
break break
end
end end
end 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))
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 end
end end
end end
end end
end end
end)
if not mist.DBs.humansByName[unitName] then
-- give a few milliseconds for MiST to handle the BIRTH event too
ctld.logTrace("give MiST some time to handle the BIRTH event too")
timer.scheduleFunction(function()
ctld.logTrace("resuming the 'nextSteps' coroutine in a timer")
coroutine.resume(nextSteps)
end, nil, timer.getTime() + 0.5)
else
ctld.logTrace("resuming the 'nextSteps' coroutine immediately")
coroutine.resume(nextSteps)
end end
end end
-- initialize the random number generator to make it almost random -- initialize the random number generator to make it almost random

3349
mist.lua

File diff suppressed because it is too large Load Diff

Binary file not shown.