Angband
Macros | Enumerations | Functions
player-util.h File Reference

Player utility functions. More...

#include "player.h"

Go to the source code of this file.

Macros

#define PY_REGEN_NORMAL   197 /* Regen factor*2^16 when full */
 
#define PY_REGEN_WEAK   98 /* Regen factor*2^16 when weak */
 
#define PY_REGEN_FAINT   33 /* Regen factor*2^16 when fainting */
 
#define PY_REGEN_HPBASE   1442 /* Min amount hp regen*2^16 */
 
#define PY_REGEN_MNBASE   524 /* Min amount mana regen*2^16 */
 
#define REST_REQUIRED_FOR_REGEN   5
 Minimum number of turns required for regeneration to kick in during resting. More...
 

Enumerations

enum  { REST_COMPLETE = -2, REST_ALL_POINTS = -1, REST_SOME_POINTS = -3 }
 Special values for the number of turns to rest, these need to be negative numbers, as postive numbers are taken to be a turncount, and zero means "not resting". More...
 

Functions

int dungeon_get_next_level (int dlev, int added)
 Increment to the next or decrement to the preceeding level accounting for the stair skip value in constants Keep in mind to check all intermediate level for unskippable quests. More...
 
void dungeon_change_level (struct player *p, int dlev)
 Change dungeon level - e.g. More...
 
void take_hit (struct player *p, int dam, const char *kb_str)
 Decreases players hit points and sets death flag if necessary. More...
 
void death_knowledge (struct player *p)
 Win or not, know inventory, home items and history upon death, enter score. More...
 
s16b modify_stat_value (int value, int amount)
 Modify a stat value by a "modifier", return new value. More...
 
void player_regen_hp (struct player *p)
 Regenerate hit points. More...
 
void player_regen_mana (struct player *p)
 Regenerate mana points. More...
 
void player_update_light (struct player *p)
 Update the player's light fuel. More...
 
int player_check_terrain_damage (struct player *p, int y, int x)
 See how much damage the player will take from damaging terrain. More...
 
void player_take_terrain_damage (struct player *p, int y, int x)
 Terrain damages the player. More...
 
bool player_can_cast (struct player *p, bool show_msg)
 Return true if the player can cast a spell. More...
 
bool player_can_study (struct player *p, bool show_msg)
 Return true if the player can study a spell. More...
 
bool player_can_read (struct player *p, bool show_msg)
 Return true if the player can read scrolls or books. More...
 
bool player_can_fire (struct player *p, bool show_msg)
 Return true if the player can fire something with a launcher. More...
 
bool player_can_refuel (struct player *p, bool show_msg)
 Return true if the player can refuel their light source. More...
 
bool player_can_cast_prereq (void)
 Prerequiste function for command. More...
 
bool player_can_study_prereq (void)
 Prerequiste function for command. More...
 
bool player_can_read_prereq (void)
 Prerequiste function for command. More...
 
bool player_can_fire_prereq (void)
 Prerequiste function for command. More...
 
bool player_can_refuel_prereq (void)
 Prerequiste function for command. More...
 
bool player_book_has_unlearned_spells (struct player *p)
 Return true if the player has access to a book that has unlearned spells. More...
 
bool player_confuse_dir (struct player *p, int *dir, bool too)
 Apply confusion, if needed, to a direction. More...
 
bool player_resting_is_special (s16b count)
 Return true if the provided count is one of the conditional REST_ flags. More...
 
bool player_is_resting (struct player *p)
 Return true if the player is resting. More...
 
s16b player_resting_count (struct player *p)
 Return the remaining number of resting turns. More...
 
void player_resting_set_count (struct player *p, s16b count)
 Set the number of resting turns. More...
 
void player_resting_cancel (struct player *p, bool disturb)
 Cancel current rest. More...
 
bool player_resting_can_regenerate (struct player *p)
 Return true if the player should get a regeneration bonus for the current rest. More...
 
void player_resting_step_turn (struct player *p)
 Perform one turn of resting. More...
 
void player_resting_complete_special (struct player *p)
 Handle the conditions for conditional resting (resting with the REST_ constants). More...
 
int player_get_resting_repeat_count (struct player *p)
 Get the number of resting turns to repeat. More...
 
void player_set_resting_repeat_count (struct player *p, s16b count)
 Set the number of resting turns to repeat. More...
 
bool player_of_has (struct player *p, int flag)
 Check if the player state has the given OF_ flag. More...
 
bool player_resists (struct player *p, int element)
 Check if the player resists (or better) an element. More...
 
bool player_is_immune (struct player *p, int element)
 Check if the player resists (or better) an element. More...
 
int coords_to_dir (struct player *p, int y, int x)
 
void player_place (struct chunk *c, struct player *p, int y, int x)
 Places the player at the given coordinates in the cave. More...
 
void disturb (struct player *p, int stop_search)
 
void search (struct player *p)
 Search for traps or secret doors. More...
 

Detailed Description

Player utility functions.

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 PY_REGEN_FAINT   33 /* Regen factor*2^16 when fainting */

Referenced by player_regen_hp().

#define PY_REGEN_HPBASE   1442 /* Min amount hp regen*2^16 */

Referenced by player_regen_hp().

#define PY_REGEN_MNBASE   524 /* Min amount mana regen*2^16 */

Referenced by player_regen_mana().

#define PY_REGEN_NORMAL   197 /* Regen factor*2^16 when full */
#define PY_REGEN_WEAK   98 /* Regen factor*2^16 when weak */

Referenced by player_regen_hp().

#define REST_REQUIRED_FOR_REGEN   5

Minimum number of turns required for regeneration to kick in during resting.

Referenced by player_resting_can_regenerate().

Enumeration Type Documentation

anonymous enum

Special values for the number of turns to rest, these need to be negative numbers, as postive numbers are taken to be a turncount, and zero means "not resting".

Enumerator
REST_COMPLETE 
REST_ALL_POINTS 
REST_SOME_POINTS 

Function Documentation

int coords_to_dir ( struct player p,
int  y,
int  x 
)
void death_knowledge ( struct player p)
void disturb ( struct player p,
int  stop_search 
)
void dungeon_change_level ( struct player p,
int  dlev 
)
int dungeon_get_next_level ( int  dlev,
int  added 
)

Increment to the next or decrement to the preceeding level accounting for the stair skip value in constants Keep in mind to check all intermediate level for unskippable quests.

References i, is_quest(), angband_constants::max_depth, angband_constants::stair_skip, and z_info.

Referenced by do_cmd_go_down(), do_cmd_go_up(), effect_handler_DEEP_DESCENT(), effect_handler_RECALL(), effect_handler_TELEPORT_LEVEL(), hit_trap(), and process_world().

s16b modify_stat_value ( int  value,
int  amount 
)

Modify a stat value by a "modifier", return new value.

Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220 Or even: 18/13, 18/23, 18/33, ..., 18/220

Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3 Or even: 18/13, 18/03, 18, 17, ..., 3

References i.

Referenced by calc_bonuses(), and get_stats().

bool player_book_has_unlearned_spells ( struct player p)
bool player_can_cast ( struct player p,
bool  show_msg 
)

Return true if the player can cast a spell.

Parameters
pis the player
show_msgshould be set to true if a failure message should be displayed.

References player::class, player_class::magic, msg, no_light(), class_magic::spell_realm, and player::timed.

Referenced by context_menu_cave(), context_menu_object(), context_menu_player(), do_cmd_cast(), player_can_cast_prereq(), and player_can_study().

bool player_can_cast_prereq ( void  )

Prerequiste function for command.

See struct cmd_info in cmd-process.c.

References player_can_cast().

bool player_can_fire ( struct player p,
bool  show_msg 
)

Return true if the player can fire something with a launcher.

Parameters
pis the player
show_msgshould be set to true if a failure message should be displayed.

References player_state::ammo_tval, equipped_item_by_slot_name(), msg, and player::state.

Referenced by context_menu_cave(), and player_can_fire_prereq().

bool player_can_fire_prereq ( void  )

Prerequiste function for command.

See struct cmd_info in cmd-process.c.

References player_can_fire().

bool player_can_read ( struct player p,
bool  show_msg 
)

Return true if the player can read scrolls or books.

Parameters
pis the player
show_msgshould be set to true if a failure message should be displayed.

References msg, no_light(), and player::timed.

Referenced by context_menu_object(), do_cmd_read_scroll(), and player_can_read_prereq().

bool player_can_read_prereq ( void  )

Prerequiste function for command.

See struct cmd_info in cmd-process.c.

References player_can_read().

bool player_can_refuel ( struct player p,
bool  show_msg 
)

Return true if the player can refuel their light source.

Parameters
pis the player
show_msgshould be set to true if a failure message should be displayed.

References equipped_item_by_slot_name(), object::flags, msg, and of_has.

Referenced by player_can_refuel_prereq().

bool player_can_refuel_prereq ( void  )

Prerequiste function for command.

See struct cmd_info in cmd-process.c.

References player_can_refuel().

bool player_can_study ( struct player p,
bool  show_msg 
)

Return true if the player can study a spell.

Parameters
pis the player
show_msgshould be set to true if a failure message should be displayed.

References player::class, player_class::magic, msg, player_upkeep::new_spells, player_can_cast(), magic_realm::spell_noun, class_magic::spell_realm, and player::upkeep.

Referenced by context_menu_object(), do_cmd_study_book(), do_cmd_study_spell(), and player_can_study_prereq().

bool player_can_study_prereq ( void  )

Prerequiste function for command.

See struct cmd_info in cmd-process.c.

References player_can_study().

int player_check_terrain_damage ( struct player p,
int  y,
int  x 
)

See how much damage the player will take from damaging terrain.

References adjust_dam(), cave, player_state::el_info, player_of_has(), randint1, RANDOMISE, element_info::res_level, square_isfiery(), and player::state.

Referenced by move_player(), and player_take_terrain_damage().

bool player_confuse_dir ( struct player p,
int dp,
bool  too 
)

Apply confusion, if needed, to a direction.

Display a message and return true if direction changes.

References ddd, msg, randint0, and player::timed.

Referenced by do_cmd_alter_aux(), do_cmd_cast(), do_cmd_close(), do_cmd_disarm(), do_cmd_fire(), do_cmd_jump(), do_cmd_open(), do_cmd_run(), do_cmd_throw(), do_cmd_tunnel(), do_cmd_walk(), and use_aux().

int player_get_resting_repeat_count ( struct player p)

Get the number of resting turns to repeat.

Parameters
pThe current player.

References player_resting_repeat_count.

Referenced by do_cmd_rest().

bool player_is_immune ( struct player p,
int  element 
)
bool player_is_resting ( struct player p)

Return true if the player is resting.

References player_resting_is_special(), player_upkeep::resting, and player::upkeep.

Referenced by check_for_player_interrupt(), disturb(), do_cmd_rest(), and prt_state().

bool player_of_has ( struct player p,
int  flag 
)
void player_place ( struct chunk c,
struct player p,
int  y,
int  x 
)
void player_regen_hp ( struct player p)
void player_regen_mana ( struct player p)
bool player_resists ( struct player p,
int  element 
)
bool player_resting_can_regenerate ( struct player p)

Return true if the player should get a regeneration bonus for the current rest.

References player_resting_is_special(), player_turns_rested, REST_REQUIRED_FOR_REGEN, player_upkeep::resting, and player::upkeep.

Referenced by player_regen_hp(), and player_regen_mana().

void player_resting_cancel ( struct player p,
bool  disturb 
)

Cancel current rest.

References disturb(), player_rest_disturb, player_resting_set_count(), and player_turns_rested.

Referenced by disturb(), and do_cmd_rest().

void player_resting_complete_special ( struct player p)
s16b player_resting_count ( struct player p)

Return the remaining number of resting turns.

References player_upkeep::resting, and player::upkeep.

Referenced by do_cmd_rest(), prt_state(), redraw_stuff(), and update_minimap_subwindow().

bool player_resting_is_special ( s16b  count)

Return true if the provided count is one of the conditional REST_ flags.

References REST_ALL_POINTS, REST_COMPLETE, and REST_SOME_POINTS.

Referenced by do_cmd_rest(), player_is_resting(), player_resting_can_regenerate(), player_resting_complete_special(), and player_resting_set_count().

void player_resting_set_count ( struct player p,
s16b  count 
)

Set the number of resting turns.

Parameters
countis the number of turns to rest or one of the REST_ constants.

References player_rest_disturb, player_resting_is_special(), player_upkeep::resting, and player::upkeep.

Referenced by do_cmd_rest(), and player_resting_cancel().

void player_resting_step_turn ( struct player p)

Perform one turn of resting.

This only handles the bookkeeping of resting itself, and does not calculate any possible other effects of resting (see process_world() for regeneration).

References player_upkeep::energy_use, angband_constants::move_energy, player_turns_rested, PR_STATE, player_upkeep::redraw, player_upkeep::resting, player::resting_turn, player::upkeep, and z_info.

Referenced by do_cmd_rest().

void player_set_resting_repeat_count ( struct player p,
s16b  count 
)

Set the number of resting turns to repeat.

Parameters
countis the number of turns requested for rest most recently.

References player_resting_repeat_count.

Referenced by do_cmd_rest().

void player_take_terrain_damage ( struct player p,
int  y,
int  x 
)
void player_update_light ( struct player p)
void search ( struct player p)
void take_hit ( struct player p,
int  dam,
const char *  kb_str 
)