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 <noreply@anthropic.com>
This commit is contained in:
Geoff Franks
2026-06-10 21:02:40 -04:00
parent 7c5af54473
commit edf70e971c
+7 -2
View File
@@ -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