MrxParkingLotManager
Module: mrxparkinglotmanager.lua
Overview
The MrxParkingLotManager module is responsible for managing parking lots in the game. It tracks vehicles entering and leaving seats, handles vehicle movement to designated parking points, and manages tutorial messages related to parking lot interactions.
Inheritance
- Inherits from:
none β base/utility module - Imports:
MrxTutorialManager,MrxUtil,MrxGui
Instance pattern
This is a stateless manager/utility module. It tracks the following key fields:
_tParkingLotCandidates: A table of candidate vehicles for parking._uNewParkingLotVeh: The GUID of the vehicle currently being parked._uWorldMarker: The world marker used to indicate the parking location._uParkingLotVeh: The GUID of the vehicle currently marked for parking.eParkingLotTracker: An event handle for tracking vehicles entering seats.eParkingLotTriggered: An event handle for handling parking lot start events.eMarkEnter,eMarkDeath,eMarkHibernation: Event handles for managing vehicle state changes.eTutorial: An event handle for managing tutorial messages.
Module constants & tunables
| Constant | Value | Meaning | |β|β:|β| | kiParkingLotLimit | 8 | Max tracked candidate vehicles; adding a 9th drops the oldest. | | kfTutorialTime | 6 | Seconds between the two parking-lot tutorial steps, and before auto-hide. | | kiBlipSize | 6 | Radar objective width/height (animated up to Γ1.2). |
Other hard-coded strings worth knowing: the world marker icon is "HUD_PMC_Fiona" (primary-objective RGB from MrxUtil.GetPrimaryObjectiveRgb), the radar texture is "MiniMap_Icon_Faction_PMC", and the two tutorial messages are "[TUTORIAL.ParkingLot.First]" / "[TUTORIAL.ParkingLot.Second]" (shown via MrxTutorialManager.ShowMessage under the identifier "parkingLot").
The "parkingLotStart" script event that triggers _MoveVehicle carries tData = {uRefPoint, uNormalPoint, uHeliPoint} β itβs posted by MrxHq.ExitEnd when leaving an HQ.
Functions
Setup()
Initializes the module by setting up persistent event listeners for tracking vehicles entering seats and handling parking lot start events. It also initializes the list of parking lot candidates.
Cleanup()
Cleans up all event listeners and unmarks any currently marked vehicle, ensuring a clean shutdown of the module.
MarkLastVehicle()
Unmarks any currently marked vehicle and marks the last vehicle in the parking lot candidates list as the new marked vehicle.
_TrackVehicle(uChar, uVehicle)
Adds a vehicle to the list of parking lot candidates if it is alive and not a boat or emplaced weapon. If the candidate list exceeds the limit (kiParkingLotLimit), the oldest candidate is removed.
Likely bug, confirmed in source: the boat/emplaced-weapon check reads Object.HasLabel(uVeh, "Boat") / Object.HasLabel(uVeh, "Emplacedweapon") β but the functionβs parameter is named uVehicle, not uVeh. uVeh is never assigned anywhere in this file, so itβs an undeclared global (nil unless some other loaded module happens to set a global of that exact name). In practice this means the boat/emplaced-weapon exclusion check almost certainly never filters the vehicle actually passed in β Object.HasLabel(nil, ...) β so boats and emplaced weapons likely get added to the candidate list despite the apparent intent to exclude them.
_MoveVehicle(tData)
Moves the last vehicle in the parking lot candidates list to a designated parking point based on its type (normal or helicopter). It also cleans up any remaining vehicles in the candidate list after moving the selected one.
_GetLastVehicle(uRefPos, uHeliPos)
Retrieves the last vehicle from the parking lot candidates list that is alive and not currently occupied by a driver. The selection criteria include proximity to reference points and helicopter-specific conditions.
_MarkVehicle(uGuid)
Marks a vehicle with a world blip and radar objective, indicating its position on the map. It also sets up event listeners for managing changes in the vehicleβs state (entering seat, death, hibernation) and shows tutorial messages related to parking lot interactions.
_UnmarkVehicle()
Removes any existing world marker and radar objective associated with a marked vehicle, deletes event listeners for managing vehicle state changes, and hides any active tutorial messages.
_ShowTutorial1()
Shows the first tutorial message related to parking lots and sets up a timer to show the second tutorial message after kfTutorialTime seconds.
_ShowTutorial2()
Shows the second tutorial message related to parking lots and sets up a timer to hide the tutorial messages after another kfTutorialTime seconds.
_HideTutorial()
Hides any active tutorial messages and deletes the event listener for managing tutorial timers.
Events
Event.ObjectInSeat(persistent, viaSetup) β filters onPlayer.GetAnyCharacter(), 0, "d", "xo", calls_TrackVehiclewhen a vehicle is entered/exited.Event.ScriptEventnamed"parkingLotStart"(persistent, viaSetup) β calls_MoveVehicle.Event.ObjectInSeatagain (non-persistent, via_MarkVehicle, handleeMarkEnter) β filters onPlayer.GetAnyCharacter(), uGuid, "a", "ei", calls_UnmarkVehicle.Event.ObjectDeath(via_MarkVehicle, handleeMarkDeath) β calls_UnmarkVehicleif the marked vehicle dies.Event.ObjectHibernationfiltered on"hibernated"(via_MarkVehicle, handleeMarkHibernation) β calls_UnmarkVehicle.Event.TimerRelative(via_ShowTutorial1/_ShowTutorial2, handleeTutorial) β chains_ShowTutorial1β_ShowTutorial2β_HideTutorial, eachkfTutorialTimeseconds apart.
Notes for modders
- Tune the feature via the three
ki*/kf*constants above β candidate count, tutorial pacing, blip size. - Selection distances are hard-coded in
_GetLastVehicle: a candidate qualifies within65units of the reference point, or (if it has the"helicopter"label) within15units of the heli point, and only if it has no driver. Edit those thresholds to change which parked vehicle gets moved. _MoveVehicleremoves every other candidate in the list after picking one β so leftover vehicles near an HQ parking lot are despawned on exit, not just repositioned.
Confirmed source bug in
_TrackVehicle: the boat/emplaced-weapon exclusion testsObject.HasLabel(uVeh, ...)but the parameter isuVehicle;uVehis an undeclared (nil) global here, so the check never filters the vehicle actually passed in β boats and emplaced weapons get added to the candidate list despite the intent to skip them. Fix the identifier touVehicleif youβre patching this module.