Crash Test Scenario Manager
Reference for `gameplay_crashTest_scenarioManager`, the main orchestrator for crash test missions. Manages multi-step crash test scenarios including vehicle setup, AI control, crash detection, scoring
Reference for gameplay_crashTest_scenarioManager, the main orchestrator for crash test missions. Manages multi-step crash test scenarios including vehicle setup, AI control, crash detection, scoring, and step progression.
Overview
This is the central controller for crash test missions. It processes step data, manages vehicle freezing/unfreezing, handles crash detection events, orchestrates AI-controlled target vehicles, and transitions between steps with fade-to-black effects.
Dependencies
ui_apps_genericMissionData- Timer displayui_apps_pointsBar- Score display- Loads secondary extensions at runtime:
crashTestTaskList,crashTestScoring,crashTestBoundaries,crashTestCountdown,crashTestDamageChecker - Also manages
freeroam_crashCamModefor crash camera replays
Exports
| Function | Signature | Description |
|------
| M.dependencies | table | { 'ui_apps_genericMissionData', 'ui_apps_pointsBar' } |---
| M.trackVehiclesForCrash | () | nil | trackVehiclesForCrash |
| M.clearMarkers | () | nil | clearMarkers |
| M.setDebug | (_debug) | nil | setDebug |-|-----------|
| M.onAnyMissionChanged | onAnyMissionChanged handler |-------------|
| processData | (crashTestData, deactivateOther) | Initialize scenario from mission data |
| startScenario | () | Begin the first step |
| goToNextStepFromUI | () | Advance to next step (called from UI) |
| startStepFromUI | () | Start the current step's countdown |
| reset | () | Reset entire scenario to initial state |
| activatesAllVehForReset | () | Re-activate all vehicles for reset |
| getCrashTestData | () | Get current scenario state |
| onUpdate | (dtReal, dtSim) | Per-frame update: markers, timers, AI checks |
| onPreRender | (dt, dtSim) | Render target markers |
| onVehicleCrashStarted | (crashStartData) | Handle crash start events |
| onVehicleCrashEnded | (crashEndData) | Handle crash end events, evaluate success/failure |
| onPlayerOutOfBounds | () | Fail step when player leaves boundary |
| M.onExtensionUnloaded | onExtensionUnloaded handler |
| M.onCrashCamEnded | onCrashCamEnded handler |
Step Processing
Each step in a crash test is sanitized from raw mission data into a structured format:
| Field | Description |
|---|---|
plVehId | Player vehicle scene ID |
jbeamTargets | List of target vehicle IDs |
targetType | "A single Jbeam", "Multiple Jbeams", or "Static object" |
objective | "Simple crash" or "Crash target vehicle into target area" |
impactSpeed | Required impact speed in kph |
aiType | "ScriptAi" or "Stuck Throttle" |
maxTime | Time limit for the step |
How It Works
processData()- Sanitizes raw step data, finds vehicles by dynamic field names, loads secondary extensions, freezes all player vehiclesstartScenario()- Initiates the first step transition withgoToNextStep()goToNextStep()- Usescore_jobsystemto create a fade-to-black transition, then sets up the new step- Countdown - A 3-second countdown via
crashTestCountdown, after which the player is unfrozen and AI begins - Crash Detection - Vehicles are tracked via
gameplay_util_crashDetection. On crash start, the player is frozen; on crash end, success/failure is evaluated - Step Completion - Scoring is calculated, the task list is updated, and the UI shows step results
-- Start a crash test scenario from mission data
gameplay_crashTest_scenarioManager.processData(missionStepsData, true)
gameplay_crashTest_scenarioManager.startScenario()
-- Get the scenario result after completion
local data = gameplay_crashTest_scenarioManager.getCrashTestData()
if data.scenarioFinished and data.accepted then
-- Scenario passed
endFailure Conditions
- Player crashes outside the target area (static object targets)
- Target vehicle damaged without player involvement
- Non-target vehicle damaged
- Target vehicle arrives without damage (AI script ends)
- Time runs out
- Player exits the boundary area
Key Behaviors
- Vehicles from other steps can be deactivated (
setActive(0)) during the current step - The crash camera mode is force-enabled during scenarios
- Target markers update dynamically - hidden after crash starts
- AI vehicles use either ScriptAi (path-following) or stuck throttle override
- Step transitions use
ui_fadeScreenfor smooth fade-to-black effects
| Function | Signature | Returns | Description |
|---|---|---|---|
M.setDebug | (_debug) | nil | setDebug |
M.onAnyMissionChanged | (status, mission) | nil | onAnyMissionChanged |
M.onExtensionUnloaded | (extension) | nil | onExtensionUnloaded |
M.onCrashCamEnded | () | nil | onCrashCamEnded |
M.clearMarkers | () | nil | clearMarkers |
M.trackVehiclesForCrash | () | nil | trackVehiclesForCrash |
Module Variables
| Variable | Type | Description |
|---|---|---|
M.dependencies | table | { 'ui_apps_genericMissionData', 'ui_apps_pointsBar' } |
M.activatesAllVehForReset | () | - |
M.getCrashTestData | () | - |
M.goToNextStepFromUI | () | - |
M.onPlayerOutOfBounds | () | - |
M.onPreRender | (dt, dtSim) | - |
M.onUpdate | (dtReal, dtSim) | - |
M.onVehicleCrashEnded | (crashEndData) | - |
M.onVehicleCrashStarted | (crashStartData) | - |
M.processData | (crashTestData, deactivateVehiclesFromOtherSteps_) | - |
M.reset | () | - |
M.startScenario | () | - |
M.startStepFromUI | () | - |
See Also
- crashTestBoundaries - Crash Test Boundary Checking - Related reference
- crashTestCountdown - Crash Test Countdown Timer - Related reference
- crashTestScoring - Crash Test Score Calculation - Related reference
- Gameplay Systems Guide - Guide
Crash Test Task List
Reference for `gameplay_crashTest_crashTestTaskList`, which manages the in-game task list UI for crash test missions, showing step objectives and their completion status.
Crawl Boundaries
Reference for `gameplay_crawl_boundary`, which manages spatial boundaries for rock crawling trails. Spawns animated flag markers along boundaries, checks crawler positions against boundary zones, and