NPC ​
Inherits: Entity < CharacterBody3D
NPC represents a non-player character in the game. This class handles BOTH editor placement and runtime behavior.
Description ​
Editor Mode:
- Creates visual skeleton for scene preview
- Manages UniqueEntityData creation/deletion
- Syncs position changes to database
Runtime Mode:
- Full entity functionality via Entity base class
- Threat table management
- NPC-specific behavior and combat
- Self-registers with ObjectRegistry when initialized
Properties ​
Node3D | editor_visual_skeleton |
Variables ​
ThreatTableComponent | threat_table_component | |
Marker3D | spawn_point | |
Interaction | interaction | null |
Label3D | interact_prompt_label | |
Timer | spawn_delay_timer | null |
Timer | respawn_timer | null |
Timer | despawn_timer | null |
bool | is_waiting_to_spawn | false # During spawn_delay |
bool | rescale_pending | false |
bool | is_respawning | false |
float | respawn_time_remaining | 0.0 |
Methods ​
void | initialize_entity( system_hub: GameHost.SystemHub ) |
void | setup_mount_crew() |
void | entity_death( announce: bool = true ) |
void | respawn_now() |
void | set_encounter_id( encounter_id: int ) |
int | get_encounter_id() |
bool | save_unique_entity_data( data: UniqueEntityData ) |
void | sync_to_unique_data() |
int | get_experience_worth() |
bool | rescale_level() |
int | get_fixed_experience_worth() |
ThreatTableComponent | get_threat_table() |
Vector3 | get_spawn_position() |
void | reset_to_spawn() |
void | process_interaction( entity: Entity ) |
void | show_interact_prompt() |
void | hide_interact_prompt() |
void | resurrect() |
Dictionary | get_animation_tags() |
Dictionary | to_save_data() |
void | from_save_data( save_data: Dictionary, system_hub: GameHost.SystemHub ) |
Signals ​
level_rescaled( old_level: int, new_level: int ) ​
The level of the NPC changed because the party changed (old level, new level)
Property descriptions ​
Node3D editor_visual_skeleton ​
Visual skeleton shown in editor for preview (not used at runtime)
Variable descriptions ​
ThreatTableComponent threat_table_component ​
Threat table for tracking threat from players
Marker3D spawn_point ​
Spawn point marker for respawning
Interaction interaction = null ​
Entity Interactions - NPCs can have multiple interaction types (conversation, vendor, crafting, etc.) Loaded from UniqueEntityData at runtime
Label3D interact_prompt_label ​
The label above the NPC that tells the player what the key does.
Timer spawn_delay_timer = null ​
Spawn/Respawn/Despawn Timers (managed via ChronoManager)
Timer respawn_timer = null ​
The timer that brings the NPC back after its death.
Timer despawn_timer = null ​
The timer that removes the body after the death.
bool is_waiting_to_spawn = false # During spawn_delay ​
Respawn State Tracking
bool rescale_pending = false ​
The party changed while the NPC was in a fight: it takes the new level when the fight ends
bool is_respawning = false ​
During respawn_timer
float respawn_time_remaining = 0.0 ​
For save/load
Method descriptions ​
void initialize_entity( system_hub: GameHost.SystemHub ) ​
Override initialize_entity to add NPC-specific setup ## Regsitry should initialize
void setup_mount_crew() ​
Puts an AI crew on this NPC when its Mount interaction has seats with an AI that acts when nobody sits in them (a tank that drives and shoots by itself)
void entity_death( announce: bool = true ) ​
Kills the NPC: the death, the loot, the experience, and the timers of the respawn and the despawn.
void respawn_now() ​
Brings the NPC back now, at its start, as if its respawn timer had run out (an encounter that respawns uses this)
void set_encounter_id( encounter_id: int ) ​
Puts the NPC in an encounter (0 = takes it out of one). Its unique data keeps it; when the data is not made yet it is kept until it is.
int get_encounter_id() ​
The encounter this NPC belongs to (0 = none).
bool save_unique_entity_data( data: UniqueEntityData ) ​
Save unique entity data to disk and update cache
void sync_to_unique_data() ​
Syncs current entity state to its UniqueEntityData
int get_experience_worth() ​
The experience this NPC gives when it is defeated: the amount of the project's Kill Experience settings for its level, times its multipliers (see NpcLevels)
bool rescale_level() ​
Gives the NPC the level the party needs now (see NpcLevels.rescale)
int get_fixed_experience_worth() ​
The Experience worth set on this NPC itself: the override of a placed NPC, else its definition (0 = none). The project may use it as the amount, or ignore it for a table or a formula of the level
ThreatTableComponent get_threat_table() ​
Get the threat table component
Vector3 get_spawn_position() ​
Get the spawn position for this NPC
void reset_to_spawn() ​
Reset NPC to spawn position
void process_interaction( entity: Entity ) ​
Runs the primary interaction of the NPC for an entity.
void show_interact_prompt() ​
Shows the prompt above the NPC.
void hide_interact_prompt() ​
Hides the prompt above the NPC.
void resurrect() ​
Override to handle NPC-specific death behavior Override to handle NPC-specific resurrection
Dictionary get_animation_tags() ​
Override to get animation tags from NPCDefinition instead of equipment NPCs don't have real equipment, so they define their animation tags directly
Dictionary to_save_data() ​
Standardized save method (calls parent's to_save_data)
void from_save_data( save_data: Dictionary, system_hub: GameHost.SystemHub ) ​
Standardized load method (calls parent's from_save_data)