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-identify.h"
#include "obj-ignore.h"
#include "obj-pile.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-attack.h"
#include "player-history.h"
#include "player-util.h"
#include "trap.h"


static void player_pickup_gold (void)
 Pick up all gold at the player's current location.
static bool auto_pickup_okay (const struct object *obj)
 Determine if an object can be picked up automatically.
static void player_pickup_aux (struct object *obj, bool domsg)
 Move an object from a floor pile to the player's gear.
static byte player_pickup_item (struct object *obj, bool menu)
 Pick up objects and treasure on the floor.
int do_autopickup (void)
 Pick up everything on the floor that requires no player action.
void do_cmd_pickup (struct command *cmd)
 Pick up objects at the player's request.
void do_cmd_autopickup (struct command *cmd)
 Pick up or look at objects on a square when the player steps onto it.

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

static bool auto_pickup_okay ( const struct object obj)

Determine if an object can be picked up automatically.

References check_for_inscrip(), FALSE, inven_carry_okay(), inven_stack_okay(), OPT, and TRUE.

Referenced by do_autopickup().

int do_autopickup ( void  )

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

References auto_pickup_okay(), cave, disturb(), ignore_item_ok(), object::next, player_pickup_aux(), player_pickup_gold(), player::px, player::py, square_object(), and TRUE.

Referenced by do_cmd_autopickup(), do_cmd_hold(), and do_cmd_pickup().

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, player::upkeep, and z_info.

void do_cmd_pickup ( struct command cmd)
static void player_pickup_aux ( struct object obj,
bool  domsg 
static void player_pickup_gold ( void  )
static byte player_pickup_item ( 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(), FALSE, angband_constants::floor_size, get_item(), i, inven_carry_okay(), mem_free(), mem_zalloc(), player_pickup_aux(), player_pickup_gold(), player::px, player::py, scan_floor(), square_holds_object(), square_object(), TRUE, USE_FLOOR, and z_info.

Referenced by do_cmd_pickup().