Crawl System
Reference for `gameplay_crawl_general`, the main manager for rock crawling trails. Handles trail setup, crawl lifecycle, POI registration, big map integration, activity dialogs, and score persistence.
Reference for gameplay_crawl_general, the main manager for rock crawling trails. Handles trail setup, crawl lifecycle, POI registration, big map integration, activity dialogs, and score persistence.
Overview
This is the central coordinator for the crawl system. It manages the active trail state, delegates to crawl_utils for the actual crawl logic, registers POIs on the big map, handles activity acceptance dialogs, and saves scores through the save system.
Dependencies
gameplay_crawl_saveSystem, gameplay_crawl_utils, gameplay_crawl_boundary, gameplay_crawl_display
Exports
| Function | Signature | Description |
|---|---|---|
setupCrawl | (trail, veh, isFromMission) | Configure a crawl trail with boundary, path, starting position |
startCrawlFreeroam | (trail, veh) | Setup and start a freeroam crawl |
startCrawlFlowgraph | (trail, veh) | Start a mission-driven crawl |
clear | (force) | Clear active trail and all crawl state |
onUpdate | (dtReal, dtSim, dtRaw) | Per-frame update: delegates to utils.updateCrawl |
onGetRawPoiListForLevel | (levelIdentifier, elements) | Register crawl POIs on the big map |
onActivityAcceptGatherData | (elemData, activityData) | Build activity accept dialog data |
onActivityIndexVisible | (data) | Setup crawl preview when POI is focused |
onDrawOnMinimap | (td) | Draw boundary on minimap |
onCrawlResultsShown | (eventData) | Save player score on completion |
onVehicleSwitched | (oldId, newId) | Clear non-mission crawl on vehicle switch |
onVehicleDestroyed | (vehId) | Clear non-mission crawl on vehicle destroy |
onAnyMissionChanged | (status, id) | Clear crawl when mission stops |
Module State
M.activeTrail- Table withtrail,boundary,path,startingPosition,prefabs,isFromMissionM.crawlersData- Array of crawler data objects
Trail Setup
setupCrawl() performs:
- Loads boundary, path, and starting position from save system
- Handles path reversal (reverses nodes, flips rotations by 180°)
- Sets up crawler data via
utils.setupCrawlerData - Loads trail prefabs
- Optionally teleports vehicle to starting position (mission mode)
How It Works
-- Freeroam crawl (from POI interaction)
local trail = gameplay_crawl_saveSystem.getTrailById(trailId)
gameplay_crawl_general.startCrawlFreeroam(trail, be:getPlayerVehicle(0))
-- Mission crawl (from flowgraph)
gameplay_crawl_general.setupCrawl(trail, veh, true)
gameplay_crawl_general.startCrawlFlowgraph(trail, veh)
-- Clear everything
gameplay_crawl_general.clear(true)POI / Big Map Integration
onGetRawPoiListForLevel() registers crawl trails as POIs when:
- Career is active OR
enableCrawlInFreeroamsetting is on - No crawl is currently active
- Trail has a valid starting position
POIs include:
crawlMarker- In-world marker with position, rotation, radiusbigmapMarker- Big map entry with icon, name, description, thumbnail, quick travel
Activity Accept Dialog
When a player approaches a crawl POI, onActivityAcceptGatherData() builds a dialog with:
- Trail name and "Freeroam Crawl" category
- Path stats (distance, elevation gain/loss)
- Player's best penalty points, best time, and attempt count
- A "Play" button that starts the freeroam crawl
Key Behaviors
- Path reversal uses
arrayReverseand rotates each node by π around the Y axis - Reversed trails can have a separate
startingPositionIdReversedor derive position from the first reversed node - Non-mission crawls are automatically cleared on vehicle switch or destroy
- Scores are saved via
gameplay_crawl_saveSystem.addNewPlayerScoreon results shown - The
onSerializehook clears state to prevent stale data across saves
Public API
| Function | Signature | Returns | Description |
|---|---|---|---|
M.onExtensionLoaded | () | nil | onExtensionLoaded |
Module Variables
| Variable | Type | Description |
|---|---|---|
M.dependencies | table | { 'gameplay_crawl_saveSystem', 'gameplay_crawl_utils', 'gameplay_crawl_boundary' |
M.clear | (force) | - |
M.onActivityAcceptGatherData | (elemData, activityData) | - |
M.onActivityIndexVisible | (data) | - |
M.onAnyMissionChanged | (status, id) | - |
M.onCrawlResultsShown | (eventData) | - |
M.onDrawOnMinimap | (td) | - |
M.onGetRawPoiListForLevel | (levelIdentifier, elements) | - |
M.onSerialize | () | - |
M.onUpdate | (dtReal, dtSim, dtRaw) | - |
M.onVehicleDestroyed | (vehId) | - |
M.onVehicleSwitched | (oldId, newId) | - |
M.setupCrawl | (trail, veh, isFromMission) | - |
M.startCrawlFlowgraph | (trail, veh) | - |
M.startCrawlFreeroam | (trail, veh) | - |
See Also
- crawl/boundary - Crawl Boundary System - Related reference
- crawl/crawlFlowgraphBridge - Crawl Flowgraph Bridge (Legacy) - Related reference
- crawl/debug - Crawl Debug Window - Related reference
- Gameplay Systems Guide - Guide
Crawl Flowgraph Bridge
Reference for `gameplay_crawl_flowgraphBridge`, the current bridge between the crawl system and flowgraph nodes. Exposes crawl lifecycle operations for mission flowgraphs.
Crawl Save System
Reference for `gameplay_crawl_saveSystem`, which handles loading, saving, serialization, and caching of crawl trail data (trails, boundaries, paths, starting positions) as well as player score persist