Angband
Data Structures | Macros | Functions | Variables
obj-gear.c File Reference

management of inventory, equipment and quiver More...

#include "angband.h"
#include "cmd-core.h"
#include "game-event.h"
#include "init.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-identify.h"
#include "obj-ignore.h"
#include "obj-pile.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-util.h"
#include "list-equip-slots.h"

Data Structures

struct  slot_info

Macros

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

Functions

int slot_by_name (struct player *p, const char *name)
int slot_by_type (struct player *p, int type, bool full)
 Gets a slot of the given type, preferentially empty unless full is true.
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)
int pack_slots_used (struct player *p)
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)
void gear_insert_end (struct object *obj)
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 object_type *obj)
 Check if we have space for an item in the pack without overflow.
bool inven_stack_okay (const object_type *o_ptr)
 Check to see if an item is stackable in the inventory.
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 *obj)
 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.
static bool inven_can_stack_partial (const object_type *o_ptr, const object_type *j_ptr, object_stack_t mode)
 Return whether each stack of objects can be merged into two uneven stacks.
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.

Variables

static struct slot_info slot_table []

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, b, c, d, e, f },

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().

void gear_insert_end ( struct object obj)

References player::gear, and pile_insert_end().

Referenced by inven_carry().

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)
static bool inven_can_stack_partial ( const object_type o_ptr,
const object_type j_ptr,
object_stack_t  mode 
)
static

Return whether each stack of objects can be merged into two uneven stacks.

References FALSE, object::number, object_stackable(), OSTACK_STORE, angband_constants::stack_size, and z_info.

Referenced by combine_pack().

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 object_type 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 object_type 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 pack_slots_used ( struct player p)
int slot_by_name ( struct player p,
const char *  name 
)
int slot_by_type ( struct player p,
int  type,
bool  full 
)

Gets a slot of the given type, preferentially empty unless full is true.

References player::body, player_body::count, i, equip_slot::obj, player_body::slots, and equip_slot::type.

Referenced by wield_slot().

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().

Variable Documentation

struct slot_info slot_table[]
static

Referenced by equip_describe(), and equip_mention().