Delivery Missions
Reference for `gameplay_delivery_delivery`, a class-based module providing delivery mission logic. Manages location selection, route calculation, timing, damage checking, and delivery progression.
Reference for gameplay_delivery_delivery, a class-based module providing delivery mission logic. Manages location selection, route calculation, timing, damage checking, and delivery progression.
Overview
This module returns a constructor function that creates delivery objects. Each delivery has a pickup point, a set of delivery locations selected from sites, a calculated roundtrip time limit, and fail conditions for damage and time.
Note: This is a class module (uses metatables), not a standard extension.
Constructor
local Delivery = require("gameplay/delivery/delivery")
local delivery = Delivery()Methods
| Method | Signature | Description |
|---|---|---|
setup | (sites, pickupPos, pickupRadius, tag, count) | Initialize delivery with sites and pickup location |
setTimeParameters | (baseTime, timePerKm) | Set time limit formula |
startDelivery | () | Begin the delivery (state → "active") |
proceedDelivery | () | Advance to next location; returns true if all delivered |
update | (dt) | Per-frame update: check fail conditions |
getCurrentLocation | () | Get the current delivery target location |
selectLocations | (tag, count) | Select random locations from sites with a given tag |
calculateRoundtrip | () | Calculate total route distance via road network |
getCurrentRewardFactor | () | Get reward multiplier based on progress |
checkFail | (dt) | Check damage and time fail conditions |
clearEvents | () | Clear event flags |
State Machine
| State | Description |
|---|---|
"disabled" | Initial state, not active |
"start" | Setup complete, waiting to start |
"active" | Delivery in progress |
"return" | All locations delivered, returning to pickup |
"failed" | Failed due to damage or time |
Setup Flow
local delivery = Delivery()
delivery.vehId = playerVehId
delivery:setTimeParameters(60, 30) -- 60s base + 30s per km
delivery:setup(sites, pickupPos, 10, "deliveryPoint", 3)
-- Selects 3 random locations tagged "deliveryPoint"
-- Calculates roundtrip distance via road network
-- Sets timer = baseTime + timePerKm * distance/1000
delivery:startDelivery()How It Works
setup()loads sites, selects random tagged locations, calculates the roundtrip distance via the road map, and sets the time limitstartDelivery()transitions to"active"state and setslocationIndex = 1update(dt)decrements the timer and checks fail conditions each frameproceedDelivery()advanceslocationIndex; when all locations are visited, state becomes"return"checkFail(dt)checks if vehicle damage exceedsmaxDamage(5000) or time runs out
Route Calculation
calculateRoundtrip() uses map.findClosestRoad() and map.getPath() to compute road-network distances between:
- Pickup → First location
- Each location → Next location
- Last location → Pickup
Fail Conditions
| Condition | Threshold | Fail Reason |
|---|---|---|
| Vehicle damage | 5000 | "damage" |
| Time expired | Calculated per route | "time" |
| Vehicle stopped | 10 seconds (unused in update) | N/A |
Key Behaviors
- Locations are shuffled randomly using Fisher-Yates shuffle
- The
locationRewardFactor(0.5) scales reward based on completion progress - Timer pauses briefly when
isPartiallyInsideLocationOneFrameis true - The
events.proceedDeliveryflag is set when advancing to the next location - Route distances include road offset distances from
findClosestRoad
| Function | Signature | Returns | Description |
|---|---|---|---|
M.init | () | nil | init |
See Also
- Gameplay Systems Guide - Guide
Crawl Engine
Reference for `gameplay_crawl_utils`, the core runtime engine for rock crawling gameplay. Handles crawl state management, pathnode detection, penalty/infraction system, marker rendering, vehicle track
Discover Experiences
Reference for `gameplay_discover_discover_037`, which defines the curated discover experiences for the 0.37 (2025 Fall) update including the Limousine Test Drive, Destructive Props, and several missio