Pillow equipment
Based on game build 714014 | Last updated: 2026-03-06
Overview
pillow_equipment.lua defines the creation logic for three types of prefabs: body pillows, hand pillows, and their associated attack FX. It uses MakeBodyPillow and MakeHandPillow to generate configurable pillow prefabs with specific behaviors: body pillows act as wearable defense items with block-related callbacks, while hand pillows function as weapons with knockback and minigame-aware attack logic. The script also defines MakePillowFX for visual effects triggered during hand pillow attacks. Dependencies are drawn from pillow_common.lua (for shared utilities like knockback handling) and pillow_defs.lua (for material-specific data). Components like equippable, weapon, and minigame_participator are used to integrate with DST’s ECS.
Usage example
-- Example: spawn a hand pillow and equip it
local pillow = SpawnPrefab("handpillow_wool")
if pillow and pillow.components.equippable then
local player = ThePlayer
player.components.inventory:Equip(pillow, EQUIPSLOTS.HANDS)
end
-- Example: spawn a body pillow
local bodypillow = SpawnPrefab("bodypillow_wool")
Dependencies & tags
Components used: named, inspectable, inventoryitem, equippable, weapon, minigame_participator (read-only via CurrentMinigameType), smallburnable, smallpropagator, hauntablelaunch
Tags: bodypillow, pillow, propweapon, FX, NOCLICK, _named (temporary, removed post-pristine state on master)
Properties
No public properties are exposed directly by this script. Instances created by MakeHandPillow and MakeBodyPillow set internal state (e.g., inst._knockback, inst._defense_callback), but these are private implementation details.
Main functions
MakeBodyPillow(materialname, pillowdata)
- Description: Constructs and returns a
Prefabfor a wearable body pillow. Sets up animation overrides on equip/unequip and registers block/attack event handlers to trigger defense callbacks with cooldowns. - Parameters:
materialname(string) - identifies the visual material and animation;pillowdata(table, optional) - configuration with keys likedefense_cooldown,defense_callback,body_prize_value. - Returns:
Prefabinstance (non-nil). - Error states: None;
pillowdatadefaults to empty table if omitted.
MakeHandPillow(materialname, pillowdata)
- Description: Constructs and returns a
Prefabfor a hand pillow weapon. Configures weapon damage/range, equip animation, and attack behavior—including minigame-aware knockback or simple damage event propagation. - Parameters:
materialname(string) - identifies the visual material and animation;pillowdata(table, optional) - configuration with keys likeknockback,strengthmult,hand_prize_value. - Returns:
Prefabinstance (non-nil). - Error states: None;
pillowdatadefaults to empty table if omitted.
MakePillowFX(materialname, data)
- Description: Constructs and returns a
Prefabfor a short-lived visual FX entity used during hand pillow attacks. Plays debris animation and supports fast-forwarding. - Parameters:
materialname(string) - identifies the FX animation;data(table) - unused in current implementation. - Returns:
Prefabinstance (non-nil).
FastForwardAttackFX(inst, pct)
- Description: Utility on FX entities to skip part of the animation and延时 removal. Called externally to accelerate FX playback.
- Parameters:
inst(Entity) - the FX instance;pct(number, clamped0–1) - fraction of animation to skip to. - Returns: Nothing. Schedules a delayed removal task.
Events & listeners
- Listens to:
blocked,attacked(on body pillow owner entity, viainst:ListenForEvent) to trigger defense callback logic. - Pushes: None directly (attacks push
attackedon target entities, but this is handled by the weapon component'sSetOnAttackcallback).