Boatrace Common
Based on game build 714014 | Last updated: 2026-03-07
Overview
boatrace_common.lua is a utility module that supports boat race gameplay in DST. It does not define a component but instead exports helper functions and prefab generators for deploying race-related objects (e.g., checkpoints, boat spawn points). It integrates with the deployhelper, placer, and inventoryitem components to manage visual placement feedback, deployment validation, and Throwable Deploy Kit creation.
Usage example
-- Register a boatrace start point
local start_point = SpawnPrefab("boatrace_start_marker")
RegisterBoatraceStart(start_point)
-- Create a throwable deploy kit and its placer
local kit_prefab, placer_prefab = MakeThrowableBoatRaceKitPrefabs({
prefab_to_deploy = "boatrace_checkpoint",
bank = "winona_battery",
build = "winona_battery",
deploy_radius = 0.5,
reticule_ring_scale = 1.2,
extradeploytest = function(inst, player, pos) return true end,
do_reticule_ring = true,
})
Dependencies & tags
Components used:
deployhelper(viaAddDeployHelper)placer(used internally forplacer_prefab)inventoryitem(viaSetLandedduring deployment)updatelooper(for visual arrow updates)
Tags added/checked:
"CLASSIFIED","NOCLICK","placer"(on visual arrows)"projectile","complexprojectile"(on throwable kits)"burnt"(checked during deploy helper enabling)"DEPLOY_IGNORE_TAGS"list:{"DECOR", "FX", "INLIMBO", "NOBLOCK", "player"}
Properties
No public properties. This module exports functions and constants only.
Main functions
RegisterBoatraceStart(startpoint)
- Description: Registers a world position as a boat race start point, storing it in
TheWorld._boatrace_starts. Automatically unregisters if thestartpointentity is removed. - Parameters:
startpoint(Entity) — an entity representing a boat race start location. - Returns: Nothing.
find_nearest_boatrace_start(source_position)
- Description: Finds the nearest registered boat race start point to a given position, within
TUNING.MAX_BOATRACE_COMPONENT_DISTANCE. Returns the closest entity ornil. - Parameters:
source_position(Vector3) — world position to check from. - Returns:
{ dsq = number, component = Entity }if found;nilotherwise.
AddDeployHelper(inst, keyfilters)
- Description: Attaches the
deployhelpercomponent to an entity and configures visual arrow feedback. Only runs on non-dedicated clients. - Parameters:
inst(Entity) — entity to attach the helper to (typically a deployable kit).keyfilters(table of strings) — list of key codes (e.g.,{"KEY_R"}) to filter keypresses for deployment.
- Returns: Nothing.
MakeThrowableBoatRaceKitPrefabs(data)
- Description: Generates two prefabs: a throwable deploy kit and its associated placer. Used for items like checkpoints and marker kits.
- Parameters:
data(table) — configuration with the following optional fields:prefab_to_deploy(string) — name of the prefab to spawn on successful deployment.name(string) — custom name for the kit; defaults toprefab_to_deploy.."_throwable_deploykit".deploy_radius(number) — radius around which to check for existing objects (default0.5).bank,build,anim— animation-related asset identifiers.extradeploytest(function) — optional custom deployment validation.product_fn(function) — called on the deployed product instance after spawn.deployfailed_fn(function) — called on a respawned kit if deployment fails.common_postinit,primary_postinit,placer_postinit,data— optional post-init hooks.tags(table) — additional tags for the kit.do_reticule_ring(boolean) — whether to show a reticule ring (defaultfalse).reticule_ring_scale(number) — scale multiplier for the ring (default1.0).
- Returns: Two values:
kit_prefab_definition— the throwable deploy kit prefab data table.placer_prefab_definition— the placer prefab data table.
BoatSpawnCheck(pos, radius, allow_boats)
- Description: Checks whether a circle of points around
posis fully ocean, optionally allowing existing boats. Used to validate boat spawn locations. - Parameters:
pos(Vector3) — center position to check.radius(number, optional) — radius of the check circle (defaultTUNING.DRAGON_BOAT_RADIUS).allow_boats(boolean, optional) — whether existing boats are allowed in the area (defaultfalse).
- Returns:
trueif all sampled points are ocean and valid;falseotherwise.
CheckpointSpawnCheck(pos)
- Description: Checks whether a checkpoint can be spawned at
pos. Ensures:- The area can fit two boats (
BoatSpawnCheckwith radius(2 * TUNING.DRAGON_BOAT_RADIUS) + 0.5, boats allowed). - The point is not within
TUNING.BOATRACE_START_INCLUSION_PROXIMITYof any registered start point.
- The area can fit two boats (
- Parameters:
pos(Vector3) — world position to validate. - Returns:
trueif valid;falseotherwise.
Events & listeners
-
Listens to:
onremove— unregisters the start point fromTheWorld._boatrace_startswhen thestartpointentity is removed (inRegisterBoatraceStart). -
Pushes:
onbuilt— on deployed product prefab when deployment succeeds (viaproduct_instance:PushEvent("onbuilt", ...)).on_landed/on_no_longer_landed— viaInventoryItem:SetLanded(...)during kit respawn or land detection.