Skip to content

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 ​

Node3Deditor_visual_skeleton

Variables ​

ThreatTableComponentthreat_table_component
Marker3Dspawn_point
Interactioninteractionnull
Label3Dinteract_prompt_label
Timerspawn_delay_timernull
Timerrespawn_timernull
Timerdespawn_timernull
boolis_waiting_to_spawnfalse # During spawn_delay
boolrescale_pendingfalse
boolis_respawningfalse
floatrespawn_time_remaining0.0

Methods ​

voidinitialize_entity( system_hub: GameHost.SystemHub )
voidsetup_mount_crew()
voidentity_death( announce: bool = true )
voidrespawn_now()
voidset_encounter_id( encounter_id: int )
intget_encounter_id()
boolsave_unique_entity_data( data: UniqueEntityData )
voidsync_to_unique_data()
intget_experience_worth()
boolrescale_level()
intget_fixed_experience_worth()
ThreatTableComponentget_threat_table()
Vector3get_spawn_position()
voidreset_to_spawn()
voidprocess_interaction( entity: Entity )
voidshow_interact_prompt()
voidhide_interact_prompt()
voidresurrect()
Dictionaryget_animation_tags()
Dictionaryto_save_data()
voidfrom_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)