Angband
Macros | Enumerations | Functions
obj-gear.h File Reference

management of inventory, equipment and quiver More...

#include "player.h"
#include "list-equip-slots.h"

Go to the source code of this file.

Macros

#define EQUIP(a, b, c, d, e, f)   EQUIP_##a,

Enumerations

enum  { EQUIP_MAX }
 Player equipment slot types. More...

Functions

int slot_by_name (struct player *p, const char *name)
bool slot_type_is (int slot, int type)
struct objectslot_object (struct player *p, int slot)
struct objectequipped_item_by_slot_name (struct player *p, const char *name)
bool object_is_equipped (struct player_body body, const struct object *obj)
bool object_is_carried (struct player *p, const struct object *obj)
const char * equip_mention (struct player *p, int slot)
const char * equip_describe (struct player *p, int slot)
int wield_slot (const struct object *o_ptr)
 Determine which equipment slot (if any) an item likes.
int minus_ac (struct player *p)
 Acid has hit the player, attempt to affect some armor.
char gear_to_label (struct object *obj)
 Convert a gear object into a one character label.
bool gear_excise_object (struct object *obj)
 Remove an object from the gear list, leaving it unattached.
struct objectgear_last_item (void)
struct objectgear_object_for_use (struct object *obj, int num, bool message)
 Remove an amount of an object from the inventory or quiver, returning a detached object which can be used.
bool inven_carry_okay (const struct object *obj)
bool inven_stack_okay (const struct object *o_ptr)
void inven_item_charges (struct object *obj)
 Describe the charges on an item in the inventory.
bool inven_carry (struct player *p, struct object *obj, bool message)
 Add an item to the players inventory.
void inven_takeoff (struct object *item)
 Take off a non-cursed equipment item.
void inven_drop (struct object *obj, int amt)
 Drop (some of) a non-cursed inventory/equipment item "near" the current location.
void combine_pack (void)
 Combine items in the pack, confirming no blank objects or gold.
bool pack_is_full (void)
 Returns whether the pack is holding the maximum number of items.
bool pack_is_overfull (void)
 Returns whether the pack is holding the more than the maximum number of items.
void pack_overflow (void)
 Overflow an item from the pack, if it is overfull.

Detailed Description

management of inventory, equipment and quiver

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke Copyright (c) 2014 Nick McConnell

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 EQUIP (   a,
  b,
  c,
  d,
  e,
 
)    EQUIP_##a,

Enumeration Type Documentation

anonymous enum

Player equipment slot types.

Enumerator:
EQUIP_MAX 

Function Documentation

void combine_pack ( void  )
const char* equip_describe ( struct player p,
int  slot 
)
const char* equip_mention ( struct player p,
int  slot 
)
struct object* equipped_item_by_slot_name ( struct player p,
const char *  name 
)
read
bool gear_excise_object ( struct object obj)

Remove an object from the gear list, leaving it unattached.

Parameters
objthe object being tested
Returns
whether an object was removed

References player::body, player_body::count, player::gear, i, player_upkeep::notice, equip_slot::obj, pile_excise(), PN_COMBINE, PR_EQUIP, PR_INVEN, PU_BONUS, PU_INVEN, PU_MANA, player_upkeep::redraw, slot_object(), player_body::slots, TRUE, player_upkeep::update, and player::upkeep.

Referenced by gear_object_for_use(), pack_overflow(), and player_update_light().

struct object* gear_last_item ( void  )
read

References player::gear, and pile_last_item().

Referenced by combine_pack(), and ignore_drop().

struct object* gear_object_for_use ( struct object obj,
int  num,
bool  message 
)
read
char gear_to_label ( struct object obj)
bool inven_carry ( struct player p,
struct object obj,
bool  message 
)

Add an item to the players inventory.

If the new item can combine with an existing item in the inventory, it will do so, using object_similar() and object_absorb(), else, the item will be placed into the first available gear array index.

This function can be used to "over-fill" the player's pack, but only once, and such an action must trigger the "overflow" code immediately. Note that when the pack is being "over-filled", the new item must be placed into the "overflow" slot, and the "overflow" must take place before the pack is reordered, but (optionally) after the pack is combined. This may be tricky. See "dungeon.c" for info.

Note that this code removes any location information from the object once it is placed into the inventory, but takes no responsibility for removing the object from any other pile it was in.

References apply_autoinscription(), player::body, do_ident_item(), FALSE, player::gear, gear_insert_end(), gear_to_label(), object::held_m_idx, object::ix, object::iy, object::marked, msg, object::next, player_upkeep::notice, object::number, object_absorb(), object_desc(), object_is_equipped(), object_is_known(), object_similar(), ODESC_FULL, ODESC_PREFIX, OSTACK_PACK, angband_constants::pack_size, pack_slots_used(), player_has, PN_COMBINE, PR_INVEN, PU_BONUS, PU_INVEN, player_upkeep::redraw, player_upkeep::total_weight, TRUE, tval_is_mushroom(), tval_is_zapper(), player_upkeep::update, update_stuff(), player::upkeep, object::weight, and z_info.

Referenced by do_cmd_buy(), do_cmd_retrieve(), player_outfit(), player_pickup_aux(), refill_lamp(), and wield_item().

bool inven_carry_okay ( const struct object obj)
void inven_drop ( struct object obj,
int  amt 
)

Drop (some of) a non-cursed inventory/equipment item "near" the current location.

There are two cases here - a single object or entire stack is being dropped, or part of a stack is being split off and dropped

References player::body, cave, drop_near(), EVENT_INVENTORY, event_signal(), FALSE, gear_object_for_use(), gear_to_label(), inven_takeoff(), msg, num, object::number, object_desc(), object_is_equipped(), ODESC_FULL, ODESC_PREFIX, player::px, player::py, and TRUE.

Referenced by do_cmd_drop().

void inven_item_charges ( struct object obj)

Describe the charges on an item in the inventory.

References msg, object_is_known(), object::pval, and tval_can_have_charges().

Referenced by use_aux().

bool inven_stack_okay ( const struct object o_ptr)
void inven_takeoff ( struct object obj)

Take off a non-cursed equipment item.

Note that only one item at a time can be wielded per slot.

Note that taking off an item when "full" may cause that item to fall to the ground.

References player::body, player_body::count, equipped_item_slot(), I2A, msgt(), player_upkeep::notice, equip_slot::obj, object_desc(), ODESC_FULL, ODESC_PREFIX, PN_COMBINE, PN_IGNORE, PU_BONUS, PU_INVEN, slot_type_is(), player_body::slots, player_upkeep::update, and player::upkeep.

Referenced by do_cmd_takeoff(), and inven_drop().

int minus_ac ( struct player p)

Acid has hit the player, attempt to affect some armor.

Note that the "base armor" of an object never changes. If any armor is damaged (or resists), the player takes less damage.

References object::ac, player::body, player_body::count, object::el_info, EL_INFO_IGNORE, FALSE, element_info::flags, player::gear, i, msg, object_desc(), ODESC_BASE, one_in_, PR_EQUIP, PU_BONUS, player_upkeep::redraw, slot_object(), slot_type_is(), object::to_a, TRUE, player_upkeep::update, and player::upkeep.

Referenced by adjust_dam().

bool object_is_carried ( struct player p,
const struct object obj 
)
bool object_is_equipped ( struct player_body  body,
const struct object obj 
)
bool pack_is_full ( void  )

Returns whether the pack is holding the maximum number of items.

References FALSE, angband_constants::pack_size, pack_slots_used(), TRUE, and z_info.

bool pack_is_overfull ( void  )

Returns whether the pack is holding the more than the maximum number of items.

If this is true, calling pack_overflow() will trigger a pack overflow.

References FALSE, angband_constants::pack_size, pack_slots_used(), TRUE, and z_info.

Referenced by pack_overflow().

void pack_overflow ( void  )
int slot_by_name ( struct player p,
const char *  name 
)
struct object* slot_object ( struct player p,
int  slot 
)
read
bool slot_type_is ( int  slot,
int  type 
)
int wield_slot ( const struct object o_ptr)

Determine which equipment slot (if any) an item likes.

The slot might (or might not) be open, but it is a slot which the object could be equipped in.

For items where multiple slots could work (e.g. rings), the function will try to return an open slot if possible.

References FALSE, slot_by_type(), object::tval, tval_is_body_armor(), tval_is_head_armor(), tval_is_light(), tval_is_melee_weapon(), and tval_is_ring().

Referenced by ammo_damage_power(), damage_dice_power(), do_cmd_wield(), flags_power(), modifier_power(), obj_can_fail(), obj_can_wear(), obj_known_digging(), rd_gear_aux(), rescale_bow_power(), to_damage_power(), and wield_all().