Paratrooper
Module: paratrooper.lua
Overview
The Paratrooper module is the script on a falling paratrooper (the soldier spawned by Paradrop). Its only job is the mid-air-to-ground handoff: once the trooper’s health drops below 100 — i.e. as soon as it takes any damage, including the landing impact — it swaps the parachuting paratrooper object for a normal grounded “airborne” faction unit at the same position/heading.
Inheritance
- Inherits from: none — base/utility module
- Imports:
MrxUtil
Instance pattern
Not the Inheritable pattern — this file has no inherit(...) call at all. Confirmed from source: tEvents = tEvents or {} is declared at module scope but never actually indexed or assigned anywhere in the file — genuinely dead/vestigial, not a real per-uGuid table in active use. Each activation just runs its reactive OnActivate → Start → RemoveChute chain directly on the uGuid passed through as a plain argument, with no stored per-instance state at all.
Functions
OnActivate(uGuid, iArg)
Called when the paratrooper instance is activated. It sets up an event to call Start once the object leaves hibernation.
Start(uGuid, iArg)
Sets up an event listener for the Event.ObjectHealth event, which triggers when the paratrooper’s health drops below 100. This event calls RemoveChute.
RemoveChute(uGuid, iArg)
Reads the trooper’s faction (MrxUtil.GetFaction), position and yaw, fades the paratrooper object out over 0.25s (Object.Remove(uGuid, 0.25)), and spawns tTemplates[sFaction] ("Chinese Airborne" / "Allied Airborne") at the same spot via Pg.Spawn. iArg is threaded through the whole chain but never used.
The trailing
Object.SetYaw(uGuid, yaw)runs afterObject.Remove(uGuid, ...), so it targets the object being faded out (the newly spawned unit already got its yaw from thePg.Spawncall) — a harmless leftover.
Events
Both are real Event.Create subscriptions:
Event.ObjectHibernation("awake", inOnActivate) →Start.Event.ObjectHealthfiltered"<", "100"(inStart) →RemoveChute. Note the threshold is passed as the string"100", matching the engine’s filter format.
Module constants & tunables
tTemplates— the grounded unit spawned on landing/damage:China = "Chinese Airborne",Allied = "Allied Airborne". Only these two factions are wired; any other faction spawns nothing (tTemplates[sFaction]isnil).- Health threshold:
"100"— the<comparison in theEvent.ObjectHealthfilter. Since troopers presumably spawn at 100, essentially the first damage tick triggers the swap. tEvents = tEvents or {}is declared at module scope but never read or written — dead/vestigial.
Notes for modders
- Swap which grounded units appear by editing
tTemplates; pair withParadrop’s owntTemplates(the falling models) to keep faction sets consistent. - The chute-to-ground swap is triggered purely by the
< 100health filter — there is no timer or landing detection, so anything that damages the trooper mid-air also triggers it. - There is no
OnDeactivatein this file; do not assume a deactivation hook exists.