MrxMunitionsPickup
Module: mrxmunitionspickup.lua
Overview
The MrxMunitionsPickup module is responsible for handling the pickup of tagged munitions by a heli. It inherits from MrxSupport and manages the spawning, targeting, and retrieval of munitions by a designated vehicle. The module also handles voice-over sequences and faction infraction logic when munitions are picked up.
Inheritance
- Inherits from:
MrxSupport - Imports:
MrxSupportManager,MrxSupportDesignatorSmoke,Munitions,MrxUtil,MrxVoSequence
Instance pattern
Same class-factory pattern as MrxSupport, not per-uGuid — Create(self, uOwnerGuid) builds a new table via setmetatable/__index, exactly like its parent. No OnActivate/Awake, no tInstance registry. It tracks the following key fields:
oTarget: The target for the pickup operation.sDeliveryVehicle: The name of the vehicle template used for delivery.uDeliveryVehicle: The GUID of the delivery vehicle.oUpdateEvent: An event handle for periodic updates.oDesignator: aMrxSupportDesignatorSmokeset to green smoke, AA test level"none", and anilvalidation function (any target accepted). Recruit type is"Copter".oFinalDestination: The final destination point for the pickup operation.- Per-designation event handles:
oNoMunitionsScriptEvent,oMunitionsKilledEvent,oMunitionsSleepEvent,oUntagScriptEvent— created in_WaitCallback/PickMunitionsTarget, deleted inPickup/ImmediatePickup.
bPickupInProgressandtImmediatePickupDataare module-level globals, not per-selffields. Both are declared at file scope and read/written by bare name (not throughself), so they are shared across every munitions-pickup object.tImmediatePickupDataeven caches aselfreference so the free-functionImmediatePickup()(which takes no arguments) can reach back into the active pickup. This works only because at most one munitions pickup is ever in flight — it is not safe for concurrent pickups.
Functions
Create(self, uOwnerGuid)
Creates a new per-instance table for the object using the module’s prototype. Initializes the delivery vehicle and designator settings.
DesignationCallback(self)
A callback function that handles designation events.
SetDeliveryVehicle(self, sVehicleTemplateName)
Sets the delivery vehicle template name and updates the GUID accordingly.
SetFinalDestination(self, oFinalDestination)
Sets the final destination point for the pickup operation.
_DesignatorCallback(self)
Handles the designator callback logic, spawning the delivery vehicle at the designated target position and setting its orientation.
_WaitCallback(self, uHeli)
Called after the heli wakes up. Starts a voice-over sequence, sets up damage event handling, and begins picking up munitions.
PickMunitionsTarget(self, uHeli)
Detaches cargo from the winch, gets tagged munitions, and sets up events to handle various scenarios (e.g., no munitions, untagged munitions).
ImmediatePickup()
A free function (no self parameter) that force-completes an in-progress pickup: it no-ops unless bPickupInProgress and there’s still a tagged munition, then calls Munitions.PickupAllMunitions(), deletes the four per-pickup events via the cached tImmediatePickupData.self, fades out the heli (and any winched target), frees the "Copter" recruit, and resets the module globals. Reaches its target object entirely through the module-level tImmediatePickupData table — see the warning above.
Pickup(self, uHeli, uDriver, pu, nState)
Handles the actual pickup of munitions. Updates faction infraction, picks up all tagged munitions, and returns the heli to its home position.
Events
Confirmed from source — all one-shot registrations tied to a specific pickup. DesignationCallback is not an event; it’s the framework hook called by MrxSupport and it just forwards to the plain function _DesignatorCallback.
Event.ObjectHibernation("awake") — waits for the spawned heli to wake, then runs_WaitCallback.Event.ScriptEvent"NoMunitions"— if the game posts this, callsMrxSupport.Abort(self, uHeli, "NoMunitions").Event.ScriptEvent"UntagMunitions"(filtered to the current targetself.pu) — if the target is un-tagged mid-run, re-picks a new target viaPickMunitionsTarget.Event.ObjectDeath(onself.pu) andEvent.ObjectHibernation("hibernated", onself.pu) — if the current target munition dies or sleeps, re-runPickMunitionsTarget.
Damage abort comes from the inherited MrxSupport.SetupDamageEvent (aborts if the heli drops below 60% health — see MrxSupport).
Notes for modders
SetDeliveryVehicle/SetFinalDestinationconfigure the heli and where it returns; the module-level default vehicle is"UH1 Transport (PMC) (Driver)".- This is a mission/freebie support type, not a purchasable catalog entry —
MrxSupportDatawires twotFreebieDatainstances of it (GurCon001_Munitions,MunitionsPickup), each with a fixed delivery vehicle + faction HQ landing zone. - Faction infraction:
Pickupadds+5infraction (viaAi.AddInfraction) against the picked-up munition’s faction, for each local player character — grabbing another faction’s dropped ordnance is a hostile act. - Customize the “on the way” VO by editing the
tVOtable in_WaitCallback. bPickupInProgress/tImmediatePickupDataare shared module globals (see the Instance-pattern warning) — don’t build logic that assumes two pickups can run at once.