cmd-pickup.c File Reference

Pickup code. More...

#include "angband.h"
#include "cave.h"
#include "cmds.h"
#include "game-event.h"
#include "game-input.h"
#include "generate.h"
#include "init.h"
#include "mon-lore.h"
#include "mon-timed.h"
#include "mon-util.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-ignore.h"
#include "obj-pile.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-attack.h"
#include "player-calcs.h"
#include "player-history.h"
#include "player-util.h"
#include "trap.h"


static void player_pickup_gold (struct player *p)
 Pick up all gold at the player's current location. More...
static struct objectfind_stack_object_in_inventory (const struct object *obj)
 Find the specified object in the inventory (not equipment) More...
static bool auto_pickup_okay (const struct object *obj)
 Determine if an object can be picked up automatically. More...
static void player_pickup_aux (struct player *p, struct object *obj, int auto_max, bool domsg)
 Move an object from a floor pile to the player's gear, checking first whether partial pickup is needed. More...
static byte player_pickup_item (struct player *p, struct object *obj, bool menu)
 Pick up objects and treasure on the floor. More...
int do_autopickup (struct player *p)
 Pick up everything on the floor that requires no player action. More...
void do_cmd_pickup (struct command *cmd)
 Pick up objects at the player's request. More...
void do_cmd_autopickup (struct command *cmd)
 Pick up or look at objects on a square when the player steps onto it. More...

Detailed Description

Pickup code.

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke, Copyright (c) 2007 Leon Marrick

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.

Function Documentation

◆ auto_pickup_okay()

static bool auto_pickup_okay ( const struct object obj)

Determine if an object can be picked up automatically.

References check_for_inscrip(), find_stack_object_in_inventory(), inven_carry_num(), inven_carry_okay(), and OPT.

Referenced by do_autopickup().

◆ do_autopickup()

int do_autopickup ( struct player p)

Pick up everything on the floor that requires no player action.

References auto_pickup_okay(), cave, disturb(), player::grid, ignore_item_ok(), inven_carry_num(), object::next, player_pickup_aux(), player_pickup_gold(), and square_object().

Referenced by do_cmd_autopickup(), and do_cmd_hold().

◆ do_cmd_autopickup()

void do_cmd_autopickup ( struct command cmd)

Pick up or look at objects on a square when the player steps onto it.

References do_autopickup(), player_upkeep::energy_use, EVENT_SEEFLOOR, event_signal(), angband_constants::move_energy, PR_ITEMLIST, player_upkeep::redraw, player::upkeep, and z_info.

◆ do_cmd_pickup()

void do_cmd_pickup ( struct command cmd)

◆ find_stack_object_in_inventory()

static struct object* find_stack_object_in_inventory ( const struct object obj)

Find the specified object in the inventory (not equipment)

References player::body, player::gear, object::next, object_is_equipped(), object_stackable(), and OSTACK_PACK.

Referenced by auto_pickup_okay().

◆ player_pickup_aux()

static void player_pickup_aux ( struct player p,
struct object obj,
int  auto_max,
bool  domsg 

◆ player_pickup_gold()

static void player_pickup_gold ( struct player p)

◆ player_pickup_item()

static byte player_pickup_item ( struct player p,
struct object obj,
bool  menu 

Pick up objects and treasure on the floor.


Scan the list of objects in that floor grid. Pick up gold automatically. Pick up objects automatically until backpack space is full if auto-pickup option is on, otherwise, store objects on floor in an array, and tally both how many there are and can be picked up.

If not picking up anything, indicate objects on the floor. Do the same thing if we don't have room for anything.

Pick up multiple objects using Tim Baker's menu system. Recursively call this function (forcing menus for any number of objects) until objects are gone, backpack is full, or player is satisfied.

We keep track of number of objects picked up to calculate time spent. This tally is incremented even for automatic pickup, so we are careful (in "dungeon.c" and elsewhere) to handle pickup as either a separate automated move or a no-cost part of the stay still or 'g'et command.

Note the lack of chance for the character to be disturbed by unmarked objects. They are truly "unknown".

objis the object to pick up.
menuis whether to present a menu to the player

References cave, CMD_PICKUP, EVENT_SEEFLOOR, event_signal(), floor_list, angband_constants::floor_size, get_item(), player::grid, i, inven_carry_okay(), mem_free(), mem_zalloc(), OFLOOR_VISIBLE, player_pickup_aux(), player_pickup_gold(), scan_floor(), square_know_pile(), square_object(), USE_FLOOR, and z_info.

Referenced by do_cmd_pickup().