Skip to content

UniqueEntityData ​

Inherits: DatabaseResource < Resource

A placed NPC: what the world keeps about one NPC in one world. It holds the id of the definition, the world, the position and rotation, the spawn settings (active at the start, delay, respawn, despawn), and the overrides of this NPC (level, model scale, faction, experience, scripts, loot, stats, interaction). The get_effective_* functions answer with the override when there is one and with the value of the definition otherwise.

Properties ​

intdefinition_id0
intmap_id0
boolis_activetrue
floatspawn_delay0.0
floatrespawn_timer0.0
boolis_unique_encounterfalse
booldespawn_on_deathtrue
intencounter_id0
intlevel_override0
Vector3model_scale_overrideVector3.ZERO
intfaction_id0
intexperience_worth_override0
Array[int]added_ui_tags[]
Array[int]removed_ui_tags[]
floatexperience_multiplier1.0
intbehavior_script_id0
intcombat_script_id0
Array[LootRule]loot_rules_override[]
intloot_table_override0
Dictionaryinventory_override
StatsDatastats_override
TemplateBaselinetemplate_baseline
Array[int]template_fixed_stats[]
Interactioninteractionnull
Vector3world_positionVector3.ZERO
Vector3world_rotationVector3.ZERO
Vector3facing_directionVector3.FORWARD
Vector3default_face_directionVector3.ZERO

Methods ​

voidupdate_position_from_node( entity_node: Node3D )
Stringget_effective_display_name( definition: EntityDefinition = null )
boolhas_display_name_override()
intget_effective_level( definition: EntityDefinition = null )
FactionDefinitionget_effective_faction( definition: EntityDefinition = null )
Vector3get_effective_model_scale( definition: EntityDefinition = null )
ModularBehaviorScriptget_effective_behavior_script( definition: EntityDefinition = null )
boolhas_behavior_script_override()
ModularCombatScriptget_effective_combat_script( definition: EntityDefinition = null )
boolhas_combat_script_override()
StatsDataget_effective_stats( definition: EntityDefinition = null )
boolhas_stats_override()
voidset_stats_override_from_definition( definition: EntityDefinition = null )
voidclear_stats_override()
LootTableget_effective_loot_table( definition: EntityDefinition = null )
boolhas_loot_table_override()
boolhas_loot_rules_override()
Array[LootRule]get_effective_loot_rules( definition: EntityDefinition = null )
Dictionaryget_effective_inventory( definition: EntityDefinition = null )
boolhas_inventory_override()
intget_effective_experiance( definition: EntityDefinition = null )
boolhas_experiance_override()
boolhas_interaction()
boolhas_overrides()
boolsave_to_disk()
Stringget_file_path()

Property descriptions ​

int definition_id = 0 ​

DO NOT RESET

int map_id = 0 ​

DO NOT RESET

Spawn Properties

bool is_active = true ​

Wether this NPC is active or hidden on startup

float spawn_delay = 0.0 ​

Delay timer for the spawn

float respawn_timer = 0.0 ​

0 = no respawn (the default: a placed NPC is an authored one, and a spawner is what brings mobs back). Set it for an important NPC that must return after it died

bool is_unique_encounter = false ​

Can only be killed once

bool despawn_on_death = true ​

Entities Body despawn on death after x seconds

Encounter

int encounter_id = 0 ​

The encounter this NPC belongs to (0 = none: it acts alone). NPCs with the same encounter fight as one group: they join a fight together, keep their formation, and react as a group. They can stand anywhere in the scene. Choose it in the Unique Object panel or with the Encounter menu of the placement bar. The encounter itself (its formation, behavior, reactions, respawn) is a record in the Uniques list

Overrides

int level_override = 0 ​

If 0, use EntityDefinition.level

Vector3 model_scale_override = Vector3.ZERO ​

If Vector3.ZERO, use EntityDefinition.model_scale

int faction_id = 0 ​

Overrides the faction of the definition (0 = use the faction of the definition).

int experience_worth_override = 0 ​

Experiance granted to player on death

Array[int] added_ui_tags = [] ​

Entity tags this placed NPC has besides the ones of its definition (a Boss among Normal goblins)

Array[int] removed_ui_tags = [] ​

Entity tags of the definition that this placed NPC does not have

float experience_multiplier = 1.0 ​

Multiplies the experience this NPC gives, on top of the multiplier of its definition (1 = no change). A rare version of a common creature: 3

int behavior_script_id = 0 ​

Overrides the behavior script of the definition (0 = use the one of the definition).

int combat_script_id = 0 ​

Overrides the combat script of the definition (0 = use the one of the definition).

Loot & Inventory

Array[LootRule] loot_rules_override = [] ​

Loot rules of this placed NPC: when it has any they REPLACE the loot rules of its definition (a unique boss with its own table)

int loot_table_override = 0 ​

Older override for the loot table - if 0, uses the loot table of the definition

Dictionary inventory_override ​

Older override for starting inventory - if empty, uses EntityDefinition.inventory

Stats

StatsData stats_override ​

Stats of this placed NPC that replace the ones of its definition. It follows its definition: what the definition gained since is added.

TemplateBaseline template_baseline ​

What the definition was when the stats override last looked at it. The override follows its definition (and the template of the definition): what the definition gained since is added to it

Array[int] template_fixed_stats = [] ​

Stats of the override that keep their own value whatever the definition does

Interactions

Interaction interaction = null ​

Interactions assigned to this specific entity instance

Vector3 world_position = Vector3.ZERO ​

World positioning

Vector3 world_rotation = Vector3.ZERO ​

The rotation of the NPC in the world.

Vector3 facing_direction = Vector3.FORWARD ​

The direction the NPC faces now.

Vector3 default_face_direction = Vector3.ZERO ​

The direction the NPC faces when it is idle (zero = it does not turn back).

Method descriptions ​

void update_position_from_node( entity_node: Node3D ) ​

Copies the position and rotation of the node of the NPC into this record.

String get_effective_display_name( definition: EntityDefinition = null ) ​

The display name: the override, else the one of the definition.

bool has_display_name_override() ​

Does this NPC have a name of its own?

int get_effective_level( definition: EntityDefinition = null ) ​

The level: the override, else the one of the definition.

FactionDefinition get_effective_faction( definition: EntityDefinition = null ) ​

The faction: the override, else the one of the definition.

Vector3 get_effective_model_scale( definition: EntityDefinition = null ) ​

The scale of the model: the override, else the one of the definition.

ModularBehaviorScript get_effective_behavior_script( definition: EntityDefinition = null ) ​

The behavior script: the override, else the one of the definition.

bool has_behavior_script_override() ​

Does this NPC have a behavior script of its own?

ModularCombatScript get_effective_combat_script( definition: EntityDefinition = null ) ​

The combat script: the override, else the one of the definition.

bool has_combat_script_override() ​

Does this NPC have a combat script of its own?

StatsData get_effective_stats( definition: EntityDefinition = null ) ​

The stats: the override (kept up to date with its definition), else the ones of the definition.

bool has_stats_override() ​

Does this NPC have stats of its own?

void set_stats_override_from_definition( definition: EntityDefinition = null ) ​

Set stats override - duplicates from definition if available, otherwise creates new Call this when enabling stats override to get a proper starting point

void clear_stats_override() ​

Clear stats override

LootTable get_effective_loot_table( definition: EntityDefinition = null ) ​

The loot table: the override, else the one of the definition.

bool has_loot_table_override() ​

Does this NPC have a loot table of its own?

bool has_loot_rules_override() ​

Does this NPC have loot rules of its own?

Array[LootRule] get_effective_loot_rules( definition: EntityDefinition = null ) ​

The loot rules of this placed NPC: its own when it has any, else the ones of its definition (with the older table and inventory overrides applied)

Dictionary get_effective_inventory( definition: EntityDefinition = null ) ​

The starting inventory: the override, else the one of the definition.

bool has_inventory_override() ​

Does this NPC have an inventory of its own?

int get_effective_experiance( definition: EntityDefinition = null ) ​

The experience the NPC gives: the override, else the one of the definition.

bool has_experiance_override() ​

Does this NPC have an experience value of its own?

bool has_interaction() ​

Does this NPC have an interaction of its own?

bool has_overrides() ​

Does this placed NPC differ from its definition in anything?

bool save_to_disk() ​

Saves this record to its file in src/data/unique_entities.

String get_file_path() ​

The path of the file of this record.