VehicleBlippable
Module: vehicleblippable.lua
Overview
The VehicleBlippable module is responsible for managing radar and off-screen world markers for vehicles. It handles the blip color based on the driver’s relation to the PMC faction, ensuring that the vehicle’s blip accurately reflects its status (ally, neutral, enemy, empty, or PMC). This module also listens for driver enter/exit events and faction attitude changes to update the blip accordingly.
Inheritance
- Inherits from:
OrientedBlippable(which extendsBlippable→Inheritable) - Imports:
MrxUtil,MrxFactionManager
The actual blip drawing/teardown (AddObjective/RemoveObjective, the tInstance[uGuid] registry) lives up this chain in Blippable/Inheritable; this module only decides the color and wires the driver/attitude events that trigger a recolor.
Instance pattern
This is a per-instance object module (keyed by uGuid). Genuine per-instance fields, set in Create:
DriverEnter/DriverExit: persistent event handles for the driver-seat enter/exit events, cleaned up inDelete.Attitude: persistent event handle for this vehicle’s faction-attitude-change event, also cleaned up inDelete.tColor(inherited fromBlippable): the fieldSetBlippedactually writes to (oSelf.tColor = oSelf.tColorPmc, etc.) — this is the one that changes per-instance based on who’s driving.
tColorAlly/tColorNeutral/tColorEnemy/tColorEmpty/tColorPmc are not per-instance state — they’re plain module-level constants declared once at the top of vehicleblippable.lua. Every instance reads the same shared tables (reachable via self.tColorAlly etc. through the prototype-inheritance fallback, same mechanism as Inheritable); nothing ever writes a different value onto a specific instance.
Module constants & tunables
The five blip colors are plain module-level tables declared at the top of vehicleblippable.lua. Change one here and every vehicle using this module recolors at once (see Notes for modders):
| Constant | RGB | Used for |
|---|---|---|
tColorPmc | {0, 255, 0} | PMC-labelled vehicle or driver (green) |
tColorAlly | {0, 127, 255} | driver relation to PMC ≥ 60 (blue) |
tColorNeutral | {230, 230, 255} | -60 < relation < 60 (near-white) |
tColorEnemy | {255, 0, 0} | relation ≤ -60 (red) |
tColorEmpty | {100, 100, 100} | no driver (gray) |
Functions
OnActivate(uGuid, uRuntimeOwner, iArg)
Called when the vehicle instance is activated. It sets up an event to call Start once the object leaves hibernation.
Start(uGuid, uRuntimeOwner, iArg)
Checks if the vehicle is alive and creates a new per-instance table for the vehicle using the module’s prototype.
Create(oPrototype, uGuid, uRuntimeOwner)
Creates a new per-instance table for the vehicle. It sets up event listeners for driver enter/exit events and faction attitude changes, and initializes the blip color based on the current state.
Delete(self)
Tears down the per-instance table by clearing any active blips and calling the base class’s Delete.
SetBlipped(oSelf, uVehicle)
Updates the vehicle’s blip color based on the driver’s relation to the PMC faction. It also clears the blip if a player is controlling the vehicle.
Exact color/relation thresholds, read directly from source:
| Condition | RGB | Meaning |
|---|---|---|
| No driver | 100, 100, 100 (gray) | Empty vehicle |
Driver has "pmc" label | 0, 255, 0 (green) | Your own faction |
| Relation to PMC ≥ 60 | 0, 127, 255 (blue) | Ally |
| Relation to PMC ≤ -60 | 255, 0, 0 (red) | Enemy |
| -60 < relation < 60 | 230, 230, 255 (near-white) | Neutral |
| A player is driving | — | Blip is cleared entirely — no blip shown for a player-driven vehicle, regardless of faction |
This is the same ally/neutral/enemy/empty/PMC color language used across most of the Vehicles category (autogunship, supportairplane, and others reimplement slightly different variants of the same scheme locally rather than importing this one).
Events
- Listens for
Event.ObjectHibernationto callStartwhen the object leaves hibernation. - Listens for
Event.ObjectInSeat(DriverEnter,DriverExit) to update the blip color on driver changes. - Listens for faction attitude change events to recolor the blip based on updated relations.
Notes for modders
- Modifying
tColorAlly/tColorNeutral/tColorEnemy/tColorEmpty/tColorPmcchanges the color for every vehicle using this module at once — they’re shared module-level constants, not per-instance settings.import("VehicleBlippable"); VehicleBlippable.tColorEnemy = {255, 255, 0}would recolor every enemy vehicle’s blip yellow, globally. - Faction attitude changes automatically recolor blips already on-screen (via the
Attitudepersistent event) — you don’t need to manually refresh vehicle blips after changing a relation withMrxFactionManager.SetRelation. autogunshipandsupportairplane(also in this category) reimplement slightly different variants of the same ally/neutral/enemy/empty/PMC scheme locally rather than importing this module — worth checking if you want a consistent look across custom vehicle types.