Item Helper Functions

You can access any of these functions from within an evaluable in an event with item_funcs.name_of_func(args)

app.engine.item_funcs.is_magic(unit: UnitObject, item: ItemObject, distance: int = 0) bool

Determines if an item is a magic item.

Parameters:
  • unit (UnitObject) – The unit attempting to use the item.

  • item (ItemObject) – The item to check.

  • distance (int, optional) – The distance at which the item is used. Defaults to 0.

Distance matters if the item is a magic_at_range type item, since it will only be magical while used at a range > 1.

Returns:

True if the item is a magic item, False otherwise.

Return type:

bool

app.engine.item_funcs.is_ranged(unit: UnitObject, item: ItemObject) bool

Determines if the item’s max range is greater than 1.

Parameters:
  • unit (UnitObject) – The unit attempting to use the item.

  • item (ItemObject) – The item to check.

Returns:

True if the item is ranged, False otherwise.

Return type:

bool

app.engine.item_funcs.is_heal(unit: UnitObject, item: ItemObject) bool

Determines if an item is a healing item.

Parameters:
  • unit (UnitObject) – The unit attempting to use the item.

  • item (ItemObject) – The item to check.

Returns:

True if the item is a healing item, False otherwise.

Return type:

bool

app.engine.item_funcs.available(unit: UnitObject, item: ItemObject) bool

Checks if an item can be used by the unit.

Parameters:
  • unit (UnitObject) – The unit attempting to use the item.

  • item (ItemObject) – The item to check.

Returns:

True if the item can be used, False otherwise.

Return type:

bool

app.engine.item_funcs.has_magic(unit: UnitObject) bool

Checks if the unit has any magic items.

Parameters:

unit (UnitObject) – The unit to check.

Returns:

True if the unit has any magic items, False otherwise.

Return type:

bool

app.engine.item_funcs.can_use(unit: UnitObject, item: ItemObject) bool

Checks if the unit can “use” a specific item, i.e., can the unit actually click Use in the item menu.

Parameters:
  • unit (UnitObject) – The unit attempting to use the item.

  • item (ItemObject) – The item to check.

Returns:

True if the unit can “use” the item, False otherwise.

Return type:

bool

app.engine.item_funcs.can_repair(unit: UnitObject, item: ItemObject) bool

Checks if the item can be repaired

Parameters:
  • unit (UnitObject) – The unit holding the item.

  • item (ItemObject) – The item to repair.

Returns:

True if the item can be repaired, False otherwise.

Return type:

bool

app.engine.item_funcs.has_repair(unit: UnitObject) bool

Checks if the unit has any items that can be repaired.

Parameters:

unit (UnitObject) – The unit to check.

Returns:

True if the unit has items that can be repaired, False otherwise.

Return type:

bool

app.engine.item_funcs.buy_price(unit: UnitObject, item: ItemObject) int

Calculates how much an item costs to buy from a shop for the unit.

Parameters:
  • unit (UnitObject) – The unit attempting to buy the item.

  • item (ItemObject) – The item to buy.

Returns:

The buy price of the item.

Return type:

int

app.engine.item_funcs.sell_price(unit: UnitObject, item: ItemObject) int

Calculates how much an item costs to sell to a shop for the unit.

Parameters:
  • unit (UnitObject) – The unit attempting to sell the item.

  • item (ItemObject) – The item to sell.

Returns:

The sell price of the item.

Return type:

int

app.engine.item_funcs.repair_price(unit: UnitObject, item: ItemObject) int

Calculates how much an item costs to repair for the unit.

Parameters:
  • unit (UnitObject) – The unit holding the item.

  • item (ItemObject) – The item to repair.

Returns:

The repair price of the item.

Return type:

int

app.engine.item_funcs.create_item(unit, item_nid, droppable: bool = False, parent: ItemObject = None, assign_ownership: bool = True) ItemObject

Creates an item and all of it’s subitems give the item’s nid If assign_ownership is True, informs the item which unit and which parent_item owns it. Sometimes set to False so that you can use an action like AddItemToMultiItem to set these properties instead.

app.engine.item_funcs.get_all_items(unit: UnitObject) List[ItemObject]

Retrieves all items possessed by a unit, including multi-items.

Parameters:

unit (UnitObject) – The unit whose items to retrieve.

Returns:

A list of all items possessed by the unit, including multi-items.

Return type:

List[ItemObject]

app.engine.item_funcs.get_all_items_with_multiitems(item_list: List[ItemObject]) List[ItemObject]

Retrieves all items and their subitems, including multi-items, from a list of items.

Parameters:

item_list (List[ItemObject]) – The list of items to process.

Returns:

A list of all items and their subitems, including multi-items.

Return type:

List[ItemObject]

app.engine.item_funcs.get_all_items_and_abilities(unit: UnitObject) List[ItemObject]

Retrieves all items and extra abilities possessed by a unit, including multi-items.

Parameters:

unit (UnitObject) – The unit whose items and abilities to retrieve.

Returns:

A list of all items and extra abilities possessed by the unit, including multi-items.

Return type:

List[ItemObject]

app.engine.item_funcs.is_weapon_recursive(unit: UnitObject, item: ItemObject) bool

Recursively checks if an item or any of its subitems is a weapon.

Parameters:
  • unit (UnitObject) – The unit holding the item.

  • item (ItemObject) – The item to check.

Returns:

True if the item or any of its subitems is a weapon, False otherwise.

Return type:

bool

app.engine.item_funcs.is_spell_recursive(unit: UnitObject, item: ItemObject) bool

Recursively checks if an item or any of its subitems is a spell.

Parameters:
  • unit (UnitObject) – The unit holding the item.

  • item (ItemObject) – The item to check.

Returns:

True if the item or any of its subitems is a spell, False otherwise.

Return type:

bool

app.engine.item_funcs.get_all_items_from_multi_item(unit: UnitObject, item: ItemObject) List[ItemObject]

Retrieves all items from a multi-item.

Parameters:
  • unit (UnitObject) – The unit to which the multi-item belongs.

  • item (ItemObject) – The multi-item to process.

Returns:

A list of all items contained within the multi-item.

Return type:

List[ItemObject]

app.engine.item_funcs.get_all_tradeable_items(unit: UnitObject) List[ItemObject]

Retrieves all tradeable items possessed by a unit. Locked items are not tradeable.

Parameters:

unit (UnitObject) – The unit whose tradeable items to retrieve.

Returns:

A list of all tradeable items possessed by the unit.

Return type:

List[ItemObject]

app.engine.item_funcs.get_num_items(unit: UnitObject) int

Retrieves the maximum number of non-accessories a unit can carry.

Parameters:

unit (UnitObject) – The unit to query.

Returns:

The maximum number of non-accessories the unit can carry.

Return type:

int

app.engine.item_funcs.get_num_accessories(unit: UnitObject) int

Retrieves the maximum number of accessories a unit can carry.

Parameters:

unit (UnitObject) – The unit to query.

Returns:

The maximum number of accessories the unit can carry.

Return type:

int

app.engine.item_funcs.too_much_in_inventory(unit: UnitObject) bool

Checks if a unit is carrying too many items.

Parameters:

unit (UnitObject) – The unit to check.

Returns:

True if the unit is carrying too many items, False otherwise.

Return type:

bool

app.engine.item_funcs.inventory_full(unit: UnitObject, item: ItemObject) bool

Checks if a unit’s inventory is full.

Parameters:
  • unit (UnitObject) – The unit to check.

  • item (ItemObject) – The item to potentially add to the unit’s inventory.

Returns:

True if the unit’s inventory is full, False otherwise.

Return type:

bool

app.engine.item_funcs.get_range(unit: UnitObject, item: ItemObject) Set[int]

Retrieves the range of an item for a unit.

Parameters:
  • unit (UnitObject) – The unit attempting to use the item.

  • item (ItemObject) – The item whose range to retrieve.

Returns:

A set containing the valid ranges of the item.

Return type:

Set[int]

app.engine.item_funcs.get_range_string(unit: UnitObject, item: ItemObject)

Retrieves the range of an item as a string.

Parameters:
  • unit (UnitObject) – The unit holding the item.

  • item (ItemObject) – The item whose range to retrieve.

Returns:

A string representation of the item’s range.

Return type:

str

app.engine.item_funcs.get_max_range(unit: UnitObject) int

Retrieves the maximum range of all available items for a unit.

Parameters:

unit (UnitObject) – The unit to query.

Returns:

The maximum range of all available items for the unit.

Return type:

int

app.engine.item_funcs.num_stacks(unit: UnitObject, skill_nid: NID) int

Calculates the number of stacks of a specific skill possessed by a unit.

Parameters:
  • unit (UnitObject) – The unit whose skills to count.

  • skill_nid (NID) – The NID of the skill to count.

Returns:

The number of stacks of the specified skill possessed by the unit.

Return type:

int

app.engine.item_funcs.can_be_used_in_base(unit: UnitObject, item: ItemObject) bool

Checks if an item can be used by a unit in the base/prep.

Parameters:
  • unit (UnitObject) – The unit attempting to use the item.

  • item (ItemObject) – The item to check.

Returns:

True if the item can be used by the unit in the base, False otherwise.

Return type:

bool