MrxVoSequence
Module: mrxvosequence.lua
Overview
The MrxVoSequence module is responsible for playing voice-over (VO) sequences in the game. It handles the normalization of VO sequences, arbitration by priority, and execution of each stage in the sequence, including delays and callbacks.
Inheritance
- Inherits from:
none - Imports:
MrxUtil,MrxSoundCategories
Instance pattern
This is a stateless manager/utility module (module-level globals, no Create/uGuid/tInstance pattern) — there is only ever one VO sequence in flight at a time, module-wide. It tracks the following key fields:
_tSequence: The current, normalized VO sequence being played (nil when idle). Also carries.nPriority,.bSendNetEvent, and.tSpeakersas extra keys on the same table._nBaseDelay: Base delay (seconds) between stages that don’t specify their own delay; defaults to0.25, overridable viavSequence.nBaseDelay._bStoppingSequence: Flag indicating if the sequence is currently stopping (guards against reentrant_NextStagecalls duringStop)._uDelayTimer: Event handle for the inter-stage delay timer (Event.TimerRelative), cleared inStop._uTimeoutEvent: Event handle for the per-cue timeout timer, cleared when the cue finishes or the sequence stops._knTimeout: Timeout duration for each cue. Never assigned anywhere in this file — no call site sets it, so_ExecuteStage’s timeout branch (if _knTimeout then ...) is dead in practice unless another module/native code sets it.knPriorityCinematic,knPriorityBriefing,knPriorityContract,knPriorityBounties,knPriorityFreeplay: Priority constants, aliased fromVO.PRIORITY_*at load time.
Functions
Start(vSequence, bCinematic, nPriority, bSendNetEvent)
Normalizes a VO sequence (cue/speaker, delay, callback stages), arbitrates by priority (higher pre-empts; equal/lower is rejected), fades the sequence, registers speakers, and runs stage 1. Returns a boolean indicating success or failure.
_ExecuteStage(nStage)
Executes a specific stage in the VO sequence. Plays the cue via VO.Cue, logs to PDA dialog, sets a timeout, and schedules the next stage via Event.TimerRelative.
Stop(bFadeSound, bIssueDanglingCallbacks, nPriorityFilter)
Cancels all cues in the current sequence, optionally fires dangling callbacks, and cleans up associated events.
Cleanup(bFadeSound)
Fades out the VO sequence sound category and removes sequences from registered speakers.
Reset()
Resets the module’s internal state by fading out the VO sequence sound category and clearing all tracked fields.
_CallSequenceCallbacks(tFormattedSequence)
Fires uncalled, non-bIgnoreOnSkip callbacks on skip for each stage in the sequence.
IsSequenceInProgress()
Returns a boolean indicating whether a VO sequence is currently in progress.
Events
Event.TimerRelative: Used twice — to delay execution of the next stage (_ExecuteStage, via_uDelayTimer) and to enforce a per-cue timeout that callsVO.Cancel(via_uTimeoutEvent, only created when_knTimeoutis set — see Instance pattern above).Event.Delete: Called to cancel pending_uDelayTimer/_uTimeoutEventtimers duringStopand_NextStage.- No other
Event.*constants appear in this file; sequence advancement between non-delayed stages happens via direct recursive calls to_ExecuteStage, not events.
Notes for modders
- A stage in
vSequencecan be one of four shapes, auto-detected byStart:{sCue, vSpeaker}(a spoken cue — speaker may be a name string, a GUID, ornil=0),{fFn, tArgs, bIgnoreOnSkip}(a callback stage, runs instantly),{nDelay}(a pause; negatives clamp to0), or a bare{J=cue, M=cue, C=cue}table keyed by the primary character’s identity (Jennifer/Mattias/Chris) — the matching cue is picked automatically. This is the actual authoring surface. - Priority decides who wins: pass one of the
knPriority*constants (they aliasVO.PRIORITY_*). A higher-priorityStartpre-empts the current sequence; equal-or-lower is rejected and its callbacks are fired as “skipped”.bCinematic = trueforcesknPriorityCinematic. _nBaseDelaydefaults to0.25sbetween stages that don’t specify their own delay; override per-call by puttingnBaseDelayon the sequence table itself._knTimeoutis dead in this file — nothing sets it, so the per-cue timeout branch in_ExecuteStagenever runs unless native/other code assigns it. Don’t rely on it as a safety net.- Only one sequence runs at a time module-wide; call
Stop/Resetif you need to force-clear before starting another at equal-or-lower priority.