Angband
|
Object utilities. More...
#include "angband.h"
#include "cave.h"
#include "cmd-core.h"
#include "effects.h"
#include "game-input.h"
#include "game-world.h"
#include "generate.h"
#include "grafmode.h"
#include "init.h"
#include "mon-make.h"
#include "monster.h"
#include "obj-curse.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-ignore.h"
#include "obj-knowledge.h"
#include "obj-make.h"
#include "obj-pile.h"
#include "obj-slays.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-history.h"
#include "player-spell.h"
#include "player-util.h"
#include "randname.h"
#include "z-queue.h"
Enumerations | |
enum | msg_tag_t { MSG_TAG_NONE, MSG_TAG_NAME, MSG_TAG_KIND, MSG_TAG_VERB, MSG_TAG_VERB_IS } |
Functions | |
static void | flavor_assign_fixed (void) |
static void | flavor_assign_random (byte tval) |
void | flavor_reset_fixed (void) |
Reset svals on flavors, effectively removing any fixed flavors. More... | |
void | flavor_init (void) |
Prepare the "variable" part of the "k_info" array. More... | |
void | flavor_set_all_aware (void) |
Set all flavors as aware. More... | |
void | object_flags (const struct object *obj, bitflag flags[OF_SIZE]) |
Obtain the flags for an item. More... | |
void | object_flags_known (const struct object *obj, bitflag flags[OF_SIZE]) |
Obtain the flags for an item which are known to the player. More... | |
bool | object_test (item_tester tester, const struct object *obj) |
Apply a tester function, skipping all non-objects and gold. More... | |
bool | is_unknown (const struct object *obj) |
Return true if the item is unknown (has yet to be seen by the player). More... | |
unsigned | check_for_inscrip (const struct object *obj, const char *inscrip) |
Looks if "inscrip" is present on the given object. More... | |
struct object_kind * | lookup_kind (int tval, int sval) |
Return the object kind with the given tval and sval , or NULL. More... | |
struct object_kind * | objkind_byid (int kidx) |
struct artifact * | lookup_artifact_name (const char *name) |
Return the a_idx of the artifact with the given name. More... | |
struct ego_item * | lookup_ego_item (const char *name, int tval, int sval) |
int | lookup_sval (int tval, const char *name) |
Return the numeric sval of the object kind with the given tval and name name . More... | |
void | object_short_name (char *buf, size_t max, const char *name) |
static int | compare_types (const struct object *o1, const struct object *o2) |
Sort comparator for objects using only tval and sval. More... | |
int | compare_items (const struct object *o1, const struct object *o2) |
Sort comparator for objects -1 if o1 should be first 1 if o2 should be first 0 if it doesn't matter. More... | |
bool | obj_has_charges (const struct object *obj) |
Determine if an object has charges. More... | |
bool | obj_can_zap (const struct object *obj) |
Determine if an object is zappable. More... | |
bool | obj_is_activatable (const struct object *obj) |
Determine if an object is activatable. More... | |
bool | obj_can_activate (const struct object *obj) |
Determine if an object can be activated now. More... | |
bool | obj_can_refill (const struct object *obj) |
Check if an object can be used to refuel other objects. More... | |
bool | obj_kind_can_browse (const struct object_kind *kind) |
bool | obj_can_browse (const struct object *obj) |
bool | obj_can_cast_from (const struct object *obj) |
bool | obj_can_study (const struct object *obj) |
bool | obj_can_takeoff (const struct object *obj) |
bool | obj_can_wear (const struct object *obj) |
bool | obj_can_fire (const struct object *obj) |
bool | obj_has_inscrip (const struct object *obj) |
bool | obj_has_flag (const struct object *obj, int flag) |
bool | obj_is_useable (const struct object *obj) |
struct effect * | object_effect (const struct object *obj) |
Return an object's effect. More... | |
bool | obj_needs_aim (struct object *obj) |
Does the given object need to be aimed? More... | |
bool | obj_can_fail (const struct object *o) |
Can the object fail if used? More... | |
int | get_use_device_chance (const struct object *obj) |
Returns the number of times in 1000 that @ will FAIL. More... | |
void | distribute_charges (struct object *source, struct object *dest, int amt) |
Distribute charges of rods, staves, or wands. More... | |
int | number_charging (const struct object *obj) |
Number of items (usually rods) charging. More... | |
bool | recharge_timeout (struct object *obj) |
Allow a stack of charging objects to charge by one unit per charging object Return true if something recharged. More... | |
bool | verify_object (const char *prompt, struct object *obj) |
Verify the choice of an item. More... | |
static msg_tag_t | msg_tag_lookup (const char *tag) |
void | print_custom_message (struct object *obj, const char *string, int msg_type) |
Print a message from a string, customised to include details about an object. More... | |
Variables | |
struct object_base * | kb_info |
struct object_kind * | k_info |
struct artifact * | a_info |
The artifact arrays. More... | |
struct ego_item * | e_info |
struct flavor * | flavors |
static char | scroll_adj [MAX_TITLES][18] |
Hold the titles of scrolls, 6 to 14 characters each, plus quotes. More... | |
Object utilities.
Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
This work is free software; you can redistribute it and/or modify it under the terms of either:
a) the GNU General Public License as published by the Free Software Foundation, version 2, or
b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.
enum msg_tag_t |
Looks if "inscrip" is present on the given object.
References i, object::note, and quark_str().
Referenced by auto_pickup_okay(), do_cmd_wield(), get_item_allow(), ignore_drop(), key_confirm_command(), and object_is_ignored().
Sort comparator for objects -1 if o1 should be first 1 if o2 should be first 0 if it doesn't matter.
The sort order is designed with the "list items" command in mind.
References compare_types(), object_kind::cost, is_unknown(), object::kind, object_flavor_is_aware(), and object_is_known_artifact().
Referenced by object_list_standard_compare().
Sort comparator for objects using only tval and sval.
-1 if o1 should be first 1 if o2 should be first 0 if it doesn't matter
References CMP, object::sval, and object::tval.
Referenced by compare_items().
Distribute charges of rods, staves, or wands.
source | is the source item |
dest | is the target item, must be of the same type as source |
amt | is the number of items that are transfered |
References AVERAGE, object::number, object::pval, randcalc(), object::time, object::timeout, tval_can_have_charges(), and tval_can_have_timeout().
Referenced by do_cmd_retrieve(), and object_split().
References object_kind::flavor, i, angband_constants::k_max, flavor::next, SV_UNKNOWN, object_kind::sval, flavor::sval, object_kind::tval, flavor::tval, and z_info.
Referenced by flavor_init().
References object_kind::flavor, i, angband_constants::k_max, flavor::next, quit_fmt(), randint0, scroll_adj, SV_UNKNOWN, object_kind::sval, flavor::sval, flavor::text, flavor::tval, and z_info.
Referenced by flavor_init().
Prepare the "variable" part of the "k_info" array.
The "color"/"metal"/"type" of an item is its "flavor". For the most part, flavors are assigned randomly each game.
Initialize descriptions for the "colored" objects, including: Rings, Amulets, Staffs, Wands, Rods, Mushrooms, Potions, Scrolls.
Scroll titles are always between 6 and 14 letters long. This is ensured because every title is composed of whole words, where every word is from 2 to 8 letters long, and that no scroll is finished until it attempts to grow beyond 15 letters. The first time this can happen is when the current title has 6 letters and the new word has 8 letters, which would result in a 6 letter scroll title.
Hack – make sure everything stays the same for each saved game This is accomplished by the use of a saved "random seed", as in "town_gen()". Since no other functions are called while the special seed is in effect, so this function is pretty "safe".
References object_kind::aware, buf, cleanup_parser(), object_kind::flavor, flavor_assign_fixed(), flavor_assign_random(), flavor_parser, flavor_reset_fixed(), i, angband_constants::k_max, MAX_TITLES, my_strcpy(), object_kind::name, name_sections, flavor::next, OPT, Rand_quick, Rand_value, randname_make(), RANDNAME_SCROLL, run_parser(), scroll_adj, seed_flavor, streq, SV_UNKNOWN, flavor::sval, turn, and z_info.
Referenced by do_cmd_accept_character(), and rd_misc().
Reset svals on flavors, effectively removing any fixed flavors.
Mainly useful for randarts so that fixed flavors for standards aren't predictable. The One Ring is kept as fixed, since it lives through randarts.
References flavor::next, SV_UNKNOWN, flavor::sval, flavor::text, and flavor::tval.
Referenced by flavor_init().
Set all flavors as aware.
References object_kind::aware, object_kind::flavor, i, angband_constants::k_max, object_kind::name, and z_info.
Referenced by do_cmd_accept_character().
Returns the number of times in 1000 that @ will FAIL.
References object::artifact, object::kind, object_kind::level, artifact::level, SKILL_DEVICE, player_state::skills, and player::state.
Referenced by check_devices(), obj_known_effect(), and show_obj().
Return true if the item is unknown (has yet to be seen by the player).
References object::grid, LIGHTING_LOS, grid_data::m_idx, map_info(), and grid_data::unseen_object.
Referenced by compare_items(), object_list_entry_line_attribute(), object_list_format_section(), object_list_should_ignore_object(), and scan_floor().
Return the a_idx of the artifact with the given name.
References angband_constants::a_max, i, my_stristr(), artifact::name, streq, and z_info.
Referenced by rd_history(), rd_item(), and wiz_tweak_item().
name | ego type name |
tval | object tval |
sval | object sval |
References angband_constants::e_max, i, object_kind::kidx, poss_item::kidx, lookup_kind(), ego_item::name, poss_item::next, ego_item::poss_items, streq, and z_info.
Referenced by rd_item(), and wiz_tweak_item().
struct object_kind* lookup_kind | ( | int | tval, |
int | sval | ||
) |
Return the object kind with the given tval
and sval
, or NULL.
References angband_constants::k_max, msg, object_kind::sval, object_kind::tval, tval_find_name(), and z_info.
Referenced by add_ability_aux(), artifact_set_data_free(), collect_artifact_data(), copy_artifact_data(), count_abilities(), count_bow_abilities(), count_nonweapon_abilities(), count_weapon_abilities(), design_artifact(), finish_parse_artifact(), get_art_name(), get_base_item(), init_money_svals(), lookup_ego_item(), make_artifact(), make_artifact_special(), make_fake_artifact(), mon_create_drop(), money_kind(), obj_kind_can_browse(), parse_always(), parse_artifact_act(), parse_artifact_graphics(), parse_artifact_info(), parse_artifact_time(), parse_class_book_graphics(), parse_class_book_properties(), parse_ego_item(), parse_lore_drop(), parse_lore_mimic(), parse_monster_drop(), parse_monster_mimic(), parse_normal(), parse_object_power_item(), parse_prefs_inscribe(), parse_prefs_object(), player_outfit(), player_pickup_gold(), rd_ignore(), rd_item(), store_base_power(), wiz_create_item_object_from_artifact(), wiz_test_kind(), and wr_item().
Return the numeric sval of the object kind with the given tval
and name name
.
References angband_constants::k_max, my_stricmp(), object_kind::name, obj_desc_name_format(), object_kind::sval, object_kind::tval, and z_info.
Referenced by apply_magic(), finish_parse_artifact(), object_list_format_name(), object_sense(), parse_always(), parse_artifact_base_object(), parse_class_equip(), parse_ego_item(), parse_flavor_flavor(), parse_lore_drop(), parse_lore_mimic(), parse_monster_drop(), parse_monster_mimic(), parse_normal(), parse_object_power_item(), parse_prefs_inscribe(), parse_prefs_object(), rd_ignore(), rd_item(), and write_curse_kinds().
References MSG_TAG_KIND, MSG_TAG_NAME, MSG_TAG_NONE, MSG_TAG_VERB, and MSG_TAG_VERB_IS.
Referenced by print_custom_message().
Number of items (usually rods) charging.
References AVERAGE, object::number, randcalc(), object::time, and object::timeout.
Referenced by obj_can_zap(), obj_desc_charges(), recharge_objects(), and recharge_timeout().
Determine if an object can be activated now.
References obj_is_activatable(), and object::timeout.
Referenced by context_menu_object(), and do_cmd_activate().
References object::kind, and obj_kind_can_browse().
Referenced by context_menu_object(), describe_book(), earlier_object(), obj_can_cast_from(), obj_can_study(), store_examine(), and textui_spell_browse().
References obj_can_browse(), spell_book_count_spells(), and spell_okay_to_cast().
Referenced by context_menu_object(), and do_cmd_cast().
Can the object fail if used?
References tval_can_have_failure(), and wield_slot().
Referenced by show_obj().
References player_state::ammo_tval, player::state, and object::tval.
Referenced by context_menu_object(), and do_cmd_fire().
Check if an object can be used to refuel other objects.
References equipped_item_by_slot_name(), object::flags, of_has, object::timeout, tval_is_fuel(), and tval_is_light().
Referenced by context_menu_object(), do_cmd_refill(), do_cmd_use(), and test_obj_can_refill().
References obj_can_browse(), spell_book_count_spells(), and spell_okay_to_study().
Referenced by context_menu_object(), do_cmd_study_book(), do_cmd_study_spell(), and player_book_has_unlearned_spells().
References obj_has_flag().
Referenced by context_menu_object(), do_cmd_drop(), do_cmd_sell(), do_cmd_stash(), do_cmd_takeoff(), do_cmd_wield(), and store_sell().
References wield_slot().
Referenced by context_menu_object(), describe_origin(), and do_cmd_wield().
Determine if an object is zappable.
References object::number, number_charging(), and tval_can_have_timeout().
Referenced by context_menu_object(), and do_cmd_zap_rod().
Determine if an object has charges.
References object::pval, and tval_can_have_charges().
Referenced by context_menu_object(), do_cmd_aim_wand(), and do_cmd_use_staff().
References angband_constants::curse_max, curses, object::curses, object::flags, i, of_has, curse_data::power, and z_info.
Referenced by obj_can_takeoff().
References object::note.
Referenced by context_menu_object(), and do_cmd_uninscribe().
Determine if an object is activatable.
References object_effect(), and tval_is_wearable().
Referenced by context_menu_object(), do_cmd_activate(), do_cmd_use(), and obj_can_activate().
References player_state::ammo_tval, object_effect(), player::state, object::tval, tval_is_ammo(), and tval_is_useable().
Referenced by context_menu_object(), and do_cmd_use().
bool obj_kind_can_browse | ( | const struct object_kind * | kind | ) |
References class_magic::books, player::class, i, lookup_kind(), player_class::magic, class_magic::num_books, class_book::sval, and class_book::tval.
Referenced by make_object(), and obj_can_browse().
bool obj_needs_aim | ( | struct object * | obj | ) |
Does the given object need to be aimed?
References effect_aim(), object_effect(), object_flavor_is_aware(), tval_is_ammo(), tval_is_rod(), and tval_is_wand().
Referenced by use_aux().
Return an object's effect.
References object::activation, activation::effect, and object::effect.
Referenced by describe_effect(), obj_is_activatable(), obj_is_useable(), obj_known_effect(), obj_needs_aim(), and use_aux().
Obtain the flags for an item.
References object::flags, flags, of_copy, and of_wipe.
Referenced by calc_bonuses(), equip_learn_after_time(), get_known_flags(), object_curses_find_flags(), object_flags_known(), object_learn_on_wield(), and wiz_display_item().
Obtain the flags for an item which are known to the player.
References easy_know(), object::ego, object_kind::flags, ego_item::flags, object::flags, flags, ego_item::flags_off, object::kind, object::known, object_flags(), object_flavor_is_aware(), of_diff, of_inter, and of_union.
Referenced by calc_bonuses(), display_player_sust_info(), display_resistance_panel(), get_known_flags(), and wiz_display_item().
Referenced by artifact_set_data_free(), dump_autoinscriptions(), dump_objects(), get_base_item(), and write_lore_entries().
bool object_test | ( | item_tester | tester, |
const struct object * | obj | ||
) |
Apply a tester function, skipping all non-objects and gold.
References tval_is_money().
Referenced by build_obj_list(), scan_floor(), scan_items(), and textui_get_item().
struct object_kind* objkind_byid | ( | int | kidx | ) |
References angband_constants::k_max, object_kind::kidx, and z_info.
Referenced by add_autoinscription(), get_obj_num(), get_obj_num_by_kind(), o_xattr(), o_xchar(), o_xtra_act(), o_xtra_prompt(), and remove_autoinscription().
Print a message from a string, customised to include details about an object.
References buf, object::kind, MSG_TAG_KIND, msg_tag_lookup(), MSG_TAG_NAME, MSG_TAG_VERB, MSG_TAG_VERB_IS, msgt(), effect::next, object::number, object_desc(), object_kind_name(), ODESC_BASE, ODESC_PREFIX, strnfcat(), and tag.
Referenced by activation_message(), and player_set_timed().
bool recharge_timeout | ( | struct object * | obj | ) |
Allow a stack of charging objects to charge by one unit per charging object Return true if something recharged.
References MIN, number_charging(), and object::timeout.
Referenced by recharge_objects().
Verify the choice of an item.
The item can be negative to mean "item on floor".
References get_check(), object_desc(), ODESC_FULL, ODESC_PREFIX, and strnfmt().
Referenced by get_item_allow(), and ignore_drop().
struct artifact* a_info |
The artifact arrays.
Referenced by a_cmp_tval(), art2gid(), artifact_is_known(), artifact_power(), cleanup_artifact(), collect_artifact_data(), collect_known_artifacts(), desc_art_fake(), describe_artifact(), design_artifact(), do_randart(), finish_parse_artifact(), finish_parse_randart(), get_art_name(), get_artifact_display_name(), make_artifact(), make_artifact_special(), mon_create_drop(), player_init(), rd_artifacts(), spoil_artifact(), store_base_power(), wiz_create_item(), wiz_create_item_action(), wiz_create_item_all_items(), wiz_create_item_subaction(), wiz_tweak_item(), wr_artifacts(), and wr_history().
struct ego_item* e_info |
struct flavor* flavors |
struct object_kind* k_info |
Referenced by alloc_init_objects(), cleanup_object(), desc_obj_fake(), display_object(), do_cmd_knowledge_ego_items(), do_cmd_wiz_learn(), dump_autoinscriptions(), dump_objects(), ego_has_ignore_type(), finish_parse_object(), hallucinatory_object(), ignore_birth_init(), ignore_collect_kind(), kind_info(), lookup_symbol(), map_info(), o_cmp_tval(), obj2gid(), object_info_ego(), parse_ego_type(), parse_object_power_type(), parse_prefs_object(), player_init(), rd_object_memory(), reset_visuals(), seen_tval(), setup_tests(), spoil_obj_desc(), teardown_tests(), test_defaults(), textui_browse_object_knowledge(), tval_sval_count(), tval_sval_list(), wiz_create_item_action(), wiz_create_item_all_items(), wiz_create_item_subaction(), wiz_create_item_subdisplay(), wr_ignore(), wr_object_memory(), write_book_kind(), and write_dummy_object_record().
struct object_base* kb_info |
|
static |
Hold the titles of scrolls, 6 to 14 characters each, plus quotes.
Referenced by flavor_assign_random(), and flavor_init().