Module util

Multiplayer Level Utility Functions

This module provides utilities for extracting spawn positions, tool spawn locations, and points of interest from level tags, as well as generating valid dynamic spawn points in a level using raycasting and terrain checks.

Tags Used in FindLocations:

  • "playerspawn" General player spawn location (used when no team is specified).
  • "teamspawn" Team-specific spawn. Tagged with: teamspawn=1, teamspawn=2, etc.
  • "ammospawn" Tool or ammo loot spawn. Optional: rarity=low
  • "pointofinterest" Marks locations of gameplay interest. Optionally: pointofinterest=1, pointofinterest=2

Functions

utilLoadLevelPlayerSpawns ([teamId]) Loads player spawn transforms from tagged level locations.
utilLoadLevelToolSpawns ([rarity]) Loads tool spawn locations from the level by tag and optional rarity.
utilLoadLevelPoi ([teamId]) Loads points of interest (POIs) from the level.
utilGenerateSpawnPointLists (densities) Generates multiple lists of spawn transforms with varying densities.
utilGenerateSpawnPointsDensity (density[, existingTransforms]) Generates a list of spawn points with the specified density.
utilGenerateSpawnPoints (count[, existingTransforms]) Generates a specified number of valid random spawn transforms in the level.


Functions

utilLoadLevelPlayerSpawns ([teamId])
Loads player spawn transforms from tagged level locations.

Searches for locations tagged as "playerspawn" or "teamspawn", and optionally filters them by team ID.

Parameters:

  • teamId number The numeric team ID to filter by (optional)

Returns:

    table A list of transforms representing spawn points
utilLoadLevelToolSpawns ([rarity])
Loads tool spawn locations from the level by tag and optional rarity.

Finds locations tagged "ammospawn" and filters them by the given rarity value, if specified.

Parameters:

  • rarity string A string representing the rarity level (e.g. "low", "medium", "high"). (optional)

Returns:

    table A list of transforms representing ammo/tool spawn points
utilLoadLevelPoi ([teamId])
Loads points of interest (POIs) from the level.

Looks for locations tagged as "pointofinterest", optionally filtering by a numeric team ID if POIs are team-specific.

Parameters:

  • teamId number The numeric team ID to filter by. (optional)

Returns:

    table A list of transforms (TTransform) representing POIs
utilGenerateSpawnPointLists (densities)
Generates multiple lists of spawn transforms with varying densities.

Uses utilGenerateSpawnPoints to create a list of transforms for each density level. Densities are specified as a list of floats, where each float represents the density

Parameters:

  • densities table A list of density values (e.g. {1.0, 0.66, 0.5})

Returns:

    table A list of lists, where each sublist contains transforms (TTransform) for a specific density
utilGenerateSpawnPointsDensity (density[, existingTransforms])
Generates a list of spawn points with the specified density.

Uses utilGenerateSpawnPoints to create a list of transforms based on the given density.

Parameters:

  • density number A number representing the density of spawn points (e.g. 1.0 for high density)
  • existingTransforms table A list of existing transforms to avoid overlap (optional)

Returns:

    table A list of transforms (TTransform) representing valid spawn points
utilGenerateSpawnPoints (count[, existingTransforms])
Generates a specified number of valid random spawn transforms in the level.

Uses utilGenerateSpawnPoint to test and collect terrain-validated spawn positions.

Parameters:

  • count number Number of valid spawn points to generate
  • existingTransforms table A list of existing transforms to avoid overlap (optional)

Returns:

    table A list of transforms (TTransform) representing valid spawn points
generated by LDoc 1.5.0 Last updated 2025-12-09 10:41:23