HomingMissile
Module: homingmissile.lua
Overview
The HomingMissile module represents a homing missile in the game world. It inherits from the Blippable module to manage radar blips and adds specific behavior for flashing blips at regular intervals.
Inheritance
- Inherits from:
Blippable - Imports:
none
Instance pattern
This is the Blippable rich-instance pattern (keyed by uGuid): OnActivate calls getfenv():Create(uGuid, uRuntimeOwner) to mint a per-object instance whose prototype is this module. The module-level blip fields become the prototype defaults every instance inherits:
tColor={255, 0, 0}(red) β default radar blip color.tFlash={255, 255, 255}(white) β the color it flashes to.nSize=1,nSortOrder=1,sTexture=nil(no custom texture β uses the Blippable default).
Per-instance runtime fields set on oSelf:
bActive: settrueby_HomingLaunchedonce the missile is live.bFlash: toggled every tick by the flash timer; passed toAddObjectiveto alternate the blip color.TimerEvent: handle to the persistent flash timer (see Events); guarded so itβs only created once.
Functions
OnActivate(uGuid, uRuntimeOwner, iArg)
Called when the missile instance is activated. It creates a new per-instance table for the object using the moduleβs prototype.
SetBlipped(oSelf)
Calls Blippable.SetBlipped(oSelf) (the inherited base), then β if oSelf.TimerEvent isnβt already set β registers a persistent Event.TimerRelative at 0.1 s that flips oSelf.bFlash and calls oSelf:AddObjective(oSelf.bFlash) each tick, producing the flashing blip. The handle is stored in oSelf.TimerEvent.
ClearBlipped(oSelf)
Removes the radar blip and marker for the missile. Deletes the timer event if it exists.
_HomingLaunched(oWidget, tData)
A helper function that activates the missile when it is launched. It sets the missile as active and calls SetBlipped to add its blip.
Confirmed: this does not spawn or fire the missile itself, despite the module name β it only reacts to one that already exists. tData carries a reference to an already-live missile object (uAmmoGuid per the calling convention used at AntiAirβs own _HomingLaunched, which just forwards here). The real spawn/launch is handled by something native, outside this file entirely β see AntiAirβs notes and Junk.SpawnHomingProjectile for the likely (unconfirmed) mechanism, and Airstrike for the other, confirmed projectile-spawning namespace this module does not use.
Not wired via Event.Create in this file. HomingMissile._HomingLaunched is invoked as a plain cross-module function call, directly from antiair.luaβs own _HomingLaunched(oWidget, tData) (confirmed: src/resident/antiair.lua:399 reads HomingMissile._HomingLaunched(oWidget, tData)). AntiAirβs version is presumably the actual event/widget-callback target registered with the engine β that registration is AntiAirβs concern, not this fileβs. homingmissile.lua itself contains zero Event.* references of any kind.
Events
Event.TimerRelativeβ oneEvent.CreatePersistent(Event.TimerRelative, {0.1}, ...)inSetBlipped, driving the 0.1 s blip flash. Deleted inClearBlipped. This is the onlyEvent.*reference in the file._HomingLaunchedis not an event. Itβs a plain function called directly by AntiAir (src/resident/antiair.lua:399βHomingMissile._HomingLaunched(oWidget, tData)), not anEvent.Createregistration. Any engine event/widget wiring lives inAntiAir, not here.
Notes for modders
- Blip appearance: change the module-level
tColor({255,0,0}),tFlash({255,255,255}),nSize(1), andsTexture(nil) to restyle the radar blip β these are inherited by every instance from Blippable. SetsTextureto a texture name to give it a custom icon. - Flash rate: the
0.1inSetBlippedβsEvent.TimerRelativeis the flash period; raise it to slow the blink. - What this module does not do: it does not spawn or fly the missile β it only blips one that already exists. The launch is driven by AntiAir / native code, which calls
_HomingLaunchedwithtData.uAmmoGuididentifying the live projectile.