Skip to content

NPCDefinition ​

Inherits: EntityDefinition < DatabaseResource < Resource

NPCDefinition extends EntityDefinition with combat stats, AI behavior, and loot systems Used for creating NPC entities with full combat and inventory capabilities

Properties ​

intdefault_level1
intexperience_worth0
floatexperience_multiplier1.0
intfaction0
StatsDatastats_dataStatsData.new()
inttemplate_id0
TemplateBaselinetemplate_baseline
Array[int]template_fixed_stats[]
Array[LootRule]loot_rules[]
LootTableLogicloot_table_logicLootTableLogic.NONE
intloot_table0
Dictionaryinventory{ ... }
intbasic_attack_data0
Array[int]active_abilities_data[]
Array[int]passive_abilities_data[]
Dictionaryability_ranks{}
CalculationFormulaability_rank_formula
intbehavior_script0
intcombat_script0
intanimation_profile0
Stringattack_tag""
Stringstance_tag""
boolis_rangedfalse
Stringaim_tag""
Stringreload_tag""

Methods ​

Array[LootRule]get_loot_rules( table_override: int = 0, inventory_override: Dictionary = {} )
Array[LootRule]get_legacy_loot_rules( table_override: int = 0, inventory_override: Dictionary = {} )
voidconvert_legacy_loot()
intget_ability_rank( ability_id: int, level: int )
voidset_faction( faction_id: int )
FactionDefinitionget_faction()
intget_faction_id()
Stringget_team_name()
voidset_default_level( new_default_level: int )
voidset_experience_worth( experience: int )
intget_experience_worth()
voidset_stats_data( new_stats: StatsData )
StatsDataget_stats_data()
voidset_behavior_script( script_id: int )
ModularBehaviorScriptget_behavior_script()
voidset_combat_script( script_id: int )
ModularCombatScriptget_combat_script()
Stringget_aim_tag()
Stringget_reload_tag()
WeaponProfileget_animation_profile()
Dictionaryget_animation_tags()
boolhas_animation_tags()
Stringget_animation_tag_for_category( category: String )
Dictionaryget_inventory()
voidset_inventory( new_inventory: Dictionary )
voidadd_inventory_item( item_id: int, quantity: int = 1 )
boolremove_inventory_item( item_id: int, quantity: int = 1 )
voidclear_inventory_item( item_id: int )
intget_inventory_item_quantity( item_id: int )
boolhas_inventory_item( item_id: int )
Dictionaryget_inventory_items()
voidadd_currency( currency_id: int, amount: int )
boolremove_currency( currency_id: int, amount: int )
voidset_currency_amount( currency_id: int, amount: int )
intget_currency_amount( currency_id: int )
boolhas_currency( currency_id: int )
Dictionaryget_currencies()
voidclear_currency( currency_id: int )
voidclear_all_inventory()
voidset_basic_attack_data( ability_id: int )
ActiveAbilityDefinitionget_basic_attack_data()
intget_basic_attack_id()
voidadd_active_ability_definition( ability_id: int )
boolremove_active_ability_definition( ability_id: int )
boolremove_active_ability_definition_by_name( ability_name: String )
boolremove_active_ability_definition_by_id( ability_id: int )
Array[int]get_active_abilities_data_ids()
Array[ActiveAbilityDefinition]get_active_abilities_data()
intget_active_ability_definition_count()
boolhas_active_ability_definition( ability_name: String )
boolhas_active_ability_definition_by_id( ability_id: int )
ActiveAbilityDefinitionget_active_ability_definition( ability_name: String )
ActiveAbilityDefinitionget_active_ability_definition_by_id( ability_id: int )
voidclear_active_abilities_data()
voidadd_passive_ability_definition( ability_id: int )
boolremove_passive_ability_definition( ability_id: int )
boolremove_passive_ability_definition_by_name( ability_name: String )
boolremove_passive_ability_definition_by_id( ability_id: int )
Array[int]get_passive_abilities_data_ids()
Array[PassiveAbilityDefinition]get_passive_abilities_data()
intget_passive_ability_definition_count()
boolhas_passive_ability_definition( ability_name: String )
boolhas_passive_ability_definition_by_id( ability_id: int )
PassiveAbilityDefinitionget_passive_ability_definition( ability_name: String )
PassiveAbilityDefinitionget_passive_ability_definition_by_id( ability_id: int )
voidclear_passive_abilities_data()
intget_total_ability_definition_count()
boolis_valid()

Enumerations ​

enum LootTableLogic ​

========== ENUMS ==========

  • NONE = 0
  • ON_INITIALIZE = 1

Property descriptions ​

Level Configuration

int default_level = 1 ​

Default level when NPC is spawned

int experience_worth = 0 ​

Experiance granted to player on death. With Kill Experience on Fixed (Gameplay Config) this is the amount; with a table or a formula it replaces the amount of the level when above 0

float experience_multiplier = 1.0 ​

Multiplies the experience this NPC gives (1 = as the settings say, 2 = double, 0 = none). A placed NPC and the entity types of the NPC have multipliers too, and all of them multiply

Faction & Alignment

int faction = 0 ​

Team/faction alignment for combat and AI behavior

Combat Stats

StatsData stats_data = StatsData.new() ​

Stats configuration including health, resources, and combat stats

Template

int template_id = 0 ​

The template this one follows (an id of the npc_template / interactable_template database type), 0 = none. An entity that follows a template has the changes of the template added when they are made (see EntityTemplates). Its growth is the growth of the template

TemplateBaseline template_baseline ​

What the template was when this entity last looked at it (the difference to the template now is what is added)

Array[int] template_fixed_stats = [] ​

Stats whose base value does not follow the template (they have the value set here whatever the template does)

Loot Configuration

Array[LootRule] loot_rules = [] ​

What this NPC hands out and when: each rule is a loot table with a trigger (when it is made, when it dies, the first time someone opens its pockets) and a source for the item level of what drops (see LootRule). A placed NPC can replace the rules

LootTableLogic loot_table_logic = LootTableLogic.NONE ​

Older setting, used together with the loot rules: when to generate and add loot from the loot table

int loot_table = 0 ​

Older setting, used together with the loot rules: loot table defining what this entity drops when defeated

Inventory

Dictionary inventory ​

Older setting: the fixed starting items and currency of this NPC. They are still given (as a loot rule with a table of its own, when the NPC is made); new NPCs use loot rules, where a table with only guaranteed entries does the same

Ability Definitions

int basic_attack_data = 0 ​

Primary attack ability definition used for auto-attacks

Array[int] active_abilities_data = [] ​

Collection of active ability definitions this entity can use

Array[int] passive_abilities_data = [] ​

Collection of passive ability definitions that affect this entity

Dictionary ability_ranks = ​

The rank of its abilities: ability id -> rank (abilities with ranks only; an ability that is not listed is rank 1, or what the formula below says)

CalculationFormula ability_rank_formula ​

The rank of its abilities by its level: the levels above the first go in (level 11 gives 10), the ranks above the first come out (rounded down). Linear 0.1: rank 2 at level 11, rank 3 at level 21. Used for the abilities that are not listed above. Empty = rank 1

AI Scripts

int behavior_script = 0 ​

Behavior Script - controls non-combat AI behavior

int combat_script = 0 ​

Combat Script - controls combat AI behavior

Animation Tags

int animation_profile = 0 ​

Animation tags for NPC combat animations (used instead of equipment lookup) The Weapon Profile this NPC fights with (Entity Assets > Weapon Profiles): its attack, stance, block, aim and reload clips. 0 = none: the old tags below are used

String attack_tag = "" ​

Attack animation folder tag (e.g., "1h_weapon_r", "bow", "2h_weapon") This is used by UseStrategy when playing weapon attack animations

String stance_tag = "" ​

Combat idle/stance animation name (e.g., "combat_idle_bow", "combat_idle_2h") This is used by EntityAnimationPlayer for combat idle poses

bool is_ranged = false ​

Whether this NPC uses ranged weapon animations

String aim_tag = "" ​

Aim animation name for ranged NPCs (e.g., "idle_bow_aim")

String reload_tag = "" ​

Reload animation name for ranged NPCs (e.g., "shoot_bow_reload")

Method descriptions ​

Array[LootRule] get_loot_rules( table_override: int = 0, inventory_override: Dictionary = {} ) ​

The loot rules of this NPC: its own, plus the ones its older loot table and inventory settings make (a placed NPC passes its own table and inventory to replace those)

Array[LootRule] get_legacy_loot_rules( table_override: int = 0, inventory_override: Dictionary = {} ) ​

The rules the older settings make (the loot table with its logic, the fixed inventory): what an NPC made before loot rules still gives

void convert_legacy_loot() ​

Moves the older loot table and fixed inventory into the loot rules of the NPC (and clears the older settings), so the editor can edit them

int get_ability_rank( ability_id: int, level: int ) ​

The rank an ability of this NPC has at a level

void set_faction( faction_id: int ) ​

Set faction by ID

FactionDefinition get_faction() ​

Get faction resource from Database

int get_faction_id() ​

Get faction ID

String get_team_name() ​

Get team name from faction

void set_default_level( new_default_level: int ) ​

Set default level

void set_experience_worth( experience: int ) ​

Set experience to grant on death

int get_experience_worth() ​

Get experience this entity grants on death

void set_stats_data( new_stats: StatsData ) ​

Set stats data

StatsData get_stats_data() ​

Get stats data

void set_behavior_script( script_id: int ) ​

Set behavior script by ID

ModularBehaviorScript get_behavior_script() ​

Get behavior script resource from Database

void set_combat_script( script_id: int ) ​

Set combat script by ID

ModularCombatScript get_combat_script() ​

Get combat script resource from Database

String get_aim_tag() ​

Get the aim tag (only valid if is_ranged is true)

String get_reload_tag() ​

Get the reload tag (only valid if is_ranged is true)

WeaponProfile get_animation_profile() ​

The Weapon Profile of this NPC (null when it has none and uses the old tags)

Dictionary get_animation_tags() ​

The animation tags of this NPC: the folder of its profile, else the old tags. A Dictionary with attack_tag, stance_tag, aim_tag, reload_tag and is_ranged

bool has_animation_tags() ​

Check if this NPC has custom animation tags defined

String get_animation_tag_for_category( category: String ) ​

Get animation tag for a specific category Returns empty string if not defined, allowing fallback to defaults

Dictionary get_inventory() ​

Get inventory with proper structure

void set_inventory( new_inventory: Dictionary ) ​

Set inventory

void add_inventory_item( item_id: int, quantity: int = 1 ) ​

Add item to inventory

bool remove_inventory_item( item_id: int, quantity: int = 1 ) ​

Remove item from inventory

void clear_inventory_item( item_id: int ) ​

Clear specific item from inventory

int get_inventory_item_quantity( item_id: int ) ​

Get item quantity

bool has_inventory_item( item_id: int ) ​

Check if inventory has item

Dictionary get_inventory_items() ​

Get all inventory items

void add_currency( currency_id: int, amount: int ) ​

Add currency

bool remove_currency( currency_id: int, amount: int ) ​

Remove currency

void set_currency_amount( currency_id: int, amount: int ) ​

Set currency amount

int get_currency_amount( currency_id: int ) ​

Get currency amount

bool has_currency( currency_id: int ) ​

Check if has currency

Dictionary get_currencies() ​

Get all currencies

void clear_currency( currency_id: int ) ​

Clear specific currency

void clear_all_inventory() ​

Clear entire inventory

void set_basic_attack_data( ability_id: int ) ​

Set basic attack data by ID

ActiveAbilityDefinition get_basic_attack_data() ​

Get basic attack data resource from Database

int get_basic_attack_id() ​

Get basic attack ID

void add_active_ability_definition( ability_id: int ) ​

Add active ability definition by ID

bool remove_active_ability_definition( ability_id: int ) ​

Remove active ability definition by ID

bool remove_active_ability_definition_by_name( ability_name: String ) ​

Remove active ability by name (looks up via Database)

bool remove_active_ability_definition_by_id( ability_id: int ) ​

Remove active ability by ID (direct match)

Array[int] get_active_abilities_data_ids() ​

Get active abilities data as Array of IDs

Array[ActiveAbilityDefinition] get_active_abilities_data() ​

Get active abilities data as Array of resources

int get_active_ability_definition_count() ​

Get active ability count

bool has_active_ability_definition( ability_name: String ) ​

Check if has active ability by name

bool has_active_ability_definition_by_id( ability_id: int ) ​

Check if has active ability by ID

ActiveAbilityDefinition get_active_ability_definition( ability_name: String ) ​

Get active ability resource by name

ActiveAbilityDefinition get_active_ability_definition_by_id( ability_id: int ) ​

Get active ability resource by ID

void clear_active_abilities_data() ​

Clear all active abilities

void add_passive_ability_definition( ability_id: int ) ​

Add passive ability definition by ID

bool remove_passive_ability_definition( ability_id: int ) ​

Remove passive ability definition by ID

bool remove_passive_ability_definition_by_name( ability_name: String ) ​

Remove passive ability by name (looks up via Database)

bool remove_passive_ability_definition_by_id( ability_id: int ) ​

Remove passive ability by ID (direct match)

Array[int] get_passive_abilities_data_ids() ​

Get passive abilities data as Array of IDs

Array[PassiveAbilityDefinition] get_passive_abilities_data() ​

Get passive abilities data as Array of resources

int get_passive_ability_definition_count() ​

Get passive ability count

bool has_passive_ability_definition( ability_name: String ) ​

Check if has passive ability by name

bool has_passive_ability_definition_by_id( ability_id: int ) ​

Check if has passive ability by ID

PassiveAbilityDefinition get_passive_ability_definition( ability_name: String ) ​

Get passive ability resource by name

PassiveAbilityDefinition get_passive_ability_definition_by_id( ability_id: int ) ​

Get passive ability resource by ID

void clear_passive_abilities_data() ​

Clear all passive abilities

int get_total_ability_definition_count() ​

Get total ability count

bool is_valid() ​

Validates that all required NPC configuration is present