Skip to content

ItemInstance ​

Inherits: RefCounted

Runtime instance of an item that references an ItemDefinition for configuration Handles individual item state, modifications, effects, and socket management

Variables ​

ItemDefinitiondefinition
Stringinstance_id
GameHost.SystemHubsystem_hub
CombatManager:combat_manager
int:stack_size
Dictionaryruntime_data{}
Array[EffectInstance]active_equipment_effects[]
boolis_equippedfalse
Entityequipped_tonull
Array[SocketInstance]socket_instances[]
boolall_sockets_filledfalse
EffectInstancefull_socket_bonus_effectnull
Timercooldown_timernull
boolis_on_cooldownfalse
intcurrent_charges0
AbilityInstanceability_instancenull
Array[EnchantEntry]enchants[]
Effect:current_enchant

Methods ​

SocketInstanceget_socket( index: int )
intget_socket_count()
intget_occupied_socket_count()
boolare_all_sockets_filled()
boolsocket_item_at_index( index: int, item: ItemInstance )
ItemInstanceunsocket_item_at_index( index: int )
intfind_available_socket_for_item( item: ItemInstance )
boolauto_socket_item( item: ItemInstance )
Array[ItemInstance]get_socketed_items()
Stringget_display_name()
Stringget_description()
Texture2Dget_icon()
intget_vendor_value()
Vector2iget_shape()
floatget_unit_weight()
floatget_total_weight()
intget_max_stack_size()
intget_item_level()
Dictionaryget_generated()
boolis_generated()
floatget_scale_factor()
Qualityget_quality()
Colorget_quality_color()
Stringget_quality_name()
intget_quality_tier()
voidapply_generated( data: Dictionary )
boolequip( user: Entity )
boolunequip()
booluse( user: Entity )
boolcan_use( user: Entity )
boolenchant_target_item( target_equipment: ItemInstance, user: Entity )
intget_current_charges()
intget_max_charges()
boolhas_charges()
boolis_at_full_charges()
floatget_charge_percentage()
boolcan_stack_with( other_item: ItemInstance )
intadd_to_stack( amount: int )
intremove_from_stack( amount: int )
boolis_stack_full()
boolis_stack_empty()
boolmeets_requirements( user: Entity )
Stringget_requirement_failure_message( user: Entity )
boolis_equipment()
boolis_consumable()
boolis_weapon()
boolis_socketable()
booladd_enchant_effect( effect: Effect, duration: float = -1, source: String = "" )
Dictionarypreview_enchant( effect: Effect )
voidremove_enchant( effect: Effect = null, cleanup_reason: String = "" )
voidremove_current_enchant( cleanup_reason: String = "" )
boolhas_enchant()
Effectget_current_enchant()
Array[Effect]get_enchant_effects()
Dictionaryget_enchant_metadata( effect: Effect = null )
floatget_enchant_time_remaining( effect: Effect = null )
Arrayget_enchant_save_data()
voidrestore_enchant_from_save( save_data: Variant )
Dictionaryto_save_data()
voidfrom_save_data( save_data: Dictionary )
voidreceive_shared_cooldown( duration: float )
voidcleanup()

Signals ​

item_used( item_instance: ItemInstance ) ​

Emitted when the item is used

item_properties_changed( item_instance: ItemInstance ) ​

Emitted when item properties are dynamically changed (durability, enchantments, etc.)

item_equipped( item_instance: ItemInstance, user: Entity ) ​

Emitted when item is equipped (for equipment items)

item_unequipped( item_instance: ItemInstance, user: Entity ) ​

Emitted when item is unequipped (for equipment items)

item_consumed( item_instance: ItemInstance, user: Entity, amount_consumed: int ) ​

Emitted when item is consumed (for consumable items)

item_depleted( item_instance: ItemInstance ) ​

Emitted when on-use item has no charges left and should be removed

socket_changed( item_instance: ItemInstance, socket_index: int, socketable_item: ItemInstance ) ​

Emitted when a socket state changes (item socketed/unsocketed)

sockets_full_status_changed( item_instance: ItemInstance, are_full: bool ) ​

Emitted when all sockets become filled or unfilled

quest_item_used( item_instance: ItemInstance, quest_id: int, user: Entity ) ​

Emitted when a quest item is used: the item, the quest and the user.

readable_item_used( item_instance: ItemInstance, pages: Array[String] ) ​

Emitted when a readable item is used: the item and its pages.

enchant_applied( item_instance: ItemInstance, enchant_effect: Effect ) ​

Emitted when an enchant is applied to this item

enchant_removed( item_instance: ItemInstance, enchant_effect: Effect, reason: String ) ​

Emitted when an enchant expires or is removed from this item

enchant_scroll_used( item_instance: ItemInstance, enchant_scroll: ItemDefinitionEnchantScroll, user: Entity ) ​

Emitted when an enchant scroll is used (for UI integration)

Variable descriptions ​

ItemDefinition definition ​

Reference to the immutable item definition (shared across instances)

String instance_id ​

Unique instance ID for save/load and tracking

GameHost.SystemHub system_hub ​

Combat system manager

CombatManager: combat_manager ​

The combat manager of the game: item definitions start their effects (consumables, socketed gems) through it

int: stack_size ​

Current stack size for this item instance

Dictionary runtime_data = ​

Runtime data storage for item-specific information

Array[EffectInstance] active_equipment_effects = [] ​

Active effect instances from this equipment (only for ItemDefinitionEquipment)

bool is_equipped = false ​

Whether this equipment is currently equipped

Entity equipped_to = null ​

The entity this equipment is equipped to (if any)

Array[SocketInstance] socket_instances = [] ​

Array of socket instances for this item (only for equipment with sockets)

bool all_sockets_filled = false ​

Whether all sockets are currently filled

EffectInstance full_socket_bonus_effect = null ​

Active effect instance from full socket bonus (if any)

Timer cooldown_timer = null ​

Cooldown timer for consumable items

bool is_on_cooldown = false ​

Whether this consumable is on cooldown

int current_charges = 0 ​

Current charges for on-use items

AbilityInstance ability_instance = null ​

Ability instance for on-use items (holds the runtime state of the item's ability)

Array[EnchantEntry] enchants = [] ​

The enchants of the item (see the enchant system below)

Effect: current_enchant ​

The first enchant effect (null if none), kept for older code

Method descriptions ​

SocketInstance get_socket( index: int ) ​

Get socket instance by index

int get_socket_count() ​

Get total number of sockets

int get_occupied_socket_count() ​

Get number of occupied sockets

bool are_all_sockets_filled() ​

Check if all sockets are filled

bool socket_item_at_index( index: int, item: ItemInstance ) ​

Socket an item into a specific socket

ItemInstance unsocket_item_at_index( index: int ) ​

Remove item from a specific socket

int find_available_socket_for_item( item: ItemInstance ) ​

Find first available socket for a socketable item

bool auto_socket_item( item: ItemInstance ) ​

Auto-socket an item into the first available compatible socket

Array[ItemInstance] get_socketed_items() ​

Get all socketed items

String get_display_name() ​

Get display name from definition (a generated item: with the names of its affixes, as its quality says)

String get_description() ​

Get description from definition

Texture2D get_icon() ​

Get icon from definition

int get_vendor_value() ​

Get vendor value from definition (a generated item: times the value multiplier of its quality and the growth of an item that scales)

Vector2i get_shape() ​

Get max stack size from definition The cells the item covers in a grid (width, height; never below 1 x 1)

float get_unit_weight() ​

What one of this item weighs

float get_total_weight() ​

What the whole stack weighs

int get_max_stack_size() ​

How many of the item fit in one stack.

int get_item_level() ​

The item level (a generated item: the level it was generated at)

Dictionary get_generated() ​

What was rolled for this item (empty for an item that was not generated)

bool is_generated() ​

Was the item generated (random affixes, a level)?

float get_scale_factor() ​

How much the written stats grow for an item that scales with its item level (1 for any other item)

Quality get_quality() ​

The quality of the item: the one that was rolled for a generated item, else the one of the definition

Color get_quality_color() ​

The color of the quality of the item.

String get_quality_name() ​

The name of the quality of the item (Common when it has none).

int get_quality_tier() ​

The tier of the quality of the item (higher is rarer).

void apply_generated( data: Dictionary ) ​

Puts the rolled data on the item: the extra sockets it has, and the data itself (what ItemGenerator made; also what a save gives back)

bool equip( user: Entity ) ​

Equip this item (for equipment items) - now only handles state tracking

bool unequip() ​

Unequip this item - now only handles state tracking

bool use( user: Entity ) ​

Use the item

bool can_use( user: Entity ) ​

Check if this item instance can be used

bool enchant_target_item( target_equipment: ItemInstance, user: Entity ) ​

Enchant a target equipment item (for enchant scrolls)

int get_current_charges() ​

Get current charges for on-use items

int get_max_charges() ​

Get maximum charges for on-use items

bool has_charges() ​

Check if on-use item has charges remaining

bool is_at_full_charges() ​

Check if on-use item is at full charges

float get_charge_percentage() ​

Get charges remaining as a percentage (0.0 to 1.0)

bool can_stack_with( other_item: ItemInstance ) ​

Check if this item can stack with another item instance

int add_to_stack( amount: int ) ​

Add to stack size

int remove_from_stack( amount: int ) ​

Remove from stack size

bool is_stack_full() ​

Check if stack is full

bool is_stack_empty() ​

Check if stack is empty

bool meets_requirements( user: Entity ) ​

Check if this item meets requirements for a user

String get_requirement_failure_message( user: Entity ) ​

Get requirement failure message

bool is_equipment() ​

Check if this is a specific item type

bool is_consumable() ​

Is the item a consumable?

bool is_weapon() ​

Is the item a weapon?

bool is_socketable() ​

Is the item a gem or rune that fits a socket?

bool add_enchant_effect( effect: Effect, duration: float = -1, source: String = "" ) ​

Add an enchant effect to this equipment item. False when the item is not equipment, or a group of the enchant refuses it (the item keeps its enchants)

Dictionary preview_enchant( effect: Effect ) ​

Would this enchant be refused, and which enchants would it replace? (for a scroll or an ability that asks before it spends anything)

void remove_enchant( effect: Effect = null, cleanup_reason: String = "" ) ​

Remove one enchant (null: every enchant of the item)

void remove_current_enchant( cleanup_reason: String = "" ) ​

Remove every enchant (the single enchant of the old rules)

bool has_enchant() ​

Does this item have an enchant?

Effect get_current_enchant() ​

The first enchant effect (null if none); get_enchant_effects lists them all

Array[Effect] get_enchant_effects() ​

The effects of the enchants on the item.

Dictionary get_enchant_metadata( effect: Effect = null ) ​

The data of an enchant (the first one when no effect is given).

float get_enchant_time_remaining( effect: Effect = null ) ​

Time left on an enchant (-1 for permanent, 0 if it is not on the item); the first enchant when none is given

Array get_enchant_save_data() ​

Enchant save data: one entry per enchant

void restore_enchant_from_save( save_data: Variant ) ​

Restore the enchants from save data (a list, or the single enchant dictionary of older saves)

Dictionary to_save_data() ​

Save instance runtime state

void from_save_data( save_data: Dictionary ) ​

Load instance runtime state

void receive_shared_cooldown( duration: float ) ​

A member of one of the item's groups was used: this item is on cooldown for the shared time too (unless it is on a longer one)

void cleanup() ​

Clean up all resources used by this item instance