Charlie Npc
Based on game build 714014 | Last updated: 2026-03-04
Overview
charlie_npc is a prefab component that defines the behavior of Charlie, a special NPC appearing during the nightmare phase. It manages visual and audio cues during spawn, casting preparation, and departure — including dynamic shadow toggling, animation sequencing, and sound playback. It integrates with the charliecutscene component on a related entity (inst.atrium) to signal completion of Charlie's presence via the Finish() method.
Usage example
local charlie = Prefab("charlie_npc")
local inst = CreateEntity()
inst:AddPrefab("charlie_npc")
-- Initial spawn and animations are handled automatically upon prefab instantiation.
-- Subsequent behavior (e.g., StartCasting, Despawn) is triggered externally via inst.StartCasting()
Dependencies & tags
Components used: None directly instantiated (only references inst.atrium.components.charliecutscene).
Tags: Adds "character" and "charlie_npc".
Properties
No public properties are defined in the constructor.
Main functions
StartCasting(cast_time)
- Description: Initiates Charlie’s casting animation sequence and starts looping cast sound. Typically called before Charlie opens a rift.
- Parameters:
cast_time(number) — duration (in frames) for the casting animation. - Returns: Nothing.
Despawn()
- Description: Starts Charlie’s departure sequence: stops cast sound, plays post-animation, disables dynamic shadow, and schedules removal.
- Parameters: None.
- Returns: Nothing.
StartCastingWithDelay(delay, cast_time)
- Description: Schedules
StartCastingandDespawnto run after specified frame delays. Used to coordinate multi-step actions (e.g., waiting before casting begins). - Parameters:
delay(number) — frames to wait before starting cast.cast_time(number) — frames for casting duration.
- Returns: Nothing.
Events & listeners
- Pushes:
"charliecutscene"(viacharliecutscene:Finish()) — signals completion of Charlie’s interaction with the world. - Listens to: None defined directly.
Events & listeners (Entity-wide)
- Listens to:
OnRemoveEntity— internal handler triggersOnRemove()to clean up sounds and callcharliecutscene:Finish()if applicable.
Notes
inst.persists = falseensures the entity is not saved across game sessions.- The
DisplayNameFndynamically changes Charlie’s name based on whether the observing player is known (e.g., Winona, Waxwell) or not (fallback to alternate name). - Dynamic shadow is initially disabled and re-enabled ~22 frames post-spawn (
EnableDynamicShadow). - Sound handles use constants
AMB_SOUND_NAME = "ambsound"andCAST_SOUND_NAME = "castloopsound"for reliable cleanup.