API ReferenceGE Extensionsscenario
Finish Race Goal
A scenario goal that tracks whether a vehicle finishes a race. Supports both "must finish" and "must win" modes.
A scenario goal that tracks whether a vehicle finishes a race. Supports both "must finish" and "must win" modes.
Public API
| Function | Signature | Description |
|---|---|---|
M.init | (scenario) | Parses finishRace goals from scenario JSON |
M.processState | (scenario, state, stateData) | Handles waypoint reached and race result events |
M.updateFinalStatus | (scenario) | Reports final goal status to statistics system |
Goal JSON Schema
{
"goal": {
"finishRace": {
"mustWin": true,
"passed": "scenarios.race.youWon",
"failed": "scenarios.race.youLost"
}
}
}| Field | Type | Default | Description |
|---|---|---|---|
mustWin | boolean | false | If true, only the first vehicle to finish passes |
passed | localizedString | "You finished the race." | Message on pass |
failed | localizedString | "You failed to finish the race." | Message on fail |
How It Works
initcollects all goals withid == "finishRace"- On
onRaceWaypointReached: whennext == nil(final waypoint):- mustWin mode: First vehicle to reach end passes; all others fail
- Normal mode: Each vehicle is marked pass/fail based on whether it finishes
- On
onRaceResult: Finishes the scenario with pass/fail messages - A vehicle that never reaches the final waypoint defaults to
"failed"
State Events
| Event | Trigger |
|---|---|
onRaceWaypointReached | Vehicle crosses last waypoint (next == nil) |
onRaceResult | Race ends - calls passedGoal or failedGoal |
| M.instances | varies | Assigned as {} |
Usage Examples
-- Simple finish goal: just cross the finish line
{
"vehicles": {
"scenario_player0": {
"goal": {
"finishRace": {}
}
}
}
}
-- Must beat AI to win
{
"finishRace": {
"mustWin": true,
"failed": "scenarios.race.aiWon"
}
}Key Notes
- Uses
statistics_statistics.setGoalProgressto report results - In
mustWinmode, once any vehicle finishes, the player's result is locked - Without
mustWin, each vehicle independently passes or fails - Both
passedGoalandfailedGoalcallscenario_scenarios.finish()to end the scenario
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
Drift Goal
A scenario goal that calculates drift scores from vehicle angle and speed, supports combo chains, and triggers win/fail based on minimum drift score thresholds.
No-Move Goal
A scenario goal that fails if a vehicle moves from its starting position. Used for parking/brake scenarios where a vehicle must remain stationary.