Item
┗> Class
The Item class represents all types of item in Kristal.
Items are data files contained in scripts/data/items that should extend this class or one of its extensions (see below), and their filepath starting at this location becomes their id, unless an id for them is specified as the second argument to Class().
There are extensions of item that provide additional functionality when extended from: HealItem and TensionItem
Items that are Light World equipment should extend LightEquipItem instead of this class (it provides all of the same fields and functions as Item).
Items can be given to the player directly in the code through Inventory:addItem().
Methods
Item:addFlag(name: string, amount: number?)
Adds to the value of a numerical item-specific flag
Arguments:
| name: string | The name of the flag to change |
| amount: number? | The value to increment the flag by (defaults to |
Returns:
| new_value: number |
Item:applyHealBonus(current_heal: number, base_heal: number, healer: PartyMember)
(Override) Applies bonus healing to healing actions performed by a party member in battle
Arguments:
| current_heal: number | The current heal amount with other bonuses applied |
| base_heal: number | The original heal amount |
| healer: PartyMember | The character performing the heal |
Returns:
| new_heal: number | The new heal amount affected by this item |
Item:applyMoneyBonus(gold: number)
(Override) If the item grants bonus gold, it applies its bonus here
Arguments:
| gold: number | The current amount of victory gold |
Returns:
| new_gold: number | The amount of gold with the bonus applied |
Item:calculateBattleHeal(heal: number, base_heal: number, caster: PartyMember?, target: PartyMember?)
(Override) Takes in the heal amount of a spell or item used in battle, returning the new amount modified by this item.
This function is only called once per unique item id. It is recommended you make the effect scale with amount equipped, which can be checked via Game.checkPartyEquipped, PartyMember.checkArmor, or PartyMember.checkWeapon.
Arguments:
| heal: number | The current amount of healing done. |
| base_heal: number | The base amount of healing done before any bonuses. |
| caster: PartyMember? | The party member performing the heal, if applicable. |
| target: PartyMember? | The party member receiving the heal, if applicable. |
Returns:
| new_heal: number | The new amount of healing done in battle after applying this item's bonus. |
Item:calculateBattleHealPriority()
(Override) Returns the priority of this item when calculating battle heal bonuses.
Higher priority items are applied later, lower priority items are applied first, and items with the same priority are applied in an arbitrary order.
Recommended use is to use a negative priority for flat bonuses (e.g. + 100) and a positive priority for multiplicative bonuses (e.g. * 2).
By default, this is 0. Built-in DELTARUNE items will use decimal priorities between 0 and 1.
Returns:
| priority: number | The priority of this item when calculating battle heal bonuses. |
Item:calculateBattleMoney(money: number, base_money: number, num_equipped: number)
(Override) Takes in the current amount of money earned in battle, returning the new amount modified by this item.
This function is only called once per unique item id, and it is given the amount of that same item equipped.
Arguments:
| money: number | The current amount of money earned in battle. |
| base_money: number | The base amount of money before any bonuses. |
| num_equipped: number | The number of the same item id equipped by the party. |
Returns:
| new_money: number | The new amount of money earned in battle after applying this item's bonus. |
Item:calculateBattleMoneyPriority()
(Override) Returns the priority of this item when calculating battle money bonuses.
Higher priority items are applied later, lower priority items are applied first, and items with the same priority are applied in an arbitrary order.
Recommended use is to use a negative priority for flat bonuses (e.g. + 100) and a positive priority for multiplicative bonuses (e.g. * 2).
By default, this is 0. Built-in DELTARUNE items will use decimal priorities between 0 and 1.
Returns:
| priority: number | The priority of this item when calculating battle money bonuses. |
Item:calculateInvulnFrames(frames: number, base_frames: number, num_equipped: number)
(Override) Takes in the current amount of invulnerability frames, returning the new amount modified by this item.
This function is only called once per unique item id, and it is given the amount of that same item equipped.
Arguments:
| frames: number | The current amount of invulnerability frames. |
| base_frames: number | The base amount of invulnerability frames before any bonuses. |
| num_equipped: number | The number of the same item id equipped by the party. |
Returns:
| new_frames: number | The new amount of invulnerability frames after applying this item's bonus. |
Item:calculateInvulnFramesPriority()
(Override) Returns the priority of this item when calculating invulnerability frame bonuses.
Higher priority items are applied later, lower priority items are applied first, and items with the same priority are applied in an arbitrary order.
Recommended use is to use a negative priority for flat bonuses (e.g. + 100) and a positive priority for multiplicative bonuses (e.g. * 2).
By default, this is 0. Built-in DELTARUNE items will use decimal priorities between 0 and 1.
Returns:
| priority: number | The priority of this item when calculating invulnerability frame bonuses. |
Item:canEquip(character: PartyMember, slot_type: string, slot_index: number)
Gets whether a particular character can equip an item
Arguments:
| character: PartyMember | The character to check equippability for |
| slot_type: string | The type of equipment slot, either |
| slot_index: number | The index of the slot the item is being equipped to |
Returns:
| can_equip: boolean |
Item:convertToDark(inventory: DarkInventory?)
(Override) Converts this item into its dark counterpart, if it has one
Arguments:
| inventory: DarkInventory? | A type of inventory used to store items in the Dark World. |
Returns:
| result: boolean|Item |
|
Item:convertToDarkEquip(chara: PartyMember)
(Override) Converts an equipped item to its dark counterpart
Arguments:
| chara: PartyMember | The PartyMember class is a type of data class that stores information about a member of the party. |
Returns:
| 1: (string|Item)? |
Item:convertToLight(inventory: LightInventory?)
(Override) Converts this item into its light counterpart, if it has one
Arguments:
| inventory: LightInventory? | A type of inventory used to store items in the Light World. |
Returns:
| result: boolean|Item |
|
Item:convertToLightEquip(chara: PartyMember)
(Override) Converts an equipped item to its light counterpart
Arguments:
| chara: PartyMember | The PartyMember class is a type of data class that stores information about a member of the party. |
Returns:
| 1: (string|Item)? |
Item:createResultItem()
(Override) Creates an instance of this Item's specified result_item
Returns:
| result_item: Item |
Item:getAttackCritBoxSize(battler: PartyBattler)
(Override) Gets the size of the critical hit box for the battler this weapon is equipped to. Only affects weapons.
The size is both visual and equivalent to the frame leniency of the attack (at 30fps). The default is 1, meaning you only have 1 frame to crit.
Arguments:
| battler: PartyBattler | The attacker's battler. |
Returns:
| size: number | The size of the critical hit box. |
Item:getAttackPitch(battler: any, enemy: any, points: any)
Arguments:
| battler: any | |
| enemy: any | |
| points: any |
Item:getAttackSound(battler: any, enemy: any, points: any)
Arguments:
| battler: any | |
| enemy: any | |
| points: any |
Item:getAttackSprite(battler: any, enemy: any, points: any)
Arguments:
| battler: any | |
| enemy: any | |
| points: any |
Item:getBattleText(user: PartyBattler, target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[])
(Override) Gets the text displayed when the item is used in battle
Arguments:
| user: PartyBattler |
|
| target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[] |
|
Returns:
| 1: string |
Item:getFlag(name: string, default: integer?)
Gets the value of an item-specific flag
Arguments:
| name: string | The name of the flag to get the value from |
| default: integer? | An optional default value to return if the flag is |
Returns:
| 1: integer |
Item:getReaction(user_id: string, reactor_id: string)
Gets the reaction for using or equipping an item for a specific user and reactor
Arguments:
| user_id: string | The id of the character using/equipping the item |
| reactor_id: string | The id of the character to get a reaction for |
Returns:
| reaction: string? |
Item:getStatBonus(stat: string)
Gets the stat bonus an item has for a specific stat
Arguments:
| stat: string |
Returns:
| bonus: number |
Item:isEquippedBy(character: PartyMember)
Gets whether this item instance is equipped by the specified party member
Arguments:
| character: PartyMember | The character to check the equipment of |
Returns:
| equipped: boolean |
Item:load(data: table)
Unpacks a table of Item save data into fields on the class
Arguments:
| data: table |
Item:onAttackHit(battler: PartyBattler, enemy: EnemyBattler, damage: number)
(Override) Called after an attack from a party member with this item equipped hits an enemy
Arguments:
| battler: PartyBattler | The attacking character |
| enemy: EnemyBattler | The enemy hit by the attack |
| damage: number | The attack's final damage (can be 0) |
Item:onBattleDamage(amount: number, swoon: boolean, all: boolean)
(Override) Called before a PartyBattler takes damage
Arguments:
| amount: number | The damage of the incoming hit |
| swoon: boolean | Whether the damage will swoon the battler instead of downing them |
| all: boolean | Whether the damage being taken comes from a strike targeting the whole party |
Returns:
| New: number? | damage amount |
Item:onBattleDeselect(user: PartyBattler, target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[])
(Override) Called when the item use is undone in the menu
Arguments:
| user: PartyBattler |
|
| target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[] |
|
Item:onBattleSelect(user: PartyBattler, target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[])
(Override) Called when the item is selected for use in battle
Arguments:
| user: PartyBattler |
|
| target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[] |
|
Item:onBattleUpdate(battler: PartyBattler)
(Override) Called every frame in batle when this item is equipped
Arguments:
| battler: PartyBattler | The equipping character |
Item:onBattleUse(user: PartyBattler, target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[])
(Override) Called when the item is used in battle
Arguments:
| user: PartyBattler |
|
| target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[] |
|
Item:onCheck()
(Override) Called when the item is checked
*By default, responisble for displaying the check message
Item:onEquip(character: PartyMember, replacement: Item?)
(Override) Called when the player tries to equip this item on a character
If the function returns false, the item will not be equipped
Arguments:
| character: PartyMember | The party member equipping the item |
| replacement: Item? | The item currently in the slot, if one is present |
Returns:
| equipped: boolean |
Item:onMenuClose(menu: DarkMenu)
(Override) Called when the menu containing this item is closed (only in Dark World)
Arguments:
| menu: DarkMenu |
Item:onMenuDraw(menu: DarkMenu)
(Override) Called whenever the menu draws when it is open to the storage containing this item (only in Dark World)
Arguments:
| menu: DarkMenu |
Item:onMenuOpen(menu: DarkMenu)
(Override) Called when the menu containing this item is opened (only in Dark World)
Arguments:
| menu: DarkMenu |
Item:onMenuUpdate(menu: DarkMenu)
(Override) Called whenever the menu updates when it is open to the storage containing this item (only in Dark World)
Arguments:
| menu: DarkMenu |
Item:onToss()
(Override) Called when the item is tossed
By default, responsible for displaying a random toss message when in the Light World
Returns:
| success: boolean | Whether the item was successfully tossed - return |
Item:onUnequip(character: any, replacement: any)
Arguments:
| character: any | |
| replacement: any |
Returns:
| 1: boolean |
Item:onWorldDamage(amount: number)
(Override) Called before a Character takes damage from a world bullet
Arguments:
| amount: number | The damage of the incoming hit |
Returns:
| New: number? | damage amount |
Item:onWorldUpdate(chara: Character)
(Override) Called every frame in the overworld when this item is equipped
Arguments:
| chara: Character | The equipping character |
Item:onWorldUse(target: PartyMember|PartyMember[])
(Override) Called when the item is used in the overworld
Arguments:
| target: PartyMember|PartyMember[] | The PartyMember class is a type of data class that stores information about a member of the party. |
Item:setFlag(name: string, value: any)
Sets the value of an item-specific flag
Arguments:
| name: string | The name of the flag to set |
| value: any | The value to set the flag to |
Fields
Item.dark_item: (string|Item)?
Item.light_item: (string|Item)?
The Item class represents all types of item in Kristal.
Items are data files contained in scripts/data/items that should extend this class or one of its extensions (see below), and their filepath starting at this location becomes their id, unless an id for them is specified as the second argument to Class().
There are extensions of item that provide additional functionality when extended from: HealItem and TensionItem
Items that are Light World equipment should extend LightEquipItem instead of this class (it provides all of the same fields and functions as Item).
Items can be given to the player directly in the code through Inventory:addItem().