Angband
Functions | Variables
cmd-cave.c File Reference

Chest and door opening/closing, disarming, running, resting, &c. More...

#include "angband.h"
#include "cave.h"
#include "cmd-core.h"
#include "cmds.h"
#include "game-event.h"
#include "game-input.h"
#include "generate.h"
#include "init.h"
#include "mon-desc.h"
#include "mon-lore.h"
#include "mon-timed.h"
#include "mon-util.h"
#include "monster.h"
#include "obj-chest.h"
#include "obj-identify.h"
#include "obj-ignore.h"
#include "obj-util.h"
#include "player-attack.h"
#include "player-path.h"
#include "player-timed.h"
#include "player-util.h"
#include "store.h"
#include "trap.h"

Functions

void do_cmd_go_up (struct command *cmd)
 Go up one level.
void do_cmd_go_down (struct command *cmd)
 Go down one level.
bool search (bool verbose)
 Search for hidden things.
void do_cmd_search (struct command *cmd)
 Simple command to "search" for one turn.
void do_cmd_toggle_search (struct command *cmd)
 Toggle search mode.
static bool do_cmd_open_test (int y, int x)
 Determine if a given grid may be "opened".
static bool do_cmd_open_aux (int y, int x)
 Perform the basic "open" command on doors.
void do_cmd_open (struct command *cmd)
 Open a closed/locked/jammed door or a closed/locked chest.
static bool do_cmd_close_test (int y, int x)
 Determine if a given grid may be "closed".
static bool do_cmd_close_aux (int y, int x)
 Perform the basic "close" command.
void do_cmd_close (struct command *cmd)
 Close an open door.
static bool do_cmd_tunnel_test (int y, int x)
 Determine if a given grid may be "tunneled".
static bool twall (int y, int x)
 Tunnel through wall.
static bool do_cmd_tunnel_aux (int y, int x)
 Perform the basic "tunnel" command.
void do_cmd_tunnel (struct command *cmd)
 Tunnel through "walls" (including rubble and doors, secret or otherwise)
static bool do_cmd_disarm_test (int y, int x)
 Determine if a given grid may be "disarmed".
static bool do_cmd_lock_door (int y, int x)
 Perform the command "lock door".
static bool do_cmd_disarm_aux (int y, int x)
 Perform the basic "disarm" command.
void do_cmd_disarm (struct command *cmd)
 Disarms a trap, or a chest.
void do_cmd_alter_aux (int dir)
 Manipulate an adjacent grid in some way.
void do_cmd_alter (struct command *cmd)
void move_player (int dir, bool disarm)
 Move player in the given direction.
static bool do_cmd_walk_test (int y, int x)
 Determine if a given grid may be "walked".
void do_cmd_walk (struct command *cmd)
 Walk in the given direction.
void do_cmd_jump (struct command *cmd)
 Walk into a trap.
void do_cmd_run (struct command *cmd)
 Start running.
void do_cmd_pathfind (struct command *cmd)
 Start running with pathfinder.
void do_cmd_hold (struct command *cmd)
 Stay still.
void do_cmd_rest (struct command *cmd)
 Rest (restores hit points and mana and such)
void do_cmd_sleep (struct command *cmd)
 Spend a turn doing nothing.
void display_feeling (bool obj_only)
 Display the feeling.
void do_cmd_feeling (void)

Variables

static const char * obj_feeling_text []
 Array of feeling strings for object feelings.
static const char * mon_feeling_text []
 Array of feeling strings for monster feelings.

Detailed Description

Chest and door opening/closing, disarming, running, resting, &c.

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.

Function Documentation

void display_feeling ( bool  obj_only)

Display the feeling.

Players always get a monster feeling. Object feelings are delayed until the player has explored some of the level.

References cave, player::depth, chunk::feeling, angband_constants::feeling_need, chunk::feeling_squares, mon_feeling_text, msg, N_ELEMENTS, obj_feeling_text, OPT, and z_info.

Referenced by do_cmd_feeling(), on_new_level(), and update_one().

void do_cmd_alter ( struct command cmd)
void do_cmd_alter_aux ( int  dir)

Manipulate an adjacent grid in some way.

Attack monsters, tunnel through walls, disarm traps, open doors.

This command must always take energy, to prevent free detection of invisible monsters.

The "semantics" of this command must be chosen before the player is confused, and it must be verified against the new grid.

References cave, ddx, ddy, disturb(), do_cmd_disarm_aux(), do_cmd_open_aux(), do_cmd_tunnel_aux(), player_upkeep::energy_use, FALSE, square::mon, angband_constants::move_energy, msg, player_confuse_dir(), player::px, player::py, py_attack(), square_iscloseddoor(), square_isdiggable(), square_isknowntrap(), chunk::squares, player::upkeep, and z_info.

Referenced by do_cmd_alter(), and move_player().

void do_cmd_close ( struct command cmd)
static bool do_cmd_close_aux ( int  y,
int  x 
)
static

Perform the basic "close" command.

Assume there is no monster blocking the destination

Returns TRUE if repeated commands may continue

References cave, do_cmd_close_test(), FALSE, msg, PU_MONSTERS, PU_UPDATE_VIEW, sound(), square_close_door(), square_isbrokendoor(), player_upkeep::update, and player::upkeep.

Referenced by do_cmd_close().

static bool do_cmd_close_test ( int  y,
int  x 
)
static

Determine if a given grid may be "closed".

References cave, FALSE, msg, square_isbrokendoor(), square_ismark(), square_isopendoor(), and TRUE.

Referenced by do_cmd_close(), and do_cmd_close_aux().

void do_cmd_disarm ( struct command cmd)
static bool do_cmd_disarm_aux ( int  y,
int  x 
)
static

Perform the basic "disarm" command.

Assume there is no monster blocking the destination

Returns TRUE if repeated commands may continue

References cave, do_cmd_disarm_test(), EVENT_INPUT_FLUSH, event_signal(), FALSE, trap::flags, hit_trap(), i, square::info, trap::kind, msg, msgt(), trap_kind::name, trap::next, no_light(), player_exp_gain(), power, randint0, randint1, SKILL_DISARM, player_state::skills, sqinfo_off, square_destroy_trap(), chunk::squares, player::state, player::timed, square::trap, trf_has, and TRUE.

Referenced by do_cmd_alter_aux(), and do_cmd_disarm().

static bool do_cmd_disarm_test ( int  y,
int  x 
)
static

Determine if a given grid may be "disarmed".

References cave, FALSE, msg, square_iscloseddoor(), square_isknowntrap(), square_islockeddoor(), square_ismark(), and TRUE.

Referenced by do_cmd_disarm(), do_cmd_disarm_aux(), and do_cmd_lock_door().

void do_cmd_feeling ( void  )

References display_feeling(), and FALSE.

void do_cmd_go_down ( struct command cmd)
void do_cmd_go_up ( struct command cmd)
void do_cmd_hold ( struct command cmd)
void do_cmd_jump ( struct command cmd)
static bool do_cmd_lock_door ( int  y,
int  x 
)
static

Perform the command "lock door".

Assume there is no monster blocking the destination

Returns TRUE if repeated commands may continue

References cave, player::depth, do_cmd_disarm_test(), EVENT_INPUT_FLUSH, event_signal(), FALSE, i, m_bonus(), msg, no_light(), power, randint0, randint1, SKILL_DISARM, player_state::skills, square_set_door_lock(), player::state, player::timed, and TRUE.

Referenced by do_cmd_disarm().

void do_cmd_open ( struct command cmd)
static bool do_cmd_open_aux ( int  y,
int  x 
)
static

Perform the basic "open" command on doors.

Assume there is no monster blocking the destination

Returns TRUE if repeated commands may continue

References cave, do_cmd_open_test(), EVENT_INPUT_FLUSH, event_signal(), FALSE, i, msgt(), no_light(), PU_MONSTERS, PU_UPDATE_VIEW, randint0, SKILL_DISARM, player_state::skills, sound(), square_door_power(), square_islockeddoor(), square_open_door(), player::state, player::timed, TRUE, player_upkeep::update, and player::upkeep.

Referenced by do_cmd_alter_aux(), and do_cmd_open().

static bool do_cmd_open_test ( int  y,
int  x 
)
static

Determine if a given grid may be "opened".

References cave, FALSE, msg, msgt(), square_iscloseddoor(), square_ismark(), and TRUE.

Referenced by do_cmd_open(), and do_cmd_open_aux().

void do_cmd_pathfind ( struct command cmd)

Start running with pathfinder.

Note that running while confused is not allowed.

References cmd_get_arg_point(), findpath(), PU_TORCH, run_step(), player_upkeep::running, player_upkeep::running_withpathfind, player::timed, TRUE, player_upkeep::update, and player::upkeep.

void do_cmd_rest ( struct command cmd)
void do_cmd_run ( struct command cmd)

Start running.

Note that running while confused is not allowed.

References cmd_get_direction(), CMD_OK, ddx, ddy, do_cmd_walk_test(), FALSE, player_confuse_dir(), player::px, player::py, run_step(), and TRUE.

void do_cmd_search ( struct command cmd)

Simple command to "search" for one turn.

References player_upkeep::energy_use, angband_constants::move_energy, search(), TRUE, player::upkeep, and z_info.

void do_cmd_sleep ( struct command cmd)

Spend a turn doing nothing.

References player_upkeep::energy_use, angband_constants::move_energy, player::upkeep, and z_info.

void do_cmd_toggle_search ( struct command cmd)
void do_cmd_tunnel ( struct command cmd)

Tunnel through "walls" (including rubble and doors, secret or otherwise)

Digging is very difficult without a "digger" weapon, but can be accomplished by strong players using heavy weapons.

References cave, cmd_get_direction(), ddx, ddy, disturb(), do_cmd_tunnel_aux(), do_cmd_tunnel_test(), player_upkeep::energy_use, FALSE, square::mon, angband_constants::move_energy, msg, player_confuse_dir(), player::px, player::py, py_attack(), chunk::squares, player::upkeep, and z_info.

static bool do_cmd_tunnel_aux ( int  y,
int  x 
)
static

Perform the basic "tunnel" command.

Assumes that no monster is blocking the destination. Uses twall() (above) to do all "terrain feature changing". Returns TRUE if repeated commands may continue.

References calc_digging_chances(), cave, player::depth, DIGGING_MAX, do_cmd_tunnel_test(), FALSE, gold, ignore_item_ok(), msg, place_gold(), place_object(), player_can_see_bold(), randint0, search(), square_apparent_name(), square_digging(), square_hasgoldvein(), square_isrubble(), square_issecretdoor(), square_object(), player::state, TRUE, and twall().

Referenced by do_cmd_alter_aux(), and do_cmd_tunnel().

static bool do_cmd_tunnel_test ( int  y,
int  x 
)
static

Determine if a given grid may be "tunneled".

References cave, FALSE, msg, square_iscloseddoor(), square_isdiggable(), square_ismark(), square_isperm(), and TRUE.

Referenced by do_cmd_tunnel(), and do_cmd_tunnel_aux().

void do_cmd_walk ( struct command cmd)
static bool do_cmd_walk_test ( int  y,
int  x 
)
static
void move_player ( int  dir,
bool  disarm 
)
bool search ( bool  verbose)

Search for hidden things.

Returns true if a search was attempted, returns false when the player has a 0% chance of finding anything. Prints messages for negative confirmation when verbose mode is requested.

References cave, disturb(), FALSE, is_trapped_chest(), msg, object::next, no_light(), object_is_known(), object_notice_everything(), place_closed_door(), player::px, player::py, randint0, SKILL_SEARCH, player_state::skills, square_issecretdoor(), square_issecrettrap(), square_object(), square_reveal_trap(), player::state, player::timed, and TRUE.

Referenced by do_cmd_hold(), do_cmd_search(), do_cmd_tunnel_aux(), and move_player().

static bool twall ( int  y,
int  x 
)
static

Tunnel through wall.

Assumes valid location.

Note that it is impossible to "extend" rooms past their outer walls (which are actually part of the room).

Attempting to do so will produce floor grids which are not part of the room, and whose "illumination" status do not change with the rest of the room.

References cave, FALSE, square::info, PU_FORGET_FLOW, PU_MONSTERS, PU_UPDATE_FLOW, PU_UPDATE_VIEW, sound(), sqinfo_off, square_iscloseddoor(), square_isdiggable(), square_tunnel_wall(), chunk::squares, TRUE, player_upkeep::update, and player::upkeep.

Referenced by do_cmd_tunnel_aux().

Variable Documentation

const char* mon_feeling_text[]
static
Initial value:
{
"You are still uncertain about this place",
"Omens of death haunt this place",
"This place seems murderous",
"This place seems terribly dangerous",
"You feel anxious about this place",
"You feel nervous about this place",
"This place does not seem too risky",
"This place seems reasonably safe",
"This seems a tame, sheltered place",
"This seems a quiet, peaceful place"
}

Array of feeling strings for monster feelings.

Keep strings at 36 or less characters to keep the combined feeling on one row.

Referenced by display_feeling().

const char* obj_feeling_text[]
static
Initial value:
{
"Looks like any other level.",
"you sense an item of wondrous power!",
"there are superb treasures here.",
"there are excellent treasures here.",
"there are very good treasures here.",
"there are good treasures here.",
"there may be something worthwhile here.",
"there may not be much interesting here.",
"there aren't many treasures here.",
"there are only scraps of junk here.",
"there are naught but cobwebs here."
}

Array of feeling strings for object feelings.

Keep strings at 36 or less characters to keep the combined feeling on one row.

Referenced by display_feeling().