Added zone activation/deactivation messages.

This commit is contained in:
iTracerFacer 2025-11-05 08:28:11 -06:00
parent a02e439092
commit 7b56a17661
2 changed files with 29 additions and 4 deletions

View File

@ -141,6 +141,10 @@ CTLD.Messages = {
coach_loaded = "Crate is hooked! Nice flying!", coach_loaded = "Crate is hooked! Nice flying!",
coach_hover_lost = "Movement detected—recover hover to load.", coach_hover_lost = "Movement detected—recover hover to load.",
coach_abort = "Hover lost. Reacquire within 25 m, GS < 8 km/h, AGL 520 m.", coach_abort = "Hover lost. Reacquire within 25 m, GS < 8 km/h, AGL 520 m.",
-- Zone state changes
zone_activated = "{kind} Zone {zone} is now ACTIVE.",
zone_deactivated = "{kind} Zone {zone} is now INACTIVE.",
} }
CTLD.Config = { CTLD.Config = {
@ -514,7 +518,7 @@ function CTLD:_removeZoneDrawing(kind, zname)
end end
-- Public: set a specific zone active/inactive by kind and name -- Public: set a specific zone active/inactive by kind and name
function CTLD:SetZoneActive(kind, name, active) function CTLD:SetZoneActive(kind, name, active, silent)
if not (kind and name) then return end if not (kind and name) then return end
local k = (kind == 'Pickup' or kind == 'Drop' or kind == 'FOB') and kind or nil local k = (kind == 'Pickup' or kind == 'Drop' or kind == 'FOB') and kind or nil
if not k then return end if not k then return end
@ -546,6 +550,10 @@ function CTLD:SetZoneActive(kind, name, active)
-- Optional messaging -- Optional messaging
local stateStr = self._ZoneActive[k][name] and 'ACTIVATED' or 'DEACTIVATED' local stateStr = self._ZoneActive[k][name] and 'ACTIVATED' or 'DEACTIVATED'
env.info(string.format('[Moose_CTLD] Zone %s %s (%s)', tostring(name), stateStr, k)) env.info(string.format('[Moose_CTLD] Zone %s %s (%s)', tostring(name), stateStr, k))
if not silent then
local msgKey = self._ZoneActive[k][name] and 'zone_activated' or 'zone_deactivated'
_eventSend(self, nil, self.Side, msgKey, { kind = k, zone = name })
end
end end
function CTLD:DrawZonesOnMap() function CTLD:DrawZonesOnMap()
@ -812,7 +820,24 @@ function CTLD:New(cfg)
o._BindingsMerged = merged o._BindingsMerged = merged
if o._BindingsMerged and #o._BindingsMerged > 0 then if o._BindingsMerged and #o._BindingsMerged > 0 then
o._ZoneFlagState = {} o._ZoneFlagState = {}
o._ZoneFlagsPrimed = false
o.ZoneFlagSched = SCHEDULER:New(nil, function() o.ZoneFlagSched = SCHEDULER:New(nil, function()
if not o._ZoneFlagsPrimed then
-- Prime states on first run without spamming messages
for _,b in ipairs(o._BindingsMerged) do
if b and b.flag and b.kind and b.name then
local val = (trigger and trigger.misc and trigger.misc.getUserFlag) and trigger.misc.getUserFlag(b.flag) or 0
local activeWhen = (b.activeWhen ~= nil) and b.activeWhen or 1
local shouldBeActive = (val == activeWhen)
local key = tostring(b.kind)..'|'..tostring(b.name)
o._ZoneFlagState[key] = shouldBeActive
o:SetZoneActive(b.kind, b.name, shouldBeActive, true)
end
end
o._ZoneFlagsPrimed = true
return
end
-- Subsequent runs: announce changes
for _,b in ipairs(o._BindingsMerged) do for _,b in ipairs(o._BindingsMerged) do
if b and b.flag and b.kind and b.name then if b and b.flag and b.kind and b.name then
local val = (trigger and trigger.misc and trigger.misc.getUserFlag) and trigger.misc.getUserFlag(b.flag) or 0 local val = (trigger and trigger.misc and trigger.misc.getUserFlag) and trigger.misc.getUserFlag(b.flag) or 0
@ -821,7 +846,7 @@ function CTLD:New(cfg)
local key = tostring(b.kind)..'|'..tostring(b.name) local key = tostring(b.kind)..'|'..tostring(b.name)
if o._ZoneFlagState[key] ~= shouldBeActive then if o._ZoneFlagState[key] ~= shouldBeActive then
o._ZoneFlagState[key] = shouldBeActive o._ZoneFlagState[key] = shouldBeActive
o:SetZoneActive(b.kind, b.name, shouldBeActive) o:SetZoneActive(b.kind, b.name, shouldBeActive, false)
end end
end end
end end

View File

@ -18,7 +18,7 @@ ctldBlue = _MOOSE_CTLD:New({
CoalitionSide = coalition.side.BLUE, CoalitionSide = coalition.side.BLUE,
PickupZoneSmokeColor = trigger.smokeColor.Blue, PickupZoneSmokeColor = trigger.smokeColor.Blue,
AllowedAircraft = { -- transport-capable unit type names (case-sensitive as in DCS DB) AllowedAircraft = { -- transport-capable unit type names (case-sensitive as in DCS DB)
'UH-1H','Mi-8MTV2','Mi-24P','SA342M','SA342L','SA342Minigun','Ka-50','Ka-50_3','AH-64D_BLK_II','UH-60L','CH-47Fbl1','CH-47F','Mi-17','GazelleAI' 'UH-1H','Mi-8MTV2','Mi-24P','SA342M','SA342L','SA342Minigun','UH-60L','CH-47Fbl1','CH-47F','Mi-17','GazelleAI'
}, },
-- Optional: drive zone activation from mission flags (preferred: set per-zone below via flag/activeWhen) -- Optional: drive zone activation from mission flags (preferred: set per-zone below via flag/activeWhen)
@ -34,7 +34,7 @@ ctldRed = _MOOSE_CTLD:New({
CoalitionSide = coalition.side.RED, CoalitionSide = coalition.side.RED,
PickupZoneSmokeColor = trigger.smokeColor.Red, PickupZoneSmokeColor = trigger.smokeColor.Red,
AllowedAircraft = { -- transport-capable unit type names (case-sensitive as in DCS DB) AllowedAircraft = { -- transport-capable unit type names (case-sensitive as in DCS DB)
'UH-1H','Mi-8MTV2','Mi-24P','SA342M','SA342L','SA342Minigun','Ka-50','Ka-50_3','AH-64D_BLK_II','UH-60L','CH-47Fbl1','CH-47F','Mi-17','GazelleAI' 'UH-1H','Mi-8MTV2','Mi-24P','SA342M','SA342L','SA342Minigun','UH-60L','CH-47Fbl1','CH-47F','Mi-17','GazelleAI'
}, },
-- Optional: drive zone activation for RED via per-zone flag/activeWhen -- Optional: drive zone activation for RED via per-zone flag/activeWhen