Rally Attempts
Creates and saves mission attempt records for rally loop completions and DNFs. Integrates with the mission progress system to record timing data, vehicle info, and stage times.
Creates and saves mission attempt records for rally loop completions and DNFs. Integrates with the mission progress system to record timing data, vehicle info, and stage times.
Public API
| Function | Signature | Returns | Description |
|---|---|---|---|
M.createRallyLoopAttemptForFinish | (mgr) | attempt, totalChange | Creates a normal completion attempt with timing + vehicle data |
M.createRallyLoopAttemptForDnf | (mgr, dnfType) | attempt, totalChange | Creates a DNF attempt (restart/abandon) with vehicle data |
Internals
Helper Functions
| Function | Description |
|---|---|
createAttempt() | Creates a new attempt via gameplay_missions_progress.newAttempt('attempted', {}) |
addDnfData(mgr, attempt, dnfType) | Sets attempt.dnf = true and stores DNF type + mission ID |
addTimingData(mgr, attempt) | Stores total penalty, total time, and individual SS stage times (timeSS1, timeSS2, etc.) |
addVehicleData(attempt) | Records vehicle model, config path, and whether config is a .pc file |
aggregate(attempt, missionId) | Calls gameplay_missions_progress.aggregateAttempt to update progress stats |
save(missionId) | Persists mission save data via gameplay_missions_progress.saveMissionSaveData |
Attempt Data Structure
-- Finish attempt
attempt.data = {
penalty = number, -- total penalty seconds
totalTime = number, -- total rally time
timeSS1 = number, -- stage 1 time (optional)
timeSS2 = number, -- stage 2 time (optional)
-- ...additional SS times
}
attempt.vehicle = {
model = "jbeamName",
config = "path/to/config",
isConfigFile = boolean
}
-- DNF attempt
attempt.dnf = true
attempt.data = {
dnfType = "restart"|"abandon",
dnfMissionId = "mission-id"
}How It Works
- Finish flow:
createRallyLoopAttemptForFinish→ creates attempt → adds timing (penalty, total time, per-stage times from event log) → adds vehicle data → aggregates → saves - DNF flow:
createRallyLoopAttemptForDnf→ creates attempt → marks DNF with type → adds vehicle data → aggregates → saves - Both flows get the mission ID from
mgr:getRallyLoopMissionId()and returnnilif unavailable - Stage times are extracted from the event log via
getStageTimes()and stored astimeSS{n}keys
Usage Example
local RallyAttempts = require('gameplay/rally/loop/rallyAttempts')
-- On rally completion
local attempt, change = RallyAttempts.createRallyLoopAttemptForFinish(loopManager)
-- On rally abandon
local attempt, change = RallyAttempts.createRallyLoopAttemptForDnf(loopManager, "abandon")See Also
- Rally Loop Penalties - Related reference
- Rally Event Log - Related reference
- Rally Loop Manager - Related reference
- Gameplay Systems Guide - Guide
Rally Loop Penalties
Calculates time control penalties for rally loop events. Determines if a driver arrived early, on-time, or late at a checkpoint and computes penalty amounts (+10 per minute deviation).
Rally Event Log
Class-based event logger for rally loop gameplay. Records all events (timecards, penalties, recoveries, flips) and maintains aggregated totals. Events are grouped by `eventGroup` for per-stage queryin