EnemyBlippable
Module: enemyblippable.lua
Overview
The EnemyBlippable module extends Blippable to manage radar objectives and off-screen world markers specifically for vehicles, colored by the relationship between the vehicle’s driver and the PMC faction. Despite the name, the color logic covers ally/neutral/enemy/empty/PMC cases, not just “enemy” — see PickColor. It is a sibling of OrientedBlippable in the blip chain (both inherit from Blippable). VehicleBlippable is not a third direct sibling here — it’s a descendant of OrientedBlippable instead (see that page’s Inheritance section).
Inheritance
- Inherits from:
Blippable(which itself inherits fromInheritable) - Imports:
MrxUtil,MrxFactionManager
Instance pattern
Per-instance object module (keyed by uGuid), but this file itself defines no OnActivate/Awake — those are inherited from Blippable (Blippable.OnActivate → Awake → oPrototype:Create(uGuid, iArg), which resolves to this file’s own Create since it overrides the parent). This file tracks the following key fields on the instance:
tColor: The color of the radar objective (one of the module-level color tables below, selected byPickColor).bHostile: Settrueonly in thenRelation <= -60branch ofPickColor; not reset in the other branches.DriverEnter: Persistent event handle for when a driver enters the vehicle.DriverExit: Persistent event handle for when a driver exits the vehicle.Attitude: Persistent attitude-change event handle fromMrxFactionManager.CreatePersistentAttitudeChangeEvent.
Functions
Create(oPrototype, uGuid, iArg)
Overrides Blippable.Create. First calls bare GetFromGuid(uGuid) (resolves through the inheritance chain to Inheritable.GetFromGuid, i.e. tInstance[uGuid]) to reuse an existing instance if one is already registered for this uGuid; otherwise falls back to Blippable.Create(oPrototype, uGuid, iArg). Then, if not already set, creates two persistent events: DriverEnter (Event.ObjectInSeat “Driver”/”enter”, callback oInstance.PickColor) and DriverExit (Event.ObjectInSeat “Driver”/”exit”, inline callback that calls oInstance:ClearBlipped(true)). Looks up the object’s faction via MrxUtil.GetFaction and MrxFactionManager.GetFactionAbbrev, and if not already set, creates a persistent Attitude event via MrxFactionManager.CreatePersistentAttitudeChangeEvent({sFactionAbbrev, "Pmc"}, ...) whose callback clears, re-picks, and re-sets the blip. If a driver is already present (Vehicle.GetDriver(uGuid)), calls PickColor immediately.
Delete(self)
Tears down the per-instance table by deleting any persistent events (DriverEnter, Attitude, DriverExit) and calling Blippable.Delete(self) (which itself calls self:ClearBlipped() if active, then Inheritable.Delete).
PickColor(self, uGuid)
Determines the appropriate blip color based on the vehicle driver, via Vehicle.GetDriver(uGuid). If the driver is player-controlled, calls self:ClearBlipped() and returns (no blip for player-driven vehicles). If there’s a non-player driver, checks Ai.GetRelation(uRider, Pg.GetGuidByName("PMC")): pmc-labeled → tColorPmc; -60 < nRelation < 60 → tColorNeutral; nRelation <= -60 → sets bHostile = true and tColorEnemy; nRelation >= 60 → tColorAlly. If no driver at all, uses tColorEmpty. Whenever self.tColor ends up set, calls self:SetBlipped(true). Note: uRider and nRelation are assigned without local in this function, so they are plain globals, not locals.
Events
- Listens for
Event.ObjectInSeat(Driver/enter and Driver/exit, both viaEvent.CreatePersistent) to callPickColoron enter and clear the blip on exit. - Registers a persistent attitude-change event via
MrxFactionManager.CreatePersistentAttitudeChangeEvent(not a rawEvent.*constant) to refresh the blip when faction relations change. - No
HideMarkerevent is defined or referenced in this file — that behavior belongs toBlippable(which definesHideMarkeras a plain function, andtHiddenGuidsas the exclusion listAddObjectivechecks).
Notes for modders
- This file has no
OnActivate/OnDeactivateof its own — instance lifecycle (activation, hibernation wake, teardown call sites) is entirely inherited fromBlippable/Inheritable. OnlyCreate,Delete, andPickColorare overridden here. - Customize blip properties by setting fields like
tColor; the actual HUD/marker rendering (AddObjective/RemoveObjective,bNetSynchandling) lives inBlippable, not this file. - Blip colors are module-level globals with exact
{r, g, b}values you can change (all plain globals, notlocals):tColorAlly = {0, 127, 255}(blue) — driver relation>= 60tColorNeutral = {230, 230, 255}(near-white) — relation strictly between-60and60tColorEnemy = {255, 0, 0}(red) — relation<= -60(also setsself.bHostile = true)tColorEmpty = {100, 100, 100}(grey) — no drivertColorPmc = {0, 255, 0}(green) — object or driver has the"pmc"labelPickColorreads these asself.tColorPmc/self.tColorNeutral/etc., which resolve through the__indexmetatable up to these module globals — so editing the globals recolors every instance.
- The
Createreuse-via-GetFromGuidpattern means callingCreateagain for auGuidthat already has a live instance returns the existing instance rather than creating a duplicate.