Class Creature
Methods
creature:init (creatureType, level, tags, info, noTweak, ignorenewFunc) | Initiates a creature. |
creature:generate_inventory (source) | Generate items for a creature's inventory. |
creature:apply_class (classID) | Applies a class definition to a creature, granting it that class's starting reputation, spells, factions and items |
creature:get_name (full, force) | Get the name of a creature |
creature:get_pronoun (ptype) | Get the pronoun of a creature |
creature:get_max_hp () | Get the max HP of a creature *MAY WANT TO CHANGE FOR YOUR OWN GAME* |
creature:get_max_mp () | Get the max magic points of a creature |
creature:updateHP (amt, damage_type) | Change the HP of a creature |
creature:damage (amt, attacker, damage_type, armor_piercing, noSound, item, ignoreWeakness) | Damage a creature |
creature:calculate_damage_received (amt, damage_type, armor_piercing, ignoreWeakness) | Calculates the damage amount a creature would receive based on damage types, weaknesses, armor, etc |
creature:qualifies_for_condition (name) | Checks if a creature qualifies for a condition |
creature:give_condition (name, turns, applier, args, force, stack, silent) | Give a condition to a creature |
creature:cure_condition (condition, silent) | Cure a condition. |
creature:has_condition (condition) | Check if a creature has a condition |
creature:decrease_all_conditions (removal_type) | Decrease all conditions of a given type |
creature:callbacks (callback_type, Anything.) | Checks the callbacks of the base creature type, any conditions the creature might have, any items the creature has equipped, and any spells the creature might have. |
creature:get_description (noInfo) | Get the name and description of a creature, including information like its health info, friendliness to the player, etc. |
creature:get_info (noHealth) | Gets the extended description of a creature |
creature:get_health_text (full) | Get a description of a creature's health |
creature:get_bonus (bonusType, average) | Get the bonus of a certain type, looking at conditions and equipment. |
creature:get_bonuses_from_skill (skillID, skillVal) | Returns the total bonus from a skill |
creature:get_resistance (damageType, noBonus, base_only) | Check how much damage of a given damage type is reduced by a creature's resistances and bonuses |
creature:get_weakness (damageType, noBonus, base_only) | Check how much damage of a given damage type is increased by a creature's weaknesses and bonuses |
creature:get_total_resistance (damageType, noBonus, base_only) | Check the total damage modifier (resistance - weakness) for a damage type. |
creature:get_all_weaknesses (noBonus, base_only) | Gets a list of all damage type weaknesses a creature has |
creature:get_all_resistances (noBonus, base_only) | Gets a list of all damage type resistances a creature has |
creature:get_all_total_resistances (noBonus, base_only) | Gets a list of all damage type weaknesses a creature has |
creature:is_immune_to_damage_type (damageType) | Checks whether a creature has blanket immunity to a damage type |
creature:is_healed_by_damage_type (damageType) | Checks whether a creature is healed by a damage type |
creature:get_armor (damage_type, noBonus, equipSlot, no_all) | Returns the armor value for a given damage type |
creature:get_all_armor (noBonus, base_only) | Gets a list of all armor values a creature has |
creature:is_immune_to_condition_type (conditionType) | Checks whether a creature has immunity to a condition type |
creature:get_hit_conditions () | Check what hit conditions a creature can inflict |
creature:attack (target, forceHit, ignore_callbacks) | Attack another entity. |
creature:advance (skip_conditions) | This function is run every turn. |
creature:can_move_to (x, y, inMap, ignoreCache) | Check whether a creature can move to a given tile |
creature:moveTo (x, y, skip_callbacks, noTween) | Move a creature to a tile |
creature:forceMove (x, y) | Forcibly move a creature to a tile, no matter what. |
creature:touching (target) | Check if a creature is touching something else |
creature:die (killer, silent) | Kill a creature. |
creature:explode () | Make a creature explode. |
creature:remove (map) | Remove a creature from the map without killing it. |
creature:get_inventory (ignoreEquip) | Gets the list of items the creature has |
creature:get_used_inventory_space () | Gets the number of slots the creature has used in its inventory |
creature:get_free_inventory_space () | Gets the number of free inventory slots a creature has |
creature:get_inventory_space () | Gets the total inventory space the creature has *MAY WANT TO CHANGE FOR YOUR OWN GAME* |
creature:pickup (item, tileOnly, silent) | Have a creature pick up an item from a tile. |
creature:give_item (item, silent) | Transfer an item to a creature's inventory |
creature:drop_item (item, silent) | Have a creature drop an item on the tile they're on |
creature:drop_all_items (deathItems) | Have a creature drop all their items on the tile they're on |
creature:delete_item (item, amt, silent) | Remove an item from a creature's inventory |
creature:has_item (item, sortBy, enchantments, level) | Check if a creature has an instance of an item ID |
creature:has_specific_item (item) | Check if a creature has a specific item |
creature:is_equipped (item) | Check if a creature has a specific item equipped |
creature:get_equipped_in_slot (slot) | Get a list of all equipment a creature has equipped in an equipment slot |
creature:get_all_equipped () | Get a list of all equipment a creature has equipped |
creature:equip (item) | Equip an item |
creature:unequip (item) | Unequip an item |
creature:can_use_item (item, verb) | Determine if a creature can use this item or not |
creature:can_see_tile (x, y, forceRefresh) | Check if a creature can see a given tile |
creature:can_sense_creature (creat, skipSight) | Check if a creature can sense another, either through sight or spooky senses. |
creature:can_shoot_tile (x, y) | Check if you can draw a straight line between the creature and a tile. |
creature:is_enemy (target, dontSend) | Check if a creature is a potential enemy. |
creature:is_friend (target) | Check if a creature is a potential friend. |
creature:get_types (base_only) | Gets a list of all creature types a creature is |
creature:is_type (ctype, base_only) | Checks if a creature is of a certain type |
creature:is_enemy_type (target) | Determine if a creature is an enemy type of yours (this function ignores factions, but does look at your creature types' enemy types list) |
creature:is_friendly_type (target) | Determine if a creature is a friendly type of yours (this function ignores factions, but does look at your creature types' friendly types list) |
creature:is_ignore_type (target) | Determine if a creature is an ignored type of yours (this function ignores factions, but does look at your creature types' ignore types list) |
creature:is_faction_enemy (target) | Checks if a creature is an enemy of any of your factions |
creature:is_faction_member (fac) | Checks if the creature is a member of a certain faction |
creature:get_kill_favor () | Gets the favor you get for killing this creature. |
creature:get_kill_reputation () | Gets the reputation you get for killing this creature. |
creature:notice (creat, skip_callbacks, force) | Cause the creature to notice another creature |
creature:update_reputation (factionID, amount, display, reason, noEnemies) | Modifies the reputation of a creatue with a faction TODO: custom rep change callbacks |
creature:update_favor (factionID, amount, display, reason, track) | Modifies the favor of a creatue with a faction |
creature:does_notice (creat) | Checks if the creature has already noticed a creature. |
creature:can_notice (creat) | Checks if a creature is able to notice another, and sets them as noticed if yes |
creature:decrease_notice (seenCreats) | Decrease the "noticed" value for all creatures that this creature has noticed |
creature:forget (creat) | Forget that you saw a creature |
creature:become_hostile (creat, force., silent) | Become hostile to another creature |
creature:ignore (creat) | Add a creature to your ignore list |
creature:stop_ignoring (creat) | Remove a creature from your ignore list |
creature:get_seen_creatures () | Get a list of all creatures you can see |
creature:make_fear_map () | Make a fear map for the given creature |
creature:update (dt) | This function is run every tick and updates various things. |
creature:collide (target, dist) | Collide with another creature or object |
creature:refresh_image_name () | Placeholder. |
creature:get_speed () | Gets a creature's speed stat value, including bonuses |
creature:get_perception (self) | Gets a creature's perception stat value, including bonuses |
creature:get_threat () | Gets the threat level of a given creature |
creature:flyTo (target, result) | Makes a creature fly through the air to a target |
creature:become_thrall (master, skip_callbacks) | Become a thrall to another creature. |
creature:become_free (skip_callbacks) | Become free from your master |
creature:free_thralls () | Free all this creature's thralls |
creature:give_xp (xp) | Grant XP to a creature |
creature:get_level_up_cost () | How much XP do you need to level up? |
creature:level_up (force, ignore_callback) | Level Up, granting stat points (for players), or randomly increasing stats (for NPCs) |
creature:learn_random_spells () | Learns random spells based on spells this creature is capable of learning. |
creature:get_stat_increases_for_level (level) | Get a list of what the stat increase will be for a given level |
creature:get_skill_increases_for_level (level) | Get a list of what the skill increase will be for a given level |
creature:get_fear (self) | Find out how afraid the creature is |
creature:get_bravery () | Gets the creature's bravery stat value, including bonuses |
creature:get_aggression (self) | Gets the creature's aggression stat value, including bonuses |
creature:get_animation_time () | Gets the creature's animation_time stat value, including bonuses |
creature:get_notice_chance () | Gets the creature's notice chance value, including bonuses |
creature:get_stealth () | Gets the creature's stealth stat value, including bonuses |
creature:get_damage (damage_stats) | Gets the creature's damage value, including bonuses |
creature:get_melee_accuracy (damage_stats) | Gets the total of a creature's melee accuracy stats, including bonuses |
creature:get_ranged_damage (damage_stats) | Gets the creature's damage value, including bonuses |
creature:get_ranged_accuracy (damage_stats) | Gets the total of a creature's melee accuracy stats, including bonuses |
creature:get_dodging (damage_stats) | Gets the creature's dodge stat values, including bonuses |
creature:get_armor_piercing () | Gets the creature's armor piercing value, including bonuses |
creature:get_critical_chance () | Gets the creature's critical_chance stat value, including bonuses |
creature:get_pathType () | Gets the creature's pathType, set in the creature definition or in the |
creature:get_stat (stat, noBonus) | A generic function for getting a stat and its bonus. |
creature:get_skills (noBonus) | Returns a list of all the skills a creature has |
creature:get_upgradable_skills (sorted_by_stat) | Returns a list of all upgradable skills a creature has, and the points required |
creature:get_skill (stat, noBonus) | A generic function for getting a skill and its bonus |
creature:can_upgrade_skill (skill, ignore_cost) | Returns whether or not the creature has enough points to upgrade the skill |
creature:upgrade_skill (skillID, val, ignore_cost, ignore_multi) | Changes the skill value |
creature:get_skill_upgrade_cost (skillID., Table.) | Returns the cost to upgrade a skill by a given amount |
creature:get_extra_stat (stat, noBonus) | A generic function for getting an extra stat and its bonuses |
creature:get_extra_stat_max (stat, noBonus) | A generic function for getting the max for an extra stat, if applicable |
creature:set_extra_stat (stat, val) | Sets an extra stat to a value |
creature:update_extra_stat (stat, val) | Adds/subtracts a value to an extra stat |
creature:get_arcana (stat, noBonus) | Gets an arcana level, including its bonus |
creature:get_spells (noEquip) | Get all spells the creature has, including those granted by equipment |
creature:get_unmemorized_spells () | Gets a list of spells in spells_known but not in spells |
creature:has_spell (spellName, noEquip, included_unmemorized) | Checks if the creature possesses a certain spell |
creature:learn_spell (spellID, force) | Add a spell to a creature's spell list |
creature:unmemorize_spell (spell, force) | Remove a spell from a creature's spell "inventory" |
creature:memorize_spell (spell, force) | Add a spell to a creature's spell "inventory" |
creature:can_learn_spell (spellID) | Determine if a creature can learn this spell or not |
creature:get_free_spell_slots () | Gets the number of free spell slots a creature has |
creature:get_spell_slots () | Gets the number of total spell slots the creature has *MAY WANT TO CHANGE FOR YOUR OWN GAME* |
creature:get_purchasable_spells () | Gets a list of all the spells a creature can currently learn from its definition, class, or skills |
creature:get_purchasable_skills (skillType) | Gets a list of all the skills a creature can currently learn from its definition, class, or generally purchasable skills |
creature:get_melee_attacks () | Get all items equipped that can be used for melee attacks |
creature:get_ranged_attacks () | Get all ranged attacks the creature has, including those granted by equipment |
creature:has_ai_flag (spellName) | Checks if the creature possesses a certain AI flag |
creature:has_tag (tag) | Checks if an creature has a descriptive tag. |
creature:transform (newBody, info, modifiers) | Transform into another creature. |
creature:evolve (creature, info, include_items) | Permanently evolve into another creature. |
creature:get_all_possible_recipes (hide_uncraftable, recipe_types, stash) | Get all possible recipes the creature can craft |
creature:can_craft_recipe (recipeID, stash, amount, ignore_tools) | Check if it's possible to craft a recipe TODO: Forbidden tags on recipes |
creature:craft_recipe (recipeID, secondary_ingredients, stash, amount) | Craft a recipe |
creature:learn_recipe (recipeID) | Learn a recipe |
creature:refresh () | Restores HP, MP, spells, removes cooldowns and conditions |
creature:process_incident (incidentID, actor, target, args) | Registers an incident as having occured, to be processed by all other creatures who observe it |
creature:get_dialog (asker) | Returns the ID of the dialog most applicable to this creature at the moment |
Methods
- creature:init (creatureType, level, tags, info, noTweak, ignorenewFunc)
-
Initiates a creature. Don't call this explicitly, it's called when you create a new creature with Creature('creatureID').
Parameters:
- creatureType String. The ID of the creature you want to create.
- level Number. The level to set the creature to (optional)
- tags Table. A table of tags to pass to the creature's new() function
- info Anything. Passed to the new() function
- noTweak Boolean. If true, don't randomize certain values
- ignorenewFunc Boolean. Whether to ignore the new() function
Returns:
-
Creature. The creature itself.
- creature:generate_inventory (source)
-
Generate items for a creature's inventory. Usually called when the creature first spawns
Parameters:
- source Table. The source of potential item lists. Defaults to the creature itself, and will frequently be either a creature type or a faction, but can be any table containing a possible_inventory or possible_death_items table. (optional)
- creature:apply_class (classID)
-
Applies a class definition to a creature, granting it that class's starting reputation, spells, factions and items
Parameters:
- classID String. The ID of the class to apply
- creature:get_name (full, force)
-
Get the name of a creature
Parameters:
- full Boolean. Whether to display the creature name after the proper name (optional)
- force Boolean. If set to true, will force display the name, even if the player can't see it (otherwise, will show as "Something"). (optional)
Returns:
-
String. The creature's name
- creature:get_pronoun (ptype)
-
Get the pronoun of a creature
Parameters:
- ptype String. The pronoun type: n = nominative, p = possessive, o = objective
Returns:
-
String. The pronoun.
- creature:get_max_hp ()
-
Get the max HP of a creature *MAY WANT TO CHANGE FOR YOUR OWN GAME*
Returns:
-
Number. The max HP
- creature:get_max_mp ()
-
Get the max magic points of a creature
Returns:
-
Number. The max MP
- creature:updateHP (amt, damage_type)
-
Change the HP of a creature
Parameters:
- amt Number. Can be positive or negative.
- damage_type String. The ID of a damage type
- creature:damage (amt, attacker, damage_type, armor_piercing, noSound, item, ignoreWeakness)
-
Damage a creature
Parameters:
- amt Number. The damage to deal.
- attacker Entity. The source of the damage.
- damage_type String. The damage type of the attack. (optional)
- armor_piercing True/False, or Number. If set to true, it ignores all armor. If set to a number, ignores that much armor. (optional)
- noSound Boolean. If set to true, no damage type sound will be played. (optional)
- item Item. The weapon used to do the damage. (optional)
- ignoreWeakness Boolean. If true, don't apply weakness
Returns:
-
Number. The final damage done.
- creature:calculate_damage_received (amt, damage_type, armor_piercing, ignoreWeakness)
-
Calculates the damage amount a creature would receive based on damage types, weaknesses, armor, etc
Parameters:
- amt Number. The damage to deal.
- damage_type String. The damage type of the attack. (optional)
- armor_piercing True/False, or Number. If set to true, it ignores all armor. If set to a number, ignores that much armor. (optional)
- ignoreWeakness Boolean. If true, don't apply weakness (optional)
Returns:
-
Number. The final damage done.
- creature:qualifies_for_condition (name)
-
Checks if a creature qualifies for a condition
Parameters:
- name String. The ID of the condition.
Returns:
-
Boolean. Whether or not the creature qualifies
- creature:give_condition (name, turns, applier, args, force, stack, silent)
-
Give a condition to a creature
Parameters:
- name String. The ID of the condition.
- turns Number. How many turns the condition should last.
- applier Entity. Who applied the condition. (optional)
- args Anything. Arguments to pass to the condition's apply() code (optional)
- force Boolean. Whether to force-apply the condition. (optional)
- stack Boolean. If true, add the new turns to the current turns (if applicable). If false, sets the turns to turns passed
- silent Boolean. If true, don't pop up to show the condition was given
Returns:
-
Boolean. Whether the condition was applied
- creature:cure_condition (condition, silent)
-
Cure a condition.
Parameters:
- condition String. The ID of the condition to cure
- silent Boolean. If true, don't show a popup
- creature:has_condition (condition)
-
Check if a creature has a condition
Parameters:
- condition String. The ID of the condition to check
Returns:
-
Number or False. The number of turns left in the condition if it has it, or false if it doesn't
- creature:decrease_all_conditions (removal_type)
-
Decrease all conditions of a given type
Parameters:
- removal_type Text. The removal type of the condition (defaults to turns)
- creature:callbacks (callback_type, Anything.)
-
Checks the callbacks of the base creature type, any conditions the creature might have, any items the creature has equipped, and any spells the creature might have.
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.
- creature:get_description (noInfo)
-
Get the name and description of a creature, including information like its health info, friendliness to the player, etc.
Parameters:
- noInfo Boolean. If true, only show the description, not extra info.
Returns:
-
String. The description of the creature.
- creature:get_info (noHealth)
-
Gets the extended description of a creature
Parameters:
- noHealth Boolean. If true, don't display health text
- creature:get_health_text (full)
-
Get a description of a creature's health
Parameters:
- full Boolean. Whether to return a full sentence or just a short description (optional)
Returns:
-
String. The health text
- creature:get_bonus (bonusType, average)
-
Get the bonus of a certain type, looking at conditions and equipment.
Parameters:
- bonusType String. The type of bonus to check for. Usually a stat
- average Boolean. Whether or not to average the total bonus before returning it (optional)
Returns:
-
Number. The bonus.
- creature:get_bonuses_from_skill (skillID, skillVal)
-
Returns the total bonus from a skill
Parameters:
- skillID String. The ID of the skill
- skillVal Number. The level of the skill (optional, defaults to current level)
Returns:
-
Table. A table of values in the form bonus=amt
- creature:get_resistance (damageType, noBonus, base_only)
-
Check how much damage of a given damage type is reduced by a creature's resistances and bonuses
Parameters:
- damageType String. The damage type.
- noBonus Boolean. If true, don't add bonuses
- base_only Boolean. If true, don't look at creature types applied by conditions
Returns:
-
Number. The amount by which the damage is reduced
- creature:get_weakness (damageType, noBonus, base_only)
-
Check how much damage of a given damage type is increased by a creature's weaknesses and bonuses
Parameters:
- damageType String. The damage type.
- noBonus Boolean. If true, don't add bonuses
- base_only Boolean. If true, don't look at creature types applied by conditions
Returns:
-
Number. The amount by which the damage is increased
- creature:get_total_resistance (damageType, noBonus, base_only)
-
Check the total damage modifier (resistance - weakness) for a damage type. Capped to 75% reduction, or 100% increase
Parameters:
- damageType String. The damage type.
- noBonus Boolean. If true, don't add bonuses
- base_only Boolean. If true, don't look at creature types applied by conditions
Returns:
-
Number. The amount by which the damage is increased
- creature:get_all_weaknesses (noBonus, base_only)
-
Gets a list of all damage type weaknesses a creature has
Parameters:
- noBonus Boolean. If true, don't add bonuses
- base_only Boolean. If true, don't look at creature types applied by conditions
Returns:
-
Table. A table of damage types and the weakness value
- creature:get_all_resistances (noBonus, base_only)
-
Gets a list of all damage type resistances a creature has
Parameters:
- noBonus Boolean. If true, don't add bonuses
- base_only Boolean. If true, don't look at creature types applied by conditions
Returns:
-
Table. A table of damage types and the resistance value
- creature:get_all_total_resistances (noBonus, base_only)
-
Gets a list of all damage type weaknesses a creature has
Parameters:
- noBonus Boolean. If true, don't add bonuses
- base_only Boolean. If true, don't look at creature types applied by conditions
Returns:
-
Table. A table of damage types and the weakness value
- creature:is_immune_to_damage_type (damageType)
-
Checks whether a creature has blanket immunity to a damage type
Parameters:
- damageType String. The damage type.
Returns:
-
Boolean. Whether or not they have immunity to that damage type
- creature:is_healed_by_damage_type (damageType)
-
Checks whether a creature is healed by a damage type
Parameters:
- damageType String. The damage type.
Returns:
-
Boolean. Whether or not they are healed by that damage type
- creature:get_armor (damage_type, noBonus, equipSlot, no_all)
-
Returns the armor value for a given damage type
Parameters:
- damage_type String. The damage type. If blank, look only at "all" armor value
- noBonus Boolean. If true, don't apply bonuses
- equipSlot String. If set, only look at equipment from this equipment slot. If false, don't apply equipment armor at all
- no_all Boolean. If set, don't add "all" armor value
Returns:
-
Number. The armor value
- creature:get_all_armor (noBonus, base_only)
-
Gets a list of all armor values a creature has
Parameters:
- noBonus Boolean. If true, don't add bonuses
- base_only Boolean. If true, don't look at creature types applied by conditions
Returns:
-
Table. A table of damage types and the weakness value
- creature:is_immune_to_condition_type (conditionType)
-
Checks whether a creature has immunity to a condition type
Parameters:
- conditionType String. The condition type.
Returns:
-
Boolean. Whether or not they have immunity to that condition type
- creature:get_hit_conditions ()
-
Check what hit conditions a creature can inflict
Returns:
-
Table. The list of hit conditions
- creature:attack (target, forceHit, ignore_callbacks)
-
Attack another entity. If any weapons are equipped, this function will call their attack code instead.
Parameters:
- target Entity. The creature (or feature) they're attacking
- forceHit Boolean. Whether to force the attack instead of rolling for it.
- ignore_callbacks Boolean. Whether to ignore any of the callbacks involved with attacking
Returns:
-
Number or False. How much damage (if any) was done, false if attacking is impossible
- creature:advance (skip_conditions)
-
This function is run every turn. It handles advancing conditions, recharging attacks, and AI for NPCs
Parameters:
- skip_conditions Boolean. Whether to skip running the condition advance code (optional)
- creature:can_move_to (x, y, inMap, ignoreCache)
-
Check whether a creature can move to a given tile
Parameters:
- x Number. The x coordinate
- y Number. The y coordinate
- inMap Map. The map to check. Defaults to current map (optional)
- ignoreCache Boolean. If true, ignore the can_move_cache (optional)
Returns:
-
Boolean. Whether or not the creature can move to that tile
- creature:moveTo (x, y, skip_callbacks, noTween)
-
Move a creature to a tile
Parameters:
- x Number. The x coordinate
- y Number. The y coordinate
- skip_callbacks Boolean. Whether to skip any callbacks related to movement (optional)
- noTween Boolean. If true, move there instantly, no tweening animation (optional)
Returns:
-
Boolean. If the creature successfully moved
- creature:forceMove (x, y)
-
Forcibly move a creature to a tile, no matter what. Do not use this function unless you absolutely have to, it is terrible and goes against everything we stand for, and can lead to creatures being stuck in places they shouldn't be, multiple creatures in a tile, or other things that you generally don't want.
Parameters:
- x Number. The x coordinate
- y Number. The y coordinate
- creature:touching (target)
-
Check if a creature is touching something else
Parameters:
- target Entity. The entity to check (can be any table with an X and Y coordinate)
Returns:
-
Boolean. Whether they're touching
- creature:die (killer, silent)
-
Kill a creature.
Parameters:
- killer Entity. Whodunnit? By default, nothing actually passes in a killer, but it's here just in case
- silent Boolean. If true, don't output anything
- creature:explode ()
- Make a creature explode.
- creature:remove (map)
-
Remove a creature from the map without killing it. Called to clean up after the creature dies, but can also be called whenever to remove them for some other reason.
Parameters:
- map Map. The map to remove the creature from. Defaults to current map (optional)
- creature:get_inventory (ignoreEquip)
-
Gets the list of items the creature has
Parameters:
- ignoreEquip
Returns:
-
Table. The creature's inventory
- creature:get_used_inventory_space ()
-
Gets the number of slots the creature has used in its inventory
Returns:
-
Number. The number of slots the creature has used in its inventory
- creature:get_free_inventory_space ()
-
Gets the number of free inventory slots a creature has
Returns:
-
Number. The number of slots the creature has free in its inventory, or false if the creature has no inventory space set (which translates to infinite space)
- creature:get_inventory_space ()
- Gets the total inventory space the creature has *MAY WANT TO CHANGE FOR YOUR OWN GAME*
- creature:pickup (item, tileOnly, silent)
-
Have a creature pick up an item from a tile.
Parameters:
- item Item. The item to pick up
- tileOnly Boolean. Whether to only allow pickups from the tile the creature is standing on. If not set to TRUE, creatures can also pick up from adjacent tiles.
- silent Boolean. If true, don't say anything
- creature:give_item (item, silent)
-
Transfer an item to a creature's inventory
Parameters:
- item Item. The item to give.
- silent Boolean. If true, don't show a popup
- creature:drop_item (item, silent)
-
Have a creature drop an item on the tile they're on
Parameters:
- item Item. The item to drop
- silent Boolean. If true, don't display drop text
- creature:drop_all_items (deathItems)
-
Have a creature drop all their items on the tile they're on
Parameters:
- deathItems Boolean. Whether to also drop death items
- creature:delete_item (item, amt, silent)
-
Remove an item from a creature's inventory
Parameters:
- item Item. The item to remove
- amt Number. The amount of the item to remove, if the item is stackable. Defaults to 1.
- silent Boolean. If true, don't show the popup
- creature:has_item (item, sortBy, enchantments, level)
-
Check if a creature has an instance of an item ID
Parameters:
- item String. The item ID to check for
- sortBy Text. What the "sortBy" value you're checking is (optional)
- enchantments Table. The table of echantments to match (optional)
- level Number. The level of the item (optional)
Returns:
- either Boolean or Item. False, or the specific item they have in their inventory
- either nil or Number. The index of the item in the inventory
- either nil or Number. The amount of the item the creature has
- creature:has_specific_item (item)
-
Check if a creature has a specific item
Parameters:
- item Item. The item to check for
Returns:
- either Boolean or Item. False, or the specific item they have in their inventory
- either nil or Number. The index of the item in the inventory
- either nil or Number. The amount of the item the creature has
- creature:is_equipped (item)
-
Check if a creature has a specific item equipped
Parameters:
- item Item. The item to check for
Returns:
-
Boolean. Whether the item is equipped.
- creature:get_equipped_in_slot (slot)
-
Get a list of all equipment a creature has equipped in an equipment slot
Parameters:
- slot String. The equipment slot to check
Returns:
-
Table. A list of the equipment.
- creature:get_all_equipped ()
-
Get a list of all equipment a creature has equipped
Returns:
-
Table. A list of the equipment.
- creature:equip (item)
-
Equip an item
Parameters:
- item Item. The item to equip
Returns:
- Boolean. Whether or not the item was equipped.
- String. Text describing the equipping.
- creature:unequip (item)
-
Unequip an item
Parameters:
- item Item. The item to unequip
Returns:
- Boolean. Whether or not the item was successfully unequipped. The only reason this would be false would be if the item had an unequip callback, or if the creature didn't even have the item equipped in the first place.
- String. Text describing the unequipping.
- creature:can_use_item (item, verb)
-
Determine if a creature can use this item or not
Parameters:
- item Item. The item to check
- verb Text. The verb the item uses. Or "equip" if it's equipment we're looking at
Returns:
- Boolean. Whether or not it's equippable
- Text. Why you can't equip it, if applicable. Nil if it is equipable.
- creature:can_see_tile (x, y, forceRefresh)
-
Check if a creature can see a given tile
Parameters:
- x Number. The x-coordinate
- y Number. The y-coordinate
- forceRefresh Boolean. Whether to force actually calculating if a creature can see it, versus just looking at the stored values of player sight. Useful only when calling this for the player.
Returns:
-
Boolean. Whether or not they can see it.
- creature:can_sense_creature (creat, skipSight)
-
Check if a creature can sense another, either through sight or spooky senses.
Parameters:
- creat Creature. The creature to check.
- skipSight Boolean. Whether to skip running can_see_tile and just look at extra senses (optional)
Returns:
-
Boolean. If the target can be seen.
- creature:can_shoot_tile (x, y)
-
Check if you can draw a straight line between the creature and a tile.
Parameters:
- x Number. The x-coordinate
- y Number. The y-coordinate
Returns:
-
Boolean. Whether or not they can shoot it.
- creature:is_enemy (target, dontSend)
-
Check if a creature is a potential enemy. This is NOT to check if they're actually currently hostile.
Parameters:
- target Creature. The target to check
- dontSend Boolean. The dontSend argument here is used when is_enemy() is called for checking a master's enemies. In the weird (but possible) case where two creatures were masters of each other, this would result in an infinite loop. Don't use it yourself. (optional)
Returns:
-
Boolean. Whether or not they're enemies
- creature:is_friend (target)
-
Check if a creature is a potential friend. This is NOT to check if they're actually currently friendly.
Parameters:
- target Creature. The target to check.
Returns:
-
Boolean. Whether or not they're friends.
- creature:get_types (base_only)
-
Gets a list of all creature types a creature is
Parameters:
- base_only Boolean. If true, don't look at types applied by conditions
Returns:
-
Table. A table of creature types
- creature:is_type (ctype, base_only)
-
Checks if a creature is of a certain type
Parameters:
- ctype String. The creature type to check for
- base_only Boolean. If true, don't look at types applied by conditions
Returns:
-
Boolean. Whether or not the creature is that type
- creature:is_enemy_type (target)
-
Determine if a creature is an enemy type of yours (this function ignores factions, but does look at your creature types' enemy types list)
Parameters:
- target Creature. The creature to check
Returns:
-
Boolean. If they're an enemy type
- creature:is_friendly_type (target)
-
Determine if a creature is a friendly type of yours (this function ignores factions, but does look at your creature types' friendly types list)
Parameters:
- target Creature. The creature to check
Returns:
-
Boolean. If they're a friendly type
- creature:is_ignore_type (target)
-
Determine if a creature is an ignored type of yours (this function ignores factions, but does look at your creature types' ignore types list)
Parameters:
- target Creature. The creature to check
Returns:
-
Boolean. If they're a friendly type
- creature:is_faction_enemy (target)
-
Checks if a creature is an enemy of any of your factions
Parameters:
- target Creature. The creature to check
Returns:
-
Boolean. Whether or not the creature is an enemy of any of your factions
- creature:is_faction_member (fac)
-
Checks if the creature is a member of a certain faction
Parameters:
- fac String. The faction ID to check for
Returns:
-
Boolean. Whether or not the creature is a member of that faction
- creature:get_kill_favor ()
-
Gets the favor you get for killing this creature.
Returns:
-
Table. A table of factions, and the favor scores
- creature:get_kill_reputation ()
-
Gets the reputation you get for killing this creature.
Returns:
-
Table. A table of factions, and the reputation scores
- creature:notice (creat, skip_callbacks, force)
-
Cause the creature to notice another creature
Parameters:
- creat Creature. The target to notice.
- skip_callbacks Whether to force notice and skip the notices() callbacks (optional)
- force Whether to force notice, but still run the callbacks (optional)
Returns:
-
Boolean. Whether the creature successfully noticed the target
- creature:update_reputation (factionID, amount, display, reason, noEnemies)
-
Modifies the reputation of a creatue with a faction TODO: custom rep change callbacks
Parameters:
- factionID String. The faction ID
- amount Number. The amount to change the reputation by
- display Boolean. If true, display text noting the reputation change
- reason String. Display this text after
- noEnemies Boolean. if true, don't update enemy factions' reputation
- creature:update_favor (factionID, amount, display, reason, track)
-
Modifies the favor of a creatue with a faction
Parameters:
- factionID String. The faction ID
- amount Number. The amount to change the favor by
- display Boolean. If true, display text noting the favor change
- reason String. Display this text after
- track Boolean. If true, track this favor change for purposes of reputation increase
- creature:does_notice (creat)
-
Checks if the creature has already noticed a creature. If not, see if they notice them now.
Parameters:
- creat
Returns:
-
Boolean. Whether the creature has noticed the target.
- creature:can_notice (creat)
-
Checks if a creature is able to notice another, and sets them as noticed if yes
Parameters:
- creat Creature. The creature to try and notice
Returns:
-
Boolean. Whether the creature is able to notice the target
- creature:decrease_notice (seenCreats)
-
Decrease the "noticed" value for all creatures that this creature has noticed
Parameters:
- seenCreats Table. A table full of creatures currently seen, whose noticed value will not be decreased (optional)
- creature:forget (creat)
-
Forget that you saw a creature
Parameters:
- creat Creature. The creature to forget
- creature:become_hostile (creat, force., silent)
-
Become hostile to another creature
Parameters:
- creat Creature. The creature to become hostile towards
- force. Boolean. Whether to force hostility, even if the callbacks return false (optional)
- silent Boolean. Whether to become hostile without playing a sound or displaying text(optional)
Returns:
-
Boolean. Whether the creature became hostile to the target.
- creature:ignore (creat)
-
Add a creature to your ignore list
Parameters:
- creat Creature. The creature to ignore
- creature:stop_ignoring (creat)
-
Remove a creature from your ignore list
Parameters:
- creat Creature. The creature to stop ignoring
- creature:get_seen_creatures ()
-
Get a list of all creatures you can see
Returns:
-
Table. An array of the creatures.
- creature:make_fear_map ()
-
Make a fear map for the given creature
Returns:
-
Table. A fear map, with coordinates in t[x][y] format
- creature:update (dt)
-
This function is run every tick and updates various things. You probably shouldn't call it yourself
Parameters:
- dt Number. The number of seconds since the last time update() was run. Most likely less than 1.
- creature:collide (target, dist)
-
Collide with another creature or object
Parameters:
- target Entity or coordinates. The entity or coordinates collided with
- dist Number. The distance still remaining in the knockback prior to collision
- creature:refresh_image_name ()
-
Placeholder. Doesn't do anything.
Returns:
-
False.
- creature:get_speed ()
-
Gets a creature's speed stat value, including bonuses
Returns:
-
Number. The stat value
- creature:get_perception (self)
-
Gets a creature's perception stat value, including bonuses
Parameters:
- self Creature. The creature itself
Returns:
-
Number. The stat value
- creature:get_threat ()
- Gets the threat level of a given creature
- creature:flyTo (target, result)
-
Makes a creature fly through the air to a target
Parameters:
- target Table. A table containing at least an x and y index. Can be a creature, a feature, or just a table with nothing but x and y.
- result Spell. What spell to use after the zoom is done. A spell object itself, not the ID (optional)
- creature:become_thrall (master, skip_callbacks)
-
Become a thrall to another creature. If you already have a master, unset your previous master.
Parameters:
- master Creature. The creature to become a thrall to
- skip_callbacks Boolean. Whether to skip thrall callbacks (optional)
- creature:become_free (skip_callbacks)
-
Become free from your master
Parameters:
- skip_callbacks Boolean. Whether to skip freedom callbacks (optional)
- creature:free_thralls ()
- Free all this creature's thralls
- creature:give_xp (xp)
-
Grant XP to a creature
Parameters:
- xp Number. The amount of XP to give
- creature:get_level_up_cost ()
-
How much XP do you need to level up? *MAY WANT TO CHANGE FOR YOUR OWN GAME*
Returns:
-
Number. The XP required to level up
- creature:level_up (force, ignore_callback)
-
Level Up, granting stat points (for players), or randomly increasing stats (for NPCs)
Parameters:
- force Boolean. Whether or not to ignore XP costs
- ignore_callback Boolean. Whether to ignore level_up callbacks
- creature:learn_random_spells ()
- Learns random spells based on spells this creature is capable of learning. Used for NPCs
- creature:get_stat_increases_for_level (level)
-
Get a list of what the stat increase will be for a given level
Parameters:
- level Number. The level to look at the stat increases for
Returns:
-
Table. A list of stats and increases in the format {stat=1}
- creature:get_skill_increases_for_level (level)
-
Get a list of what the skill increase will be for a given level
Parameters:
- level Number. The level to look at the stat increases for
Returns:
-
Table. A list of stats and increases in the format {stat=1}
- creature:get_fear (self)
-
Find out how afraid the creature is
Parameters:
- self Creature. The creature itself
Returns:
-
Number. The fear value
- creature:get_bravery ()
-
Gets the creature's bravery stat value, including bonuses
Returns:
-
Number. The stat value
- creature:get_aggression (self)
-
Gets the creature's aggression stat value, including bonuses
Parameters:
- self Creature. The creature itself
Returns:
-
Number. The stat value
- creature:get_animation_time ()
-
Gets the creature's animation_time stat value, including bonuses
Returns:
-
Number. The stat value
- creature:get_notice_chance ()
-
Gets the creature's notice chance value, including bonuses
Returns:
-
Number. The stat value
- creature:get_stealth ()
-
Gets the creature's stealth stat value, including bonuses
Returns:
-
Number. The stat value
- creature:get_damage (damage_stats)
-
Gets the creature's damage value, including bonuses
Parameters:
- damage_stats Table. A table of stats and skills that increase damage in the format stat=amt_per_level
Returns:
-
Number. The damage value
- creature:get_melee_accuracy (damage_stats)
-
Gets the total of a creature's melee accuracy stats, including bonuses
Parameters:
- damage_stats Table. A table of stats and skills that increase damage in the format stat=amt_per_level
Returns:
-
Number. The damage value
- creature:get_ranged_damage (damage_stats)
-
Gets the creature's damage value, including bonuses
Parameters:
- damage_stats Table. A table of stats and skills that increase damage in the format stat=amt_per_level
Returns:
-
Number. The damage value
- creature:get_ranged_accuracy (damage_stats)
-
Gets the total of a creature's melee accuracy stats, including bonuses
Parameters:
- damage_stats Table. A table of stats and skills that increase damage in the format stat=amt_per_level
Returns:
-
Number. The damage value
- creature:get_dodging (damage_stats)
-
Gets the creature's dodge stat values, including bonuses
Parameters:
- damage_stats Table. A table of stats and skills that increase dodge in the format stat=amt_per_level
Returns:
-
Number. The damage value
- creature:get_armor_piercing ()
-
Gets the creature's armor piercing value, including bonuses
Returns:
-
Number. The damage value
- creature:get_critical_chance ()
-
Gets the creature's critical_chance stat value, including bonuses
Returns:
-
Number. The stat value
- creature:get_pathType ()
- Gets the creature's pathType, set in the creature definition or in the
- creature:get_stat (stat, noBonus)
-
A generic function for getting a stat and its bonus. Looks at base stats first, then extra_stats, then skills
Parameters:
- stat Text. The stat to get
- noBonus Boolean. If true, don't add the bonus to the stat
Returns:
-
Number. The stat value
- creature:get_skills (noBonus)
-
Returns a list of all the skills a creature has
Parameters:
- noBonus
Returns:
-
Table. A list of all skills in the format skillID=value
- creature:get_upgradable_skills (sorted_by_stat)
-
Returns a list of all upgradable skills a creature has, and the points required
Parameters:
- sorted_by_stat Boolean. If true, the table will return in the format {upgrade_stat1={skill1,skill2},upgradestat2={skill3,skill4}}. If false, it will just return a flat list of skills
Returns:
-
Table. A list of all skills in the format skillID=upgrade_stat
- creature:get_skill (stat, noBonus)
-
A generic function for getting a skill and its bonus
Parameters:
- stat Text. The skill to get
- noBonus Boolean. If true, don't add the bonus to the stat
Returns:
-
Number. The stat value
- creature:can_upgrade_skill (skill, ignore_cost)
-
Returns whether or not the creature has enough points to upgrade the skill
Parameters:
- skill Text. The ID of the skill
- ignore_cost Boolean. If true, just check non-cost requirements
Returns:
-
Boolean. Whether the skill is upgradable or not
- creature:upgrade_skill (skillID, val, ignore_cost, ignore_multi)
-
Changes the skill value
Parameters:
- skillID Text. The ID of the skill
- val Number. The amount to change the skill by, defaults to 1
- ignore_cost Boolean. If true, don't pay the cost of the upgrade
- ignore_multi Boolean. If true, ignore the increase_per_point value
- creature:get_skill_upgrade_cost (skillID., Table.)
-
Returns the cost to upgrade a skill by a given amount
Parameters:
- skillID. String. The skill ID to check
- Table. A table. Will potentially have two entries: points for skill points used, and items, a table of items with the format {item=itemID,sortBy="text",amount=1,displayName="text"}
- creature:get_extra_stat (stat, noBonus)
-
A generic function for getting an extra stat and its bonuses
Parameters:
- stat Text. The stat to get
- noBonus Boolean. If true, don't add the bonus to the stat
Returns:
-
Number. The stat value
- creature:get_extra_stat_max (stat, noBonus)
-
A generic function for getting the max for an extra stat, if applicable
Parameters:
- stat Text. The stat to get
- noBonus Boolean. If true, don't add the bonus to the stat
Returns:
-
Number. The stat value
- creature:set_extra_stat (stat, val)
-
Sets an extra stat to a value
Parameters:
- stat Text. The stat to set
- val Number. What to set the stat to
- creature:update_extra_stat (stat, val)
-
Adds/subtracts a value to an extra stat
Parameters:
- stat Text. The stat to set
- val Number. What to add to the stat
Returns:
-
Number. The stat value
- creature:get_arcana (stat, noBonus)
-
Gets an arcana level, including its bonus
Parameters:
- stat Text. The arcana value to get
- noBonus Boolean. If true, don't add the bonus to the stat
Returns:
-
Number. The arcana value
- creature:get_spells (noEquip)
-
Get all spells the creature has, including those granted by equipment
Parameters:
- noEquip Boolean. If true, ignore spells granted by equipment.
Returns:
-
Table. A list of the creature's spells
- creature:get_unmemorized_spells ()
-
Gets a list of spells in spells_known but not in spells
Returns:
-
Table. A list of creature's unmemorized spells
- creature:has_spell (spellName, noEquip, included_unmemorized)
-
Checks if the creature possesses a certain spell
Parameters:
- spellName String. The name of the spell
- noEquip Boolean. If true, ignore spells granted by equipment
- included_unmemorized Boolean. If true, also look in the spells_known table
Returns:
- Number or Boolean. Either the index of the spell in the caster's "spellbook," or false if they don't know it
- Spell or nil. The spell itself
- creature:learn_spell (spellID, force)
-
Add a spell to a creature's spell list
Parameters:
- spellID Text. The ID of the spell to learn
- force Boolean. Ignore spell requirements
- creature:unmemorize_spell (spell, force)
-
Remove a spell from a creature's spell "inventory"
Parameters:
- spell Spell. The spell to forget
- force Boolean. If true, remove the spell even if it's normally not supposed to be forgettable
- creature:memorize_spell (spell, force)
-
Add a spell to a creature's spell "inventory"
Parameters:
- spell Spell. The spell to memorize
- force Boolean. If true, add the spell even if it overfills the slots
- creature:can_learn_spell (spellID)
-
Determine if a creature can learn this spell or not
Parameters:
- spellID Text. The ID of the spell to check
Returns:
- Boolean. Whether or not it can be learned
- Text. The reason it can't be learned (or nil if it can)
- creature:get_free_spell_slots ()
-
Gets the number of free spell slots a creature has
Returns:
-
Number. The number of slots the creature has free in its spell list, or false if the creature has no inventory space set (which translates to infinite space)
- creature:get_spell_slots ()
- Gets the number of total spell slots the creature has *MAY WANT TO CHANGE FOR YOUR OWN GAME*
- creature:get_purchasable_spells ()
-
Gets a list of all the spells a creature can currently learn from its definition, class, or skills
Returns:
-
Table. A table of the spells available to purchase
- creature:get_purchasable_skills (skillType)
-
Gets a list of all the skills a creature can currently learn from its definition, class, or generally purchasable skills
Parameters:
- skillType String. Limit to a particular skill tpyre (optional)
Returns:
-
Table. A table of the skills available to purchase
- creature:get_melee_attacks ()
-
Get all items equipped that can be used for melee attacks
Returns:
-
Table. A list of items that can be used for melee attacks
- creature:get_ranged_attacks ()
-
Get all ranged attacks the creature has, including those granted by equipment
Returns:
-
Table. A list of the creature's ranged attacks
- creature:has_ai_flag (spellName)
-
Checks if the creature possesses a certain AI flag
Parameters:
- spellName String. The AI flag
Returns:
-
Boolean. Whether the creature has the AI flag
- creature:has_tag (tag)
-
Checks if an creature has a descriptive tag.
Parameters:
- tag String. The tag to check for
Returns:
-
Boolean. Whether or not it has the tag.
- creature:transform (newBody, info, modifiers)
-
Transform into another creature. This replaces the original creature with a somewhat modified version of the creature they turn into, but leaves the original self unmodified (which enables the possibility of transfomring back). Differentiated from Creature:evolve() which uses the original creature as the base and modifies it permanently.
Parameters:
- newBody Creature or String. The creature to transform into, or the creature ID if a string
- info Anything. Info to pass to the new() function of the new creature
- modifiers Table. Table containing possible modifiers: level=number (Level to spawn the new body at) tags=table (Table of tags to pass to the new creature) permanent=true (if true, don't save a reference to the old body as it will not be needed) include_spells=true (if true, move old body's spells over) include_skills=true (if true, move old body's skills over) active_undo=true (if true, give the undo transformation spell to the new body) no_hp_transfer=true (if true, don't make HP ratio transfer when transforming) no_inventory_transfer=true (if true, don't transfer inventory to the new body)
- creature:evolve (creature, info, include_items)
-
Permanently evolve into another creature. It uses the initial creature as a base, and changes it to keep the highest value of skills, stats, reputation, and favor. Factions membership, spells, reputation, and favor are combined, and AI-related stuff is overwritten. Generally will be a net positive. This is differentiated from Creature:transform(), which leaves the original creature intact but effectively creates a new body and moves some limited information over to it.
Parameters:
- creature Creature or string. The creature to transform into, or the creature ID if a string
- info Anything. Info to pass to the new() function of the new creature
- include_items Boolean. Whether or not to keep the items and equipment the new creature would normally spawn with
- creature:get_all_possible_recipes (hide_uncraftable, recipe_types, stash)
-
Get all possible recipes the creature can craft
Parameters:
- hide_uncraftable Boolean. If true, only show recipes that are currently craftable. If false or nil, show all known crafts even if they can't be crafted right now (optional)
- recipe_types String. Filter by recipe types (optional)
- stash Entity. An entity containing items to use in addition to the creature's own inventory
Returns:
-
Table. A table with the IDs of all craftable recipes
- creature:can_craft_recipe (recipeID, stash, amount, ignore_tools)
-
Check if it's possible to craft a recipe
TODO: Forbidden tags on recipes
Parameters:
- recipeID String. The ID of the recipe
- stash Entity. An entity containing items to use in addition to the creature's own inventory
- amount Number. The number of times to craft it
- ignore_tools Boolean. If true, ignore whether or not the creature has the right tools
Returns:
- Boolean. Whether or not the recipe can be crafted
- Text. A description of why you can't craft the recipe.
- creature:craft_recipe (recipeID, secondary_ingredients, stash, amount)
-
Craft a recipe
Parameters:
- recipeID Text. The ID of the recipe to craft
- secondary_ingredients Table. Secondary ingredients provided for the recipe based on the ingredient_properties
- stash Entity. An entity containing items to use in addition to the creature's own inventory
- amount Number. The number of times to craft it
Returns:
- Boolean. If the recipe was successfully created
- Text. The result text of the recipe
- creature:learn_recipe (recipeID)
-
Learn a recipe
Parameters:
- recipeID Text. The ID of the recipe to learn
- creature:refresh ()
- Restores HP, MP, spells, removes cooldowns and conditions
- creature:process_incident (incidentID, actor, target, args)
-
Registers an incident as having occured, to be processed by all other creatures who observe it
Parameters:
- incidentID String. The incident type
- actor Entity. The creature (or other entity) that caused the incident. Optional
- target Entity. The entity (or coordinates), that was the target of the incident. Optional
- args Table. Other information to use when processing this incident
- creature:get_dialog (asker)
-
Returns the ID of the dialog most applicable to this creature at the moment
Parameters:
- asker Creature. The creature speaking to this creature