Angband
Macros | Functions
obj-util.h File Reference

Object utilities. More...

Go to the source code of this file.

Macros

#define MAX_TITLES   50
#define MAX_PVAL   32767

Functions

void flavor_init (void)
 Prepare the "variable" part of the "k_info" array.
void object_flags (const object_type *o_ptr, bitflag flags[OF_SIZE])
void object_flags_known (const object_type *o_ptr, bitflag flags[OF_SIZE])
bool object_test (item_tester tester, const struct object *o)
 Apply a tester function, skipping all non-objects and gold.
bool item_test (item_tester tester, int item)
bool is_unknown (const object_type *o_ptr)
unsigned check_for_inscrip (const object_type *o_ptr, const char *inscrip)
struct object_kindlookup_kind (int tval, int sval)
 Return the object kind with the given tval and sval, or NULL.
struct object_kindobjkind_byid (int kidx)
int lookup_artifact_name (const char *name)
 Return the a_idx of the artifact with the given name.
int lookup_sval (int tval, const char *name)
 Return the numeric sval of the object kind with the given tval and name name.
void object_short_name (char *buf, size_t max, const char *name)
int compare_items (const object_type *o1, const object_type *o2)
bool obj_has_charges (const object_type *o_ptr)
bool obj_can_zap (const object_type *o_ptr)
bool obj_is_activatable (const object_type *o_ptr)
bool obj_can_activate (const object_type *o_ptr)
bool obj_can_refill (const object_type *o_ptr)
bool obj_can_browse (const object_type *o_ptr)
bool obj_can_cast_from (const object_type *o_ptr)
bool obj_can_study (const object_type *o_ptr)
bool obj_can_takeoff (const object_type *o_ptr)
bool obj_can_wear (const object_type *o_ptr)
bool obj_can_fire (const object_type *o_ptr)
bool obj_has_inscrip (const object_type *o_ptr)
bool obj_is_useable (const object_type *o_ptr)
u16b object_effect (const object_type *o_ptr)
bool obj_needs_aim (object_type *o_ptr)
 Does the given object need to be aimed?
bool obj_can_fail (const struct object *o)
 Can the object fail if used?
int get_use_device_chance (const object_type *o_ptr)
void distribute_charges (object_type *o_ptr, object_type *q_ptr, int amt)
 Distribute charges of rods, staves, or wands.
void reduce_charges (object_type *o_ptr, int amt)
 If rods or wand are destroyed, the total maximum timeout or charges of the stack needs to be reduced, unless all the items are being destroyed.
int number_charging (const object_type *o_ptr)
bool recharge_timeout (object_type *o_ptr)
 Allow a stack of charging objects to charge by one unit per charging object Return TRUE if something recharged.
bool verify_object (const char *prompt, struct object *obj)
 Verify the choice of an item.

Detailed Description

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.

Macro Definition Documentation

#define MAX_PVAL   32767
#define MAX_TITLES   50

Referenced by flavor_init().

Function Documentation

unsigned check_for_inscrip ( const object_type o_ptr,
const char *  inscrip 
)
int compare_items ( const object_type o1,
const object_type o2 
)
void distribute_charges ( struct object o_ptr,
struct object q_ptr,
int  amt 
)

Distribute charges of rods, staves, or wands.

Parameters
o_ptris the source item
q_ptris the target item, must be of the same type as o_ptr
amtis 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(), do_cmd_sell(), do_cmd_stash(), and object_split().

void flavor_init ( void  )

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, FALSE, object_kind::flavor, flavor_assign_fixed(), flavor_assign_random(), flavor_reset_fixed(), i, angband_constants::k_max, MAX_TITLES, my_strcpy(), object_kind::name, name_sections, OPT, Rand_quick, Rand_value, randname_make(), RANDNAME_SCROLL, scroll_adj, seed_flavor, streq, TRUE, and z_info.

Referenced by do_cmd_accept_character(), and rd_misc().

int get_use_device_chance ( const object_type o_ptr)
bool is_unknown ( const object_type o_ptr)
bool item_test ( item_tester  tester,
int  item 
)
int lookup_artifact_name ( const char *  name)

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 parse_lore_drop_artifact(), and parse_monster_drop_artifact().

struct object_kind* lookup_kind ( int  tval,
int  sval 
)
read
int lookup_sval ( int  tval,
const char *  name 
)
int number_charging ( const object_type o_ptr)
bool obj_can_activate ( const object_type o_ptr)
bool obj_can_browse ( const object_type o_ptr)
bool obj_can_cast_from ( const object_type o_ptr)
bool obj_can_fail ( const struct object o)

Can the object fail if used?

References FALSE, TRUE, tval_can_have_failure(), and wield_slot().

Referenced by show_obj_list().

bool obj_can_fire ( const object_type o_ptr)
bool obj_can_refill ( const object_type o_ptr)
bool obj_can_study ( const object_type o_ptr)
bool obj_can_takeoff ( const object_type o_ptr)
bool obj_can_wear ( const object_type o_ptr)
bool obj_can_zap ( const object_type o_ptr)
bool obj_has_charges ( const object_type o_ptr)
bool obj_has_inscrip ( const object_type o_ptr)
bool obj_is_activatable ( const object_type o_ptr)
bool obj_is_useable ( const object_type o_ptr)
bool obj_needs_aim ( object_type o_ptr)

Does the given object need to be aimed?

References object::effect, effect_aim(), object_flavor_is_aware(), tval_is_ammo(), tval_is_rod(), and tval_is_wand().

Referenced by use_aux().

u16b object_effect ( const object_type o_ptr)
void object_flags ( const object_type o_ptr,
bitflag  flags[OF_SIZE] 
)
void object_flags_known ( const object_type o_ptr,
bitflag  flags[OF_SIZE] 
)
void object_short_name ( char *  buf,
size_t  max,
const char *  name 
)
bool object_test ( item_tester  tester,
const struct object o 
)

Apply a tester function, skipping all non-objects and gold.

References FALSE, and tval_is_money().

Referenced by scan_floor(), scan_items(), show_equip(), show_floor(), show_inven(), show_quiver(), spell_identify_unknown_available(), and textui_get_item().

struct object_kind* objkind_byid ( int  kidx)
read
bool recharge_timeout ( object_type o_ptr)

Allow a stack of charging objects to charge by one unit per charging object Return TRUE if something recharged.

References FALSE, MIN, number_charging(), object::timeout, and TRUE.

Referenced by recharge_objects().

void reduce_charges ( struct object o_ptr,
int  amt 
)

If rods or wand are destroyed, the total maximum timeout or charges of the stack needs to be reduced, unless all the items are being destroyed.

-LM-

References object::number, object::pval, object::timeout, tval_can_have_charges(), and tval_can_have_timeout().

Referenced by effect_handler_RECHARGE(), inven_damage(), and wiz_quantity_item().

bool verify_object ( const char *  prompt,
struct object obj 
)

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(), ignore_drop(), and textui_get_item().