Oceanvine Cocoon
Based on game build 714014 | Last updated: 2026-03-06
Overview
The oceanvine_cocoon is a static, flying environmental entity that spawns water spiders (spider_water) to hunt for ocean fish. It functions as a boss-like spawning node for oceanic threats, using the childspawner component to manage regeneration and release of spider offspring. The cocoon can be ignited (transitioning to a burnt state), frozen, or destroyed, with each outcome triggering distinct behaviors and consequences.
Key interactions include:
- Responding to fire via the
burnablecomponent and state transition tooceanvine_cocoon_burnt - Freezing via the
freezablecomponent, halting spawner activity - Taking damage to release investigating spiders via the
combatandchildspawnercomponents - Spawning fish-investigating spiders on a recurring timer
It integrates with world settings via WorldSettings_ChildSpawner_* functions to enable/disable behavior based on TUNING.OCEANVINE_ENABLED.
Usage example
-- Create a new oceanvine_cocoon instance
local cocoon = SpawnPrefab("oceanvine_cocoon")
cocoon.Transform:SetPosition(x, y, z)
-- Trigger cocoon to release all children immediately
if cocoon.SummonChildren then
cocoon:SummonChildren()
end
-- Manually ignite the cocoon (e.g., from external fire source)
cocoon:PushEvent("activated", { target = player })
Dependencies & tags
Components used: burnable, childspawner, combat, distancefade (client-only), freezable, health, inspectable, lootdropper, sleeper, timer
Tags added: flying, ignorewalkableplatforms, NOBLOCK, plant, spidercocoon, webbed, soulless
Tags dynamically added/removed during lifecycle: burnt, notarget, noattack (on burnt death)
Properties
No public properties are initialized in the constructor. All state is encapsulated in components.
Main functions
The oceanvine_cocoon prefab uses several internal callback functions registered via component APIs. These are not called directly by modders but may be referenced in event handling.
cocoon_ignited(inst, source, doer)
- Description: Triggered when the cocoon is ignited. Releases all pending spiders, stops spawning, and pauses the fish-search timer.
- Parameters:
inst(Entity) — the cocoon instance
source,doer— ignition context (unused in logic) - Returns: Nothing.
- Error states: No direct failure conditions; child release may return empty table if cocoon has no children.
cocoon_burnt(inst)
- Description: Transitions cocoon to burnt state: adds
burntandnotargettags, disables minimap, spawns a temporary fire FX entity, and schedules transition tooceanvine_cocoon_burntafter animation. - Parameters:
inst(Entity) - Returns: Nothing.
cocoon_extinguish(inst)
- Description: Called when the cocoon is extinguished (e.g., rain, water). Restarts spider spawning and resumes the fish timer.
- Parameters:
inst(Entity) - Returns: Nothing.
play_hit(inst)
- Description: Plays the cocoon’s hit animation and sound. Used by
OnHitand other trigger events. - Parameters:
inst(Entity) - Returns: Nothing.
spawn_investigators(inst, data)
- Description: Spawns up to two water spiders to investigate an attack target, with staggered timing.
- Parameters:
inst(Entity) — cocoon instance
data(table) — must containtargetentity for positioning; optional - Returns: Nothing.
- Error states: Returns early if
freezablecomponent reports frozen state.
look_for_fish(inst)
- Description: Scans for ocean fish within 10 units; if found, spawns one spider to investigate, then schedules the next check.
- Parameters:
inst(Entity) - Returns: Nothing.
OnHit(inst, attacker)
- Description: Combat hook called when cocoon takes damage. Triggers
spawn_investigators. - Parameters:
inst(Entity)
attacker(Entity) - Returns: Nothing.
OnFreeze(inst)
- Description: Responds to freeze event: plays frozen animation, stops spider spawning.
- Parameters:
inst(Entity) - Returns: Nothing.
OnUnFreeze(inst)
- Description: Responds to unfreeze event: clears frozen override, resumes spawning.
- Parameters:
inst(Entity) - Returns: Nothing.
OnKilled(inst)
- Description: Handles cocoon destruction. Releases remaining spiders, drops loot, plays destruction sound, and notifies nearby
cocoon_hometrees. - Parameters:
inst(Entity) - Returns: Nothing.
SummonChildren(inst)
- Description: Public API exposed as
inst.SummonChildrenfor external triggers (e.g.,spider_whistle). Spawns all remaining spiders immediately. - Parameters:
inst(Entity) - Returns: Nothing.
- Error states: Silently returns if cocoon is dead or frozen.
Events & listeners
-
Listens to:
animover— triggersgo_to_burntafter burnt pre-animationdeath— triggersOnKilledactivated— triggersspawn_investigatorsfreeze— triggersOnFreezeonthaw— triggersOnThawunfreeze— triggersOnUnFreezelunarhailbuildupworked— triggersOnHit(viadata.doer)startquake,endquake(onTheWorld.net) — manages_quakingstate on released spiderstimerdone— callson_timer_finishedto cyclelook_for_fish
-
Pushes:
burntup— fired when entering burnt phasecocoon_destroyed— notifies nearbycocoon_hometrees (position passed in event data)