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 ​
int | default_level | 1 |
int | experience_worth | 0 |
float | experience_multiplier | 1.0 |
int | faction | 0 |
StatsData | stats_data | StatsData.new() |
int | template_id | 0 |
TemplateBaseline | template_baseline | |
Array[int] | template_fixed_stats | [] |
Array[LootRule] | loot_rules | [] |
LootTableLogic | loot_table_logic | LootTableLogic.NONE |
int | loot_table | 0 |
Dictionary | inventory | { ... } |
int | basic_attack_data | 0 |
Array[int] | active_abilities_data | [] |
Array[int] | passive_abilities_data | [] |
Dictionary | ability_ranks | {} |
CalculationFormula | ability_rank_formula | |
int | behavior_script | 0 |
int | combat_script | 0 |
int | animation_profile | 0 |
String | attack_tag | "" |
String | stance_tag | "" |
bool | is_ranged | false |
String | aim_tag | "" |
String | reload_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 = {} ) |
void | convert_legacy_loot() |
int | get_ability_rank( ability_id: int, level: int ) |
void | set_faction( faction_id: int ) |
FactionDefinition | get_faction() |
int | get_faction_id() |
String | get_team_name() |
void | set_default_level( new_default_level: int ) |
void | set_experience_worth( experience: int ) |
int | get_experience_worth() |
void | set_stats_data( new_stats: StatsData ) |
StatsData | get_stats_data() |
void | set_behavior_script( script_id: int ) |
ModularBehaviorScript | get_behavior_script() |
void | set_combat_script( script_id: int ) |
ModularCombatScript | get_combat_script() |
String | get_aim_tag() |
String | get_reload_tag() |
WeaponProfile | get_animation_profile() |
Dictionary | get_animation_tags() |
bool | has_animation_tags() |
String | get_animation_tag_for_category( category: String ) |
Dictionary | get_inventory() |
void | set_inventory( new_inventory: Dictionary ) |
void | add_inventory_item( item_id: int, quantity: int = 1 ) |
bool | remove_inventory_item( item_id: int, quantity: int = 1 ) |
void | clear_inventory_item( item_id: int ) |
int | get_inventory_item_quantity( item_id: int ) |
bool | has_inventory_item( item_id: int ) |
Dictionary | get_inventory_items() |
void | add_currency( currency_id: int, amount: int ) |
bool | remove_currency( currency_id: int, amount: int ) |
void | set_currency_amount( currency_id: int, amount: int ) |
int | get_currency_amount( currency_id: int ) |
bool | has_currency( currency_id: int ) |
Dictionary | get_currencies() |
void | clear_currency( currency_id: int ) |
void | clear_all_inventory() |
void | set_basic_attack_data( ability_id: int ) |
ActiveAbilityDefinition | get_basic_attack_data() |
int | get_basic_attack_id() |
void | add_active_ability_definition( ability_id: int ) |
bool | remove_active_ability_definition( ability_id: int ) |
bool | remove_active_ability_definition_by_name( ability_name: String ) |
bool | remove_active_ability_definition_by_id( ability_id: int ) |
Array[int] | get_active_abilities_data_ids() |
Array[ActiveAbilityDefinition] | get_active_abilities_data() |
int | get_active_ability_definition_count() |
bool | has_active_ability_definition( ability_name: String ) |
bool | has_active_ability_definition_by_id( ability_id: int ) |
ActiveAbilityDefinition | get_active_ability_definition( ability_name: String ) |
ActiveAbilityDefinition | get_active_ability_definition_by_id( ability_id: int ) |
void | clear_active_abilities_data() |
void | add_passive_ability_definition( ability_id: int ) |
bool | remove_passive_ability_definition( ability_id: int ) |
bool | remove_passive_ability_definition_by_name( ability_name: String ) |
bool | remove_passive_ability_definition_by_id( ability_id: int ) |
Array[int] | get_passive_abilities_data_ids() |
Array[PassiveAbilityDefinition] | get_passive_abilities_data() |
int | get_passive_ability_definition_count() |
bool | has_passive_ability_definition( ability_name: String ) |
bool | has_passive_ability_definition_by_id( ability_id: int ) |
PassiveAbilityDefinition | get_passive_ability_definition( ability_name: String ) |
PassiveAbilityDefinition | get_passive_ability_definition_by_id( ability_id: int ) |
void | clear_passive_abilities_data() |
int | get_total_ability_definition_count() |
bool | is_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