MrxSupportTransit
Module: mrxsupporttransit.lua
Overview
The MrxSupportTransit module is responsible for managing the support transit system in the game. It handles operations such as initiating a transit, managing the heliβs behavior during transit, and handling player interactions with the transit interface. The module also manages various events related to vehicle entry, exit, and death.
Inheritance
- Inherits from:
MrxSupport - Imports:
MrxSupportDesignatorSmokeMrxSupportDesignatorFlareMrxTransitMrxUtilMrxStateWifPmcInteriorMrxTutorialManager
Instance pattern
Same class-factory pattern as MrxSupport, not per-uGuid β Create(self, uPlayerGuid) builds a new table via setmetatable/__index, exactly like its parent. No OnActivate/Awake, no tInstance registry. It tracks the following key fields:
sDeliveryVehicle: The name of the delivery vehicle, module-level default"UH1 Transport (Transit)".bUnrestrictedByFuel: settrueinCreateβ this is the only support type in the category that bypasses the fuel check inMrxSupportManager.CompleteDesignation(calling for a ride home is free).bWaterPickup: set per-designation inDesignationCallback(true if the owning character is swimming) β switches the heli from aHeliLandgoal to aMoveTohover-pickup and skips the seat-enter/exit events.- Per-designation event handles:
EnterEvent/ExitEvent/PlayerLeftEvent/TimeoutEvent/DeathEvent/HibernateEvent/eAbort/uIdleGoalβ all created in_WaitCallback/_VehicleLandedand torn down by_Cleanup.
bTransitInterfaceActiveis a module-level global, not per-instance state. Itβs declared at file scope (bTransitInterfaceActive = false) and read/written directly by name β never throughselfβ so a single flag is shared across every transit object. In practice only one transit is ever in flight, but donβt assume itβs isolated per delivery.
Module constants (file scope): nAltitude = 250 (unused in this file β spawn height actually comes from MrxSupport.GetSpawnHeight()); tVOOnTheWay/tVOGoHome (local Ewan freeplay-support cue lists); the net-event ID constants NETEVENT_ENTERVEHICLE = 0, NETEVENT_EXITVEHICLE = 1, NETEVENT_SHOWMESSAGE = 2, NETEVENT_CLEARMESSAGE = 3.
Functions
Create(self, uPlayerGuid)
- Description: Creates a new support instance with the specified player GUID.
- Parameters:
self: The current instance of the module.uPlayerGuid: The unique identifier for the player.
- Returns: A new support instance.
Commence(self, bFireImmediately)
- Description: Initiates the support operation. If the player is swimming, it switches to using a flare designator instead of smoke.
- Parameters:
self: The current instance of the module.bFireImmediately: A boolean indicating whether to fire immediately.
DesignationCallback(self)
- Description: Handles the designation callback for the support operation. It spawns the heli at the designated target and sets up various events for handling the transit process.
- Parameters:
self: The current instance of the module.
_WaitCallback(self, uHeli)
- Description: A private function that waits for the heli to be spawned and sets up AI goals and events for the transit process.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.
SetPickupVehicle(self, sVehicleTemplateName)
- Description: Sets the pickup vehicle template name and updates the delivery vehicle GUID accordingly.
- Parameters:
self: The current instance of the module.sVehicleTemplateName: The name of the vehicle template.
_VehicleLanded(self, uHeli, uDriver, nState)
- Description: Handles the event when the heli lands. It sets up an idle goal for the driver and starts a timeout event if the transit is not in water pickup mode.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.uDriver: The unique identifier for the driver.nState: The state of the vehicle.
_RemoveTimeoutEvent(self, uHeli, uDriver)
- Description: Removes the timeout event and sends the heli home if it has landed. It also deletes related events and clears messages.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.uDriver: The unique identifier for the driver.
_OnHibernate(self, uHeli)
- Description: Handles the event when the heli hibernates. It cleans up resources and removes the heli from the game world.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.
_OpenTransitInterface(self, uHeli, uDriver, uPlayer)
- Description: Opens the transit interface when the player boards the heli. It starts a VO sequence and sets up events for handling player exits and game events.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.uDriver: The unique identifier for the driver.uPlayer: The unique identifier for the player.
_PlayerExited(self, uHeli, uDriver, uPlayer)
- Description: Handles the event when a player exits the heli. It clears messages and sets up timeout events if necessary.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.uDriver: The unique identifier for the driver.uPlayer: The unique identifier for the player.
_PlayerLeftGame(self, uHeli, uDriver)
- Description: Handles the event when a player leaves the game. It opens the transit interface if necessary and sets up timeout events.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.uDriver: The unique identifier for the driver.
_TransitInterfaceCallback(self, uHeli, nSelectedIndex, bSuccess)
- Description: Handles the callback from the transit interface. It sends a clear message event and either starts transit to the selected point or exits all players from the vehicle.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.nSelectedIndex: The index of the selected transit point.bSuccess: A boolean indicating whether the selection was successful.
TransitInterfaceCallbackBriefing(self, nSelectedIndex)
- Description: Handles the briefing callback from the transit interface. It spawns a temporary heli and sets up events for handling the briefing process.
- Parameters:
self: The current instance of the module.nSelectedIndex: The index of the selected transit point.
_WaitCallbackBriefing(self, oSupport, uHeli, uPlayer, nSelectedIndex)
- Description: A private function that waits for the briefing heli to be spawned and sets up AI goals and events for handling the briefing process.
- Parameters:
self: The current instance of the module.oSupport: The support instance.uHeli: The unique identifier for the heli.uPlayer: The unique identifier for the player.nSelectedIndex: The index of the selected transit point.
TransitToPoint(self, uHeli, uPoint)
- Description: Starts transit to the specified point. It checks if the distance between the heli and the point is greater than 15 units and then proceeds with the transit process.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.uPoint: The unique identifier for the transit point.
_StartTransit(self, uHeli, uPoint)
- Description: Starts the transit process by setting the position and orientation of the heli and preparing it for transit.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.uPoint: The unique identifier for the transit point.
_FinishTransit(self, uHeli, uPoint)
- Description: Finishes the transit process by setting up AI goals and events for landing the heli at the specified point.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.uPoint: The unique identifier for the transit point.
_FinishTransit2(self, uHeli)
- Description: Finishes the transit process by exiting all players from the vehicle and setting up events for handling the end of the transit.
- Parameters:
self: The current instance of the module.uHeli: The unique identifier for the heli.
NetEventCallback(eventId, tArgs)
- Description: Handles network events related to entering and exiting vehicles, showing and clearing messages.
- Parameters:
eventId: The ID of the network event.tArgs: A table containing arguments for the event.
AllPlayersExitVehicle(bSendEvent)
- Description: Exits all players from their current vehicle. It sends a network event to exit the vehicle and clears messages.
- Parameters:
bSendEvent: A boolean indicating whether to send an exit vehicle event.
_Cleanup(self)
This function is responsible for cleaning up various event handlers and resetting a module-level state variable. It deletes several events (EnterEvent, ExitEvent, PlayerLeftEvent, TimeoutEvent, DeathEvent, eAbort) using the Event.Delete function to prevent memory leaks or unintended behavior after these events are no longer needed. Additionally, it sets a module-level boolean bTransitInterfaceActive to false and sends a custom network event NETEVENT_CLEARMESSAGE to clear any messages related to support transit.
_HandleDeath(self)
This function handles the death of an object associated with the support transit system. It first clears the DeathEvent field by setting it to nil. Then, it calls the _Cleanup function to perform a full cleanup of all event handlers and reset the module-level state.
Events
Confirmed directly from source. There are no On* engine-lifecycle callbacks in this file (an earlier version of this page listed OnActivate/OnDeactivate/OnDeath/OnUse/OnEnter/OnExit/OnStateChange/ OnPlayerJoined/OnPlayerLeft β none of those functions exist here). Like the rest of the category this is a MrxSupport class-factory object; everything is a one-shot Event.Create/ Event.CreatePersistent tied to a specific in-flight heli, set up in _WaitCallback and cleared in _Cleanup:
Event.ObjectHibernationβ waits for the spawned heli to wake (DesignationCallbackβ_WaitCallback); and a"hibernated"handle firing_OnHibernateto clean up + remove the heli.Event.ObjectInSeat(persistent) β two handles,"a"/"e"(any seat, enter β_OpenTransitInterface) and"a"/"x"(any seat, exit β_PlayerExited), on the landed heli.Event.ObjectDeathβ on the heli, firing_HandleDeath(which calls_Cleanup).Event.TimerRelativeβ the auto-return timeouts (45s after landing in_VehicleLanded;10s after the last player exits) and short VO/return delays.Event.ScriptEvent"mpPlayerLeft"(persistent) β co-op teardown, firing_PlayerLeftGame.
NetEventCallback(eventId, tArgs) is the receiver for this moduleβs own Net.SendCustomEvent( "MrxSupportTransit", ...) traffic (dispatched by module name, not via Event.*), handling the four NETEVENT_* IDs listed above β enter/exit the secondary playerβs vehicle and show/clear the client transit tutorial message.
Notes for modders
- Free rides:
bUnrestrictedByFuel = trueis set inCreate, so transit ignores the fuel gate that every other support type respects β seeMrxSupportManager.CompleteDesignation. - Water pickup vs. land: if the owning character is swimming when they designate,
bWaterPickupflips the whole sequence to a hoveringMoveTopickup (no landing, no seat events) β test both paths if you change the spawn/land logic. - Timeouts to tune: the heli waits
45s on the ground after landing before auto-returning (_VehicleLanded), or10s after the last player leaves it (_PlayerExited/_PlayerLeftGame). Both are plainEvent.TimerRelativeliterals. bTransitInterfaceActiveis a shared module global, not per-selfβ see the warning in Instance pattern before relying on it in a multi-transit scenario.nAltitude = 250is dead here β spawn height comes fromMrxSupport.GetSpawnHeight()(250 with a co-op secondary character present, else 50), not this constant.