Bracket Drag Race
Reference for `gameplay_drag_dragTypes_bracketRace`, which implements the bracket-style drag race where racers have a dial-in time and staggered starts.
Reference for gameplay_drag_dragTypes_bracketRace, which implements the bracket-style drag race where racers have a dial-in time and staggered starts.
Overview
In a bracket race, each racer has a dial-in (predicted) quarter-mile time. The slower racer launches first by the difference in dials, giving both an equal chance. The winner is whoever gets closest to their dial without going under ("breaking out"). This extension manages phase progression with dependency-based synchronisation.
Dependencies
gameplay_drag_general, gameplay_drag_utils
Exports
| Function | Signature | Description |
|------
| M.dependencies | table | {"gameplay_drag_general", "gameplay_drag_utils"} |----|-----------|-------------|
| onExtensionLoaded | () | Caches references to general and utils |
| onUpdate | (dtReal, dtSim, dtRaw) | Main loop - updates racers, runs phase logic |
| startDebugPhase | (pIndex, dData) | Jump all racers to a specific phase for testing |
| startActivity | () | Begin the race; sets dials from racer timer data |
| resetDragRace | () | Delegates to general reset, clears local flags |
Internals
| Symbol | Purpose |
|---|---|
hasActivityStarted | Gate for the onUpdate loop |
debugStart | Flag for debug-phase jumping |
minDistance | 0.8 m - unused distance threshold |
minVelToStop | 15 m/s - unused velocity threshold |
How It Works
-- startActivity fetches dragData and builds dials with actual dial values
gameplay_drag_dragTypes_bracketRace.startActivity()
-- Each frame, onUpdate iterates all racers:
-- 1. updateRacer(racer) - refresh position, speed, wheel positions
-- 2. Execute current phase function: dUtils[phase.name](phase, racer, dtSim)
-- 3. If phase completed and no dependency → advance racer
-- 4. If all racers' current phase completed (dependency phase) → advance allPhase progression uses a dependency system:
- Dependent phases (e.g.
stage,countdown) require ALL racers to complete before advancing - Independent phases (e.g.
race,stop) let each racer advance individually
The dial offset creates the staggered start - the slower racer's tree starts first, calculated by dUtils.setDialsData().
Key Behaviors
- Dials are sourced from
racer.timers.dial.value(set duringsetupRacer) - Phase functions (
stage,countdown,race,stop) live ingameplay_drag_utils isActivityFinishedistruewhen every racer hasisFinished == truedragData.isCompletedis set when the activity finishes
Module Variables
| Variable | Type | Description |
|---|---|---|
M.dependencies | table | {"gameplay_drag_general", "gameplay_drag_utils"} |
M.onExtensionLoaded | () | - |
M.onUpdate | (dtReal, dtSim, dtRaw) | - |
M.resetDragRace | () | - |
M.startActivity | () | - |
M.startDebugPhase | (pIndex, dData) | - |
See Also
- drag/dragTypes/dragPracticeRace - Solo Practice Drag Race - Related reference
- drag/dragTypes/headsUpDrag - Heads-Up Drag Race - Related reference
- Gameplay Systems Guide - Guide
Drag Race Phases
Reference for `gameplay_drag_utils`, which provides all phase functions (`stage`, `countdown`, `race`, `stop`, `emergencyStop`), racer position tracking, tree light processing, win conditions, and bou
Drag Practice Race
Reference for `gameplay_drag_dragTypes_dragPracticeRace`, which implements a single-player practice drag race with automatic cleanup.