Quick Race
Handles the runtime logic for quick race scenarios: vehicle spawning, prefab loading, waypoint generation from race paths, lap timing, highscore recording, and time-of-day setup.
Handles the runtime logic for quick race scenarios: vehicle spawning, prefab loading, waypoint generation from race paths, lap timing, highscore recording, and time-of-day setup.
Internal State
| Field | Type | Description |
|---|---|---|
M.addCheckPoint | varies | Assigned as addCheckPoint |
M.loadCheckpoints | varies | Assigned as loadCheckpoints |
Public API
| Function | Signature | Description |
|---|---|---|
M.onLoadCustomPrefabs | (sc) | Loads flowgraph, race file, spawns vehicle |
M.onCustomWaypoints | (sc) | Converts race path into lap config waypoints |
M.onScenarioLoaded | (sc) | Sets vehicle lights for night, reverses normals if needed |
M.loadVehicle | (scenario) | Spawns the player vehicle at spawn position |
M.onCountdownEnded | () | Unfreezes vehicle, resets lap times |
M.onRaceWaypointReached | (wpInfo) | Records lap times, submits single-lap highscores |
M.onRaceResult | (final) | Records final race highscore, prepares results for UI |
M.getConfigKey | (rolling, reverse, laps) → string | Generates highscore key like "standingReverse2" |
M.onClientEndMission | () | Cleans up flowgraph |
M.changeTimeTrialConfig | () | Toggles time trial overview screen |
M.onUiChangedState | (curUIState, prevUIState) | Handles UI navigation from quickrace overview |
M.getNodesOnBranch | (segment, config) → table | Recursively extracts waypoint names from race graph |
M.getVehicleBrand | (scenario) → string | Returns vehicle brand name |
M.getVehicleName | (scenario) → string | Returns vehicle model name |
Waypoint Generation
The onCustomWaypoints function converts a race path into scenario lap config:
- Optionally reverses the path
- Auto-configures the path graph
- Generates node names like
__generated_from_path__<id> - Recursively traverses the graph via depth-first search
- Handles branching paths (split waypoints stored in
lapConfigBranches) - Sets
startTimerCheckpointfrom the path's start node
Vehicle Spawning
loadVehicle determines spawn position based on track config:
| Mode | Spawn Sphere |
|---|---|
| Standing + Forward | spawnSpheres.standing |
| Standing + Reverse | spawnSpheres.standingReverse |
| Rolling + Forward | spawnSpheres.rolling |
| Rolling + Reverse | spawnSpheres.rollingReverse |
For .race.json tracks, spawn is derived from startPositions in the path.
Highscore Keys
Generated by getConfigKey():
| Rolling | Reverse | Laps | Key |
|---|---|---|---|
| false | false | 3 | "standing3" |
| true | false | 1 | "rolling1" |
| false | true | 2 | "standingReverse2" |
How It Works
- UI calls
startQuickracewith scenario/track/vehicle data onLoadCustomPrefabsloads flowgraph (if any) and race file, spawns vehicleonCustomWaypointsgenerates lap configuration from race path- Scenario system handles countdown, race logic via
scenario_scenarios onRaceWaypointReachedrecords per-lap times and submits to highscoresonRaceResultrecords final time and prepares detailed results for UI
Key Notes
- Supports both legacy spawn sphere and modern
.race.jsonpath formats - Flowgraph-based tracks load via
core_flowgraphManager - Headlights auto-enabled for TOD values 0, 1, or 8 (nighttime)
- Time trial UI can be toggled from pause menu via
changeTimeTrialConfig - Per-lap and full-race highscores tracked separately
Additional Exports
M.timeTrialOpen- (undocumented)
See Also
- Scenario Bus Driver - Bus Route Scenario Logic - Related reference
- Scenario Damage Goal - Damage-Based Win/Fail Condition - Related reference
- Scenario Demolition Derby - Last Vehicle Moving Wins - Related reference
- Scenario System Guide - Guide
Position Goal
A scenario goal that checks if a vehicle is within range of a target scene object at race end. Used for parking/braking scenarios.
Quick Race Loader
Discovers available quick race tracks across all levels, loads track configurations, supports track editor tracks, and assembles complete scenario data for the quick race system.