Class Item
Methods
item:init (itemID, tags, info, ignoreNewFunc) | Create an instance of the item. |
item:duplicate () | Duplicates an instance of the item. |
item:get_description (withName) | Get the description of the item. |
item:get_name (full, amount, withLevel, noProper) | Get the name of the item. |
item:target (target, user, skip, ignoreCooldowns) | Set the item as the thing currently being used to target (so it'll display as targeting in the game UI) |
item:use (target, user, ignoreCooldowns) | "Use" the item. |
item:get_damage (wielder) | Find out how much damage an item will deal. |
item:get_extra_damage (target, wielder, dmg) | Find out how much extra damage an item will deal due to enchantments |
item:attack (target, wielder, forceHit, ignore_callbacks, forceBasic) | Attack another entity. |
item:reload (possessor, ammo) | Reload an item. |
item:get_possible_ammo (possessor) | Get a list of items that can be used as ammo for this item |
item:matches (item) | Determines if another item is the same as this item |
item:qualifies_for_enchantment (enchantment, permanent) | Determine if an item qualifies for a particular enchantment |
item:get_possible_enchantments (permanent, artifactOnly, enchantment_type) | Get a list of all possible enchantments the item could have |
item:apply_enchantment (enchantment, turns) | Apply an enchantment to an item |
item:remove_enchantment (enchantment) | Remove an enchantment from an item |
item:decrease_all_enchantments (removal_type) | Decrease the amount of enchantment on an item |
item:get_enchantments () | Return a list of all enchantments currently applied to an item |
item:get_enchantment_string () | Return a list of all enchantments and their values in a string, for item ID purposes |
item:get_enchantment_bonus (bonusType, permanentOnly) | Returns the total value of the bonuses of a given type provided by enchantments. |
item:get_hit_conditions () | Check what hit conditions an item can inflict |
item:get_armor_piercing (wielder) | Checks the armor-piercing quality of a weapon. |
item:get_accuracy () | Returns the accuracy (modifier to the hit roll) of a weapon. |
item:get_ranged_accuracy () | Returns the ranged accuracy (modifier to the hit roll) of a weapon. |
item:get_ranged_damage () | Returns the ranged accuracy (modifier to the hit roll) of a weapon. |
item:get_critical_chance () | Checks the critical chance of a weapon. |
item:get_value () | Checks the value of an item |
item:get_threat () | Checks the threatvalue of an item |
item:get_threat_modifier () | Checks the threat_modifier value of an item |
item:has_tag (tag, ignore_enchantments) | Checks if an item has a descriptive tag. |
item:add_tag (tag) | Add a tag to an item |
item:add_tags (tags) | Add multiple tags to an item |
item:delete (map, amount) | Delete an item |
item:level_up () | Increase an item's level |
item:is_identified () | Checks whether an item is identified |
item:identify () | Mark an item as identified |
item:cleanup (map) | Perform an item's cleanup() callback, if applicable. |
item:is_ingredient_in (all) | Determines what recipes the item is an ingredient in: |
item:splitStack (amount) | Split off a new stack of an item |
item:get_spells_granted () | Returns a list of spells granted to the wearer of this equipment |
item:get_armor (damageType, noBonus, no_all) | Returns the value |
item:get_all_armor (noBonus) | Returns a list of armor granted to the wearer of this equipment |
item:get_buyer_list () | Returns a list of shops and factions that will buy an item |
item:get_highest_sell_cost () | Gets the highest cost of known stores/factions that will buy an item |
item:get_types (base_only) | Gets a list of all types a item is |
item:is_type (ctype, base_only) | Checks if an item is of a certain type |
item:callbacks (callback_type, Anything.) | Checks the callbacks of the base item type and any enchantments the item has |
item:get_potential_targets (user, previous_targets) | Gets potential targets of a item. |
item:update_charges (amt) | Changes the amount of charges that an item has |
item:get_study_results (studier) | Get the items and skills that you will receive from studying an item |
item:get_impressions () | Gets impressions provided when equipping an item. |
item:get_condition_type_immunities () | Gets condition type immunities provided when equipping an item. |
Methods
- item:init (itemID, tags, info, ignoreNewFunc)
-
Create an instance of the item. Don't call this directly. Called via Item('itemID')
Parameters:
- itemID String. The ID of the item.
- tags Table. A table of tags to pass to the item's new() function
- info Anything. Argument to pass into the item's new() function.
- ignoreNewFunc Boolean. Whether to ignore the item's new() function
Returns:
-
Item. The item itself.
- item:duplicate ()
-
Duplicates an instance of the item.
Returns:
-
Item. The item itself.
- item:get_description (withName)
-
Get the description of the item.
Parameters:
- withName Boolean. Whether to also include the name of the item.
Returns:
-
String. The description of the item.
- item:get_name (full, amount, withLevel, noProper)
-
Get the name of the item.
Parameters:
- full Boolean. If false, the item will be called "a dagger", if true, the item will be called "Dagger".
- amount Number. The number of items in question. (optional)
- withLevel Boolean. If true, show the item's level if it has one (optional)
- noProper Boolean. If true, don't show the proper name
Returns:
-
String. The name of the item
- item:target (target, user, skip, ignoreCooldowns)
-
Set the item as the thing currently being used to target (so it'll display as targeting in the game UI)
Parameters:
- target Entity. The target of the item
- user User. The owner and user of the item
- skip Boolean. Whether to skip item-specific targetting code and go straight to the generic (optional)
- ignoreCooldowns Boolean. If set to true, this will ignore whether or not the item is on a cooldown (optional)
- item:use (target, user, ignoreCooldowns)
-
"Use" the item. Calls the item's use() code.
Parameters:
- target Entity. The target of the item's use. Might be another creature, a tile, even the user itself.
- user Creature. The creature using the item.
- ignoreCooldowns Boolean. If set to true, this will ignore whether or not the item is on a cooldown (optional)
Returns:
-
Boolean. Whether the use was successful.
- item:get_damage (wielder)
-
Find out how much damage an item will deal. The item's damage value + the wielder's get_damage(), but might be overridden by an item's get_damage() code
Parameters:
- wielder Creature. The creature using the item.
Returns:
-
Number. The damage the item will deal.
- item:get_extra_damage (target, wielder, dmg)
-
Find out how much extra damage an item will deal due to enchantments
Parameters:
- target Entity. The target of the item's attack.
- wielder Creature. The creature using the item.
- dmg Number. The base damage being done to the target
Returns:
-
Table. A table with values of the extra damage the item will deal.
- item:attack (target, wielder, forceHit, ignore_callbacks, forceBasic)
-
Attack another entity.
Parameters:
- target Entity. The creature (or feature) they're attacking
- wielder Creature. The creature attacking with the item.
- forceHit Boolean. Whether to force the attack instead of rolling for it. (optional)
- ignore_callbacks Boolean. Whether to ignore any of the callbacks involved with attacking (optional)
- forceBasic Boolean. Whether to ignore the weapon's attacked_with and attack_hits code and just do a basic attack. (optional)
Returns:
-
Number. How much damage (if any) was done
- item:reload (possessor, ammo)
-
Reload an item.
Parameters:
- possessor Creature. The creature using the item.
- ammo Item. The item to use as ammo
Returns:
-
Boolean. Whether the reload was successful.
- item:get_possible_ammo (possessor)
-
Get a list of items that can be used as ammo for this item
Parameters:
- possessor Creature. The creature using the item.
Returns:
-
Table. A list of items that can be used for ammo.
- item:matches (item)
-
Determines if another item is the same as this item
Parameters:
- item Item. The item to check
Returns:
-
Boolean. Whether or not the items are the same
- item:qualifies_for_enchantment (enchantment, permanent)
-
Determine if an item qualifies for a particular enchantment
Parameters:
- enchantment Text. The enchantment ID
- permanent Boolean. Whether the enchantment has to qualify as a permanent enchantment (optional)
Returns:
-
Boolean. Whether or not the item qualifies for the enchantment
- item:get_possible_enchantments (permanent, artifactOnly, enchantment_type)
-
Get a list of all possible enchantments the item could have
Parameters:
- permanent Boolean. Whether the enchantment has to qualify as a permanent enchantment (optional)
- artifactOnly Boolean. Whether to only consider enchantments without the neverArtifact flag
- enchantment_type String. The enchantment type to look at (Optional)
Returns:
-
Table. A list of all enchantment IDs
- item:apply_enchantment (enchantment, turns)
-
Apply an enchantment to an item
Parameters:
- enchantment Text. The enchantment ID
- turns Number. The number of turns to apply the enchantment, if applicable. What "turns" refers to will vary by enchantment, and some are always permanent, and so this number will do nothing. Add a -1 to make force this enchantment to be permanent.
- item:remove_enchantment (enchantment)
-
Remove an enchantment from an item
Parameters:
- enchantment Text. The ID of the enchantment
- item:decrease_all_enchantments (removal_type)
-
Decrease the amount of enchantment on an item
Parameters:
- removal_type Text. The removal type of the enchantment
- item:get_enchantments ()
-
Return a list of all enchantments currently applied to an item
Returns:
-
Table. The list of enchantments
- item:get_enchantment_string ()
-
Return a list of all enchantments and their values in a string, for item ID purposes
Returns:
-
String
- item:get_enchantment_bonus (bonusType, permanentOnly)
-
Returns the total value of the bonuses of a given type provided by enchantments.
Parameters:
- bonusType Text. The bonus type to look at
- permanentOnly Boolean. If true, only look at permanent enchantments
Returns:
-
Number. The bonus
- item:get_hit_conditions ()
-
Check what hit conditions an item can inflict
Returns:
-
Table. The list of hit conditions
- item:get_armor_piercing (wielder)
-
Checks the armor-piercing quality of a weapon.
Parameters:
- wielder Creature. The creature wielding the weapon.
Returns:
-
Number. The armor piercing value.
- item:get_accuracy ()
-
Returns the accuracy (modifier to the hit roll) of a weapon.
Returns:
-
Number. The accuracy of the weapon.
- item:get_ranged_accuracy ()
-
Returns the ranged accuracy (modifier to the hit roll) of a weapon.
Returns:
-
Number. The accuracy of the weapon.
- item:get_ranged_damage ()
-
Returns the ranged accuracy (modifier to the hit roll) of a weapon.
Returns:
-
Number. The accuracy of the weapon.
- item:get_critical_chance ()
-
Checks the critical chance of a weapon.
Returns:
-
Number. The crit chance of the weapon.
- item:get_value ()
-
Checks the value of an item
Returns:
-
Number. The value of the item
- item:get_threat ()
-
Checks the threatvalue of an item
Returns:
-
Number. The value of the item
- item:get_threat_modifier ()
-
Checks the threat_modifier value of an item
Returns:
-
Number. The value of the item
- item:has_tag (tag, ignore_enchantments)
-
Checks if an item has a descriptive tag.
Parameters:
- tag String. The tag to check for
- ignore_enchantments Boolean. Whether to ignore looking at enchantments' tags.
Returns:
-
Boolean. Whether or not it has the tag.
- item:add_tag (tag)
-
Add a tag to an item
Parameters:
- tag String. The tag to add
- item:add_tags (tags)
-
Add multiple tags to an item
Parameters:
- tags Table. The tags to add
- item:delete (map, amount)
-
Delete an item
Parameters:
- map Map. The map to the delete the item off of (optional, defaults to current map)
- amount Number. The amount of the item to delete. If nil, delete it all
- item:level_up ()
- Increase an item's level
- item:is_identified ()
- Checks whether an item is identified
- item:identify ()
- Mark an item as identified
- item:cleanup (map)
-
Perform an item's cleanup() callback, if applicable.
Parameters:
- map Map. The map the item is on
- item:is_ingredient_in (all)
-
Determines what recipes the item is an ingredient in:
Parameters:
- all Boolean. If true, get all recipes, not just known recipes.
- item:splitStack (amount)
-
Split off a new stack of an item
Parameters:
- amount Number. The number in the new stack
Returns:
-
Item. The new item stack
- item:get_spells_granted ()
-
Returns a list of spells granted to the wearer of this equipment
Returns:
-
Table. A list of the spells
- item:get_armor (damageType, noBonus, no_all)
-
Returns the value
Parameters:
- damageType
- noBonus
- no_all
- item:get_all_armor (noBonus)
-
Returns a list of armor granted to the wearer of this equipment
Parameters:
- noBonus
Returns:
-
Table. A list of the armor values
- item:get_buyer_list ()
- Returns a list of shops and factions that will buy an item
- item:get_highest_sell_cost ()
- Gets the highest cost of known stores/factions that will buy an item
- item:get_types (base_only)
-
Gets a list of all types a item is
Parameters:
- base_only Boolean. If true, don't look at types applied by enchantments
Returns:
-
Table. A table of item types
- item:is_type (ctype, base_only)
-
Checks if an item is of a certain type
Parameters:
- ctype String. The item type to check for
- base_only Boolean. If true, don't look at types applied by enchantments
Returns:
-
Boolean. Whether or not the item is that type
- item:callbacks (callback_type, Anything.)
-
Checks the callbacks of the base item type and any enchantments the item has
Parameters:
- callback_type String. The callback type to check.
- Anything. Any info you want to pass to the callback. Each callback type is probably looking for something specific (optional)
Returns:
- Boolean. If any of the callbacks returned true or false.
- Table. Any other information that the callbacks might return.
- item:get_potential_targets (user, previous_targets)
-
Gets potential targets of a item. Uses the item's own get_potential_targets() function if it has one, or defaults to seen creatures if it doesn't and it's a creature-targeting item
Parameters:
- user Creature. The caster of the spell
- previous_targets Table. The already-targeted targets of the item, if applicable
Returns:
-
Table. A list of potential targets
- item:update_charges (amt)
-
Changes the amount of charges that an item has
Parameters:
- amt The amount to change the charges by
- item:get_study_results (studier)
-
Get the items and skills that you will receive from studying an item
Parameters:
- studier
- item:get_impressions ()
-
Gets impressions provided when equipping an item.
Returns:
-
Table. A list of impressions
- item:get_condition_type_immunities ()
-
Gets condition type immunities provided when equipping an item.
Returns:
-
Table. A list of impressions