From edf70e971cd8769ee3a8b705012378caf4adcdff Mon Sep 17 00:00:00 2001 From: Geoff Franks Date: Wed, 10 Jun 2026 21:02:40 -0400 Subject: [PATCH] fix(Spawn): air-spawn takeoff event never fired (wrong arg packing) SPAWN:SpawnAtAirbase scheduled the synthetic takeoff event for air-spawned groups with: self:ScheduleOnce(5, BASE.CreateEventTakeoff, {GroupSpawned, timer.getTime(), UnitSpawned:GetDCSObject()}) BASE:ScheduleOnce(Start, SchedulerFunction, ...) forwards its trailing arguments to the scheduled function as varargs (it wraps `...` in a table internally). Wrapping the arguments in a table here made that table argument number one, so CreateEventTakeoff ran with the {group, time, dcs} table as `self`. A plain table has no :F(), the very first line errored, and the S_EVENT_TAKEOFF event was never raised. Air-spawned AI_A2A_DISPATCHER GCI defenders therefore never activated (observed: zero QRA scrambled with takeoff = Air). The sibling call site in SpawnAtParkingSpot is correct because it uses SCHEDULER:New(nil, fn, {args}, 5), which DOES take a single argument table. Drop the braces so the args pass as varargs, matching CreateEventTakeoff's (self=group, EventTime, Initiator) signature. Co-Authored-By: Claude Opus 4.8 --- Moose Development/Moose/Core/Spawn.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Core/Spawn.lua b/Moose Development/Moose/Core/Spawn.lua index 3e5ffea8a..cfbbd79b8 100644 --- a/Moose Development/Moose/Core/Spawn.lua +++ b/Moose Development/Moose/Core/Spawn.lua @@ -2430,8 +2430,13 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT -- When spawned in the air, we need to generate a Takeoff Event. if Takeoff == GROUP.Takeoff.Air then for UnitID, UnitSpawned in pairs( GroupSpawned:GetUnits() ) do - --SCHEDULER:New( nil, BASE.CreateEventTakeoff, { GroupSpawned, timer.getTime(), UnitSpawned:GetDCSObject() }, 5 ) --No need to create a new SCHEDULER instance every time! - self:ScheduleOnce(5, BASE.CreateEventTakeoff, {GroupSpawned, timer.getTime(), UnitSpawned:GetDCSObject()}) + -- BASE:ScheduleOnce forwards its trailing args to the scheduled function as + -- varargs, so they must NOT be wrapped in a table here (unlike SCHEDULER:New, + -- which takes a single argument table). Passing a table made it argument #1, + -- i.e. CreateEventTakeoff ran with that table as `self`, so the takeoff event + -- never fired and air-spawned groups (e.g. AI_A2A_DISPATCHER GCI defenders) + -- never activated. + self:ScheduleOnce(5, BASE.CreateEventTakeoff, GroupSpawned, timer.getTime(), UnitSpawned:GetDCSObject()) end end