Nightmaregrowth
Based on game build 714014 | Last updated: 2026-03-06
Overview
The nightmaregrowth prefab represents a corrupted, growing entity found in the Grotto. It emits a powerful negative sanity aura and initiates structural destruction upon growth. The prefab is implemented as a multi-prefab system including a main entity (nightmaregrowth), a visual crack effect (nightmaregrowth_crack), and spawner variants. It integrates with the inspectable, sanityaura, and workable components to provide narrative interaction, sanity effects, and destruction behavior.
Usage example
-- Create a nightmare growth at world position
local growth = SpawnPrefab("nightmaregrowth")
growth.Transform:SetPosition(x, y, z)
-- Grow the structure manually (triggers destruction and visual effects)
if growth.growfn then
growth:growfn()
end
Dependencies & tags
Components used: sanityaura, inspectable
Tags: Adds ancient_text to the main entity; FX, NOCLICK, DECOR to the crack effect.
Properties
No public properties are exposed by the main nightmaregrowth entity beyond its components.
Main functions
grow(inst)
- Description: Triggers the growth animation, spawns the
collapse_smallFX prefab, destroys nearby workable structures within radius 4, plays sound effects, and sets up crack animations. - Parameters:
inst(Entity) — the nightmaregrowth instance. - Returns: Nothing.
- Error states: None. Only affects entities within
DESTROY_RADIUS(4 units) that are valid, possessworkable, and areCanBeWorked.
SpawnCrack(inst)
- Description: Spawns the
nightmaregrowth_crackprefab at the current position, sets its rotation if available, and destroys any valid, workable structures in the immediate area usingworkable:Destroy. - Parameters:
inst(Entity) — the nightmaregrowth instance. - Returns: Nothing.
rune_getdescription(inst, viewer)
- Description: Returns a narrative text line if the viewer has the
ancient_readertag in any equipped slot; advances story progress first. - Parameters:
inst(Entity) — the nightmaregrowth instance.viewer(Entity) — the player inspecting the entity.
- Returns: String (from
STRINGS.NIGHTMARE_OVERGROWTH.LINE_n) ornilif conditions not met.
rune_getstatus(inst)
- Description: Advances story progress counter without returning a status string.
- Parameters:
inst(Entity) — the nightmaregrowth instance. - Returns:
nil.
Events & listeners
- Listens to:
onremove— triggersOnRemoveto clean up the crack effect. - Pushes: No events are fired by this prefab’s code.
Save/Load Integration
The main entity supports serialization via OnSave and OnLoad hooks:
- Saves
storyprogress(narrative line index) andcrack_rotation. - Loads saved data and restores state; ensures
_storyprogressglobal does not regress.
Spawner Variants
Three prefabs manage spawning behavior:
nightmaregrowth_spawner: Schedulesnightmaregrowthcreation after a random delay (2.5–5.5 seconds), then removes itself. SupportsOnLoadto spawn immediately if loaded mid-delay.retrofitted_grotterwar_spawnpointandretrofitted_grotterwar_homepoint: Register server-side events for dungeon generation systems; do not spawn entities directly.
crackfx (nightmaregrowth_crack)
A non-networked, non-persistent FX entity with:
- Layer
LAYER_BACKGROUND, orientationOnGround, sort order 3. - Tags:
FX,NOCLICK,DECOR. - Plays
crack_idleanimation (non-looping initially, but transitioned to). - Rotation set randomly at spawn; rotation saved/restored alongside main entity.