From 7b56a17661cc153e663cc489f727c2c81558c201 Mon Sep 17 00:00:00 2001 From: iTracerFacer <134304944+iTracerFacer@users.noreply.github.com> Date: Wed, 5 Nov 2025 08:28:11 -0600 Subject: [PATCH] Added zone activation/deactivation messages. --- Moose_CTLD_Pure/Moose_CTLD.lua | 29 +++++++++++++++++-- .../init_mission_dual_coalition.lua | 4 +-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Moose_CTLD_Pure/Moose_CTLD.lua b/Moose_CTLD_Pure/Moose_CTLD.lua index 48f14bd..4e467a3 100644 --- a/Moose_CTLD_Pure/Moose_CTLD.lua +++ b/Moose_CTLD_Pure/Moose_CTLD.lua @@ -141,6 +141,10 @@ CTLD.Messages = { coach_loaded = "Crate is hooked! Nice flying!", coach_hover_lost = "Movement detected—recover hover to load.", coach_abort = "Hover lost. Reacquire within 25 m, GS < 8 km/h, AGL 5–20 m.", + + -- Zone state changes + zone_activated = "{kind} Zone {zone} is now ACTIVE.", + zone_deactivated = "{kind} Zone {zone} is now INACTIVE.", } CTLD.Config = { @@ -514,7 +518,7 @@ function CTLD:_removeZoneDrawing(kind, zname) end -- 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 local k = (kind == 'Pickup' or kind == 'Drop' or kind == 'FOB') and kind or nil if not k then return end @@ -546,6 +550,10 @@ function CTLD:SetZoneActive(kind, name, active) -- Optional messaging local stateStr = self._ZoneActive[k][name] and 'ACTIVATED' or 'DEACTIVATED' 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 function CTLD:DrawZonesOnMap() @@ -812,7 +820,24 @@ function CTLD:New(cfg) o._BindingsMerged = merged if o._BindingsMerged and #o._BindingsMerged > 0 then o._ZoneFlagState = {} + o._ZoneFlagsPrimed = false 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 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 @@ -821,7 +846,7 @@ function CTLD:New(cfg) local key = tostring(b.kind)..'|'..tostring(b.name) if o._ZoneFlagState[key] ~= shouldBeActive then o._ZoneFlagState[key] = shouldBeActive - o:SetZoneActive(b.kind, b.name, shouldBeActive) + o:SetZoneActive(b.kind, b.name, shouldBeActive, false) end end end diff --git a/Moose_CTLD_Pure/init_mission_dual_coalition.lua b/Moose_CTLD_Pure/init_mission_dual_coalition.lua index 9e29af1..cf210e0 100644 --- a/Moose_CTLD_Pure/init_mission_dual_coalition.lua +++ b/Moose_CTLD_Pure/init_mission_dual_coalition.lua @@ -18,7 +18,7 @@ ctldBlue = _MOOSE_CTLD:New({ CoalitionSide = coalition.side.BLUE, PickupZoneSmokeColor = trigger.smokeColor.Blue, 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) @@ -34,7 +34,7 @@ ctldRed = _MOOSE_CTLD:New({ CoalitionSide = coalition.side.RED, PickupZoneSmokeColor = trigger.smokeColor.Red, 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