Skip to main content

Rockyherd

Based on game build 714014 | Last updated: 2026-03-07

Overview

rockyherd is a prefab container that acts as a herd spawner for Rocky entities. It maintains an instance of the herd component to track active Rocky members (with a maximum of 6) and uses the periodicspawner component to automatically spawn new Rockies at intervals, adjusted for season. It listens for seasonal changes to dynamically update spawn timing and enforces spawning rules such as maximum density within range and offscreen-only spawning.

Usage example

-- Spawning a new Rocky herd instance (typically done internally by the world generation system)
local herd = Prefab("rockyherd", fn, nil, prefabs)()
-- The prefab is not meant for manual instantiation by modders; it's used as a world entity.

Dependencies & tags

Components used: herd, periodicspawner, scaler Tags: Adds herd, NOBLOCK, NOCLICK

Properties

PropertyTypeDefault ValueDescription
gatherrangenumberTUNING.ROCKYHERD_RANGERadius around the herd centroid where Rockies may gather/spawn.
maxsizenumber6Maximum number of Rocky members allowed in this herd.
membertagstring"rocky"Tag used to identify eligible member entities for this herd.

Main functions

CanSpawn()

  • Description: Determines whether a new Rocky should be spawned based on current herd state and world constraints. Called by periodicspawner before each potential spawn.
  • Parameters: None (accesses inst.components.herd and global tuning values).
  • Returns: true if spawning is allowed; false otherwise.
  • Error states: Returns false if the herd is full or if the number of existing Rockies in range meets or exceeds TUNING.ROCKYHERD_MAX_IN_RANGE.

OnSpawned(newent)

  • Description: Handler called when a new Rocky entity is spawned. Adds the entity to the herd and initializes its scale.
  • Parameters: newent (entity instance) - the newly spawned Rocky entity.
  • Returns: Nothing.
  • Error states: No effect if inst.components.herd is nil.

SeasonalSpawningChanges(season)

  • Description: Adjusts the spawner timing based on the current season. spring increases spawn rate (via SpringGrowthMod).
  • Parameters: season (string) – one of the SEASONS.* constants (e.g., "SPRING", "SUMMER").
  • Returns: Nothing.

Events & listeners

  • Listens to: season (via WatchWorldState) – triggers SeasonalSpawningChanges when the world season changes.
  • Pushes: None.