Ipecacsyrup
Based on game build 714014 | Last updated: 2026-03-05
Overview
The ipecacsyrup prefab represents a consumable item that, when eaten by a character currently in the ipecacpoop state, applies a debuff (ipecacsyrup_buff) that triggers recurring damage and poop-spawning effects over time. The debuff is implemented as a separate non-networked entity (ipecacsyrup_buff) that tracks a tick counter and fires timed events. It integrates with the edible, debuff, timer, and periodicspawner systems.
Usage example
local inst = SpawnPrefab("ipecacsyrup")
inst.components.edible.healthvalue -- yields -TUNING.HEALING_MED
inst.components.edible:SetOnEatenFn(my_custom_on_eaten_fn)
Dependencies & tags
Components used: edible, stackable, tradable, inspectable, inventoryitem, debuff, timer, periodicspawner, health.
Tags: Adds CLASSIFIED to ipecacsyrup_buff entity (for internal logic).
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
_tick_count | number | TUNING.IPECAC_POOP_COUNT | Remaining ticks before the debuff ends. Initialized in fn_buff. |
prefab | string | "ipecacsyrup" or "ipecacsyrup_buff" | Prefab identifier passed to Prefab() constructor. |
Main functions
syrup_OnEaten(inst, eater)
- Description: Handler executed when the syrup is consumed. Checks if the eater is in the
ipecacpoopstate and, if so, applies theipecacsyrup_buffdebuff. - Parameters:
inst(Entity) — the syrup item instance.
eater(Entity) — the entity that ate the syrup. - Returns: Nothing.
- Error states: Only triggers debuff if
eater.sg ~= nilandeater.sg:HasState("ipecacpoop")returns true.
buff_OnAttached(inst, target)
- Description: Callback invoked when the debuff is attached to a target. Sets the buff entity as a child of the target, resets tick count, and starts the tick timer. Registers listeners for
deathandonremoveevents to clean up. - Parameters:
inst(Entity) — theipecacsyrup_buffentity.
target(Entity) — the entity receiving the debuff. - Returns: Nothing.
buff_DoTick(inst)
- Description: Executes one tick of the debuff: decrements the tick counter, spawns a
poopat the target’s position, applies damage, fires theipecacpoopevent, and restarts the timer for the next tick (if not exhausted). - Parameters:
inst(Entity) — theipecacsyrup_buffentity. - Returns: Nothing.
- Error states: If
_tick_count <= 0, stops the debuff instead of spawning or damaging.
buff_OnTimerDone(inst, data)
- Description: Event callback for
timerdone; dispatchesbuff_DoTickif the timer name matchesIPECAC_TICK_TIMERNAME. - Parameters:
inst(Entity) — theipecacsyrup_buffentity.
data(table) — timer data, expected to containname. - Returns: Nothing.
buff_OnExtended(inst, target)
- Description: Resets the tick count to
TUNING.IPECAC_POOP_COUNTwhen the debuff is reapplied (prevents stacking). Does not extend duration — only resets remaining ticks. - Parameters:
inst(Entity) — theipecacsyrup_buffentity.
target(Entity) — the debuffed entity (unused). - Returns: Nothing.
Events & listeners
- Listens to:
timerdone— handled bybuff_OnTimerDone.
death(on target) — triggersdebuff:Stop().
onremove(on target) — triggersdebuff:Stop(). - Pushes:
ipecacpoop— fired on the debuffed target during each tick.