Macros | Functions | Variables
player-calcs.h File Reference

Player temporary status structures. More...

#include "player.h"

Go to the source code of this file.


#define PN_COMBINE   0x00000001L /* Combine the pack */
 Bit flags for the "player->upkeep->notice" variable. More...
#define PN_IGNORE   0x00000002L /* Ignore stuff */
#define PN_MON_MESSAGE   0x00000004L /* flush monster pain messages */
#define PU_BONUS   0x00000001L /* Calculate bonuses */
 Bit flags for the "player->upkeep->update" variable. More...
#define PU_TORCH   0x00000002L /* Calculate torch radius */
#define PU_HP   0x00000004L /* Calculate chp and mhp */
#define PU_MANA   0x00000008L /* Calculate csp and msp */
#define PU_SPELLS   0x00000010L /* Calculate spells */
#define PU_UPDATE_VIEW   0x00000020L /* Update field of view */
#define PU_MONSTERS   0x00000040L /* Update monsters */
#define PU_DISTANCE   0x00000080L /* Update distances */
#define PU_PANEL   0x00000100L /* Update panel */
#define PU_INVEN   0x00000200L /* Update inventory */
#define PR_MISC   0x00000001L /* Display Race/Class */
 Bit flags for the "player->upkeep->redraw" variable. More...
#define PR_TITLE   0x00000002L /* Display Title */
#define PR_LEV   0x00000004L /* Display Level */
#define PR_EXP   0x00000008L /* Display Experience */
#define PR_STATS   0x00000010L /* Display Stats */
#define PR_ARMOR   0x00000020L /* Display Armor */
#define PR_HP   0x00000040L /* Display Hitpoints */
#define PR_MANA   0x00000080L /* Display Mana */
#define PR_GOLD   0x00000100L /* Display Gold */
#define PR_HEALTH   0x00000200L /* Display Health Bar */
#define PR_SPEED   0x00000400L /* Display Extra (Speed) */
#define PR_STUDY   0x00000800L /* Display Extra (Study) */
#define PR_DEPTH   0x00001000L /* Display Depth */
#define PR_STATUS   0x00002000L
#define PR_DTRAP   0x00004000L /* Trap detection indicator */
#define PR_STATE   0x00008000L /* Display Extra (State) */
#define PR_MAP   0x00010000L /* Redraw whole map */
#define PR_INVEN   0x00020000L /* Display inven/equip */
#define PR_EQUIP   0x00040000L /* Display equip/inven */
#define PR_MESSAGE   0x00080000L /* Display messages */
#define PR_MONSTER   0x00100000L /* Display monster recall */
#define PR_OBJECT   0x00200000L /* Display object recall */
#define PR_MONLIST   0x00400000L /* Display monster list */
#define PR_ITEMLIST   0x00800000L /* Display item list */
#define PR_FEELING   0x01000000L /* Display level feeling */
#define PR_LIGHT   0x02000000L /* Display light level */
#define PR_BASIC
 Display Basic Info. More...
 Display Extra Info. More...
 Display Subwindow Info. More...


bool earlier_object (struct object *orig, struct object *new, bool store)
 Decide which object comes earlier in the standard inventory listing, defaulting to the first if nothing separates them. More...
int equipped_item_slot (struct player_body body, struct object *obj)
void calc_inventory (struct player_upkeep *upkeep, struct object *gear, struct player_body body)
 Put the player's inventory and quiver into easily accessible arrays. More...
void calc_bonuses (struct player *p, struct player_state *state, bool known_only, bool update)
 Calculate the players current "state", taking into account not only race/class intrinsics, but also objects being worn and temporary spell effects. More...
void calc_digging_chances (struct player_state *state, int chances[DIGGING_MAX])
 Populates chances with the player's chance of digging through the diggable terrain types in one turn out of 1600. More...
int calc_blows (struct player *p, const struct object *obj, struct player_state *state, int extra_blows)
 Calculate the blows a player would get. More...
void health_track (struct player_upkeep *upkeep, struct monster *mon)

Monster and object tracking functions

void monster_race_track (struct player_upkeep *upkeep, struct monster_race *race)
 Track the given monster race. More...
void track_object (struct player_upkeep *upkeep, struct object *obj)
 Track the given object. More...
void track_object_kind (struct player_upkeep *upkeep, struct object_kind *kind)
 Track the given object kind. More...
void track_object_cancel (struct player_upkeep *upkeep)
 Cancel all object tracking. More...
bool tracked_object_is (struct player_upkeep *upkeep, struct object *obj)
 Is the given item tracked? More...
void notice_stuff (struct player *p)

Generic "deal with" functions

void update_stuff (struct player *p)
 Handle "player->upkeep->update". More...
void redraw_stuff (struct player *p)
 Handle "player->upkeep->redraw". More...
void handle_stuff (struct player *p)
 Handle "player->upkeep->update" and "player->upkeep->redraw". More...
int weight_remaining (struct player *p)
 Computes weight remaining before burdened. More...


const int adj_dex_th [STAT_RANGE]
 Stat Table (DEX) – bonus to hit. More...
const int adj_str_td [STAT_RANGE]
 Stat Table (STR) – bonus to dam. More...
const int adj_str_blow [STAT_RANGE]
 Stat Table (STR) – help index into the "blow" table. More...
const int adj_dex_safe [STAT_RANGE]
 Stat Table (DEX) – chance of avoiding "theft" and "falling". More...
const int adj_con_fix [STAT_RANGE]
 Stat Table (CON) – base regeneration rate. More...
const int adj_str_hold [STAT_RANGE]
 Stat Table (STR) – weapon weight limit in pounds. More...

Detailed Description

Player temporary status structures.

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 PN_COMBINE   0x00000001L /* Combine the pack */


#define PN_IGNORE   0x00000002L /* Ignore stuff */


#define PN_MON_MESSAGE   0x00000004L /* flush monster pain messages */


#define PR_ARMOR   0x00000020L /* Display Armor */

Referenced by inven_wield(), and update_bonuses().


#define PR_BASIC
#define PR_GOLD
Definition: player-calcs.h:59
#define PR_HEALTH
Definition: player-calcs.h:60
#define PR_STATS
Definition: player-calcs.h:55
#define PR_HP
Definition: player-calcs.h:57
#define PR_MISC
Bit flags for the "player->upkeep->redraw" variable.
Definition: player-calcs.h:51
#define PR_LEV
Definition: player-calcs.h:53
#define PR_DEPTH
Definition: player-calcs.h:63
#define PR_TITLE
Definition: player-calcs.h:52
#define PR_SPEED
Definition: player-calcs.h:61
#define PR_ARMOR
Definition: player-calcs.h:56

Display Basic Info.

Referenced by do_cmd_redraw(), do_cmd_wiz_advance(), leave_store(), new_level_display_update(), and target_set_interactive().


#define PR_DEPTH   0x00001000L /* Display Depth */

Referenced by target_set_interactive().


#define PR_DTRAP   0x00004000L /* Trap detection indicator */

Referenced by monster_swap(), and move_player().


#define PR_EQUIP   0x00040000L /* Display equip/inven */


#define PR_EXP   0x00000008L /* Display Experience */

Referenced by adjust_level().




#define PR_FEELING   0x01000000L /* Display level feeling */

Referenced by update_one().


#define PR_GOLD   0x00000100L /* Display Gold */


#define PR_HEALTH   0x00000200L /* Display Health Bar */


#define PR_HP   0x00000040L /* Display Hitpoints */


#define PR_INVEN   0x00020000L /* Display inven/equip */


#define PR_ITEMLIST   0x00800000L /* Display item list */


#define PR_LEV   0x00000004L /* Display Level */

Referenced by adjust_level().


#define PR_LIGHT   0x02000000L /* Display light level */

Referenced by calc_lighting().


#define PR_MANA   0x00000080L /* Display Mana */


#define PR_MAP   0x00010000L /* Redraw whole map */


#define PR_MESSAGE   0x00080000L /* Display messages */


#define PR_MISC   0x00000001L /* Display Race/Class */

Bit flags for the "player->upkeep->redraw" variable.

Referenced by effect_handler_SHAPECHANGE(), and player_resume_normal_shape().


#define PR_MONLIST   0x00400000L /* Display monster list */


#define PR_MONSTER   0x00100000L /* Display monster recall */


#define PR_OBJECT   0x00200000L /* Display object recall */


#define PR_SPEED   0x00000400L /* Display Extra (Speed) */

Referenced by inven_wield(), and update_bonuses().


#define PR_STATE   0x00008000L /* Display Extra (State) */


#define PR_STATS   0x00000010L /* Display Stats */


#define PR_STATUS   0x00002000L


#define PR_STUDY   0x00000800L /* Display Extra (Study) */

Referenced by calc_spells(), and spell_learn().



Display Subwindow Info.

Referenced by redraw_stuff().


#define PR_TITLE   0x00000002L /* Display Title */


#define PU_BONUS   0x00000001L /* Calculate bonuses */


#define PU_DISTANCE   0x00000080L /* Update distances */


#define PU_HP   0x00000004L /* Calculate chp and mhp */


#define PU_INVEN   0x00000200L /* Update inventory */


#define PU_MANA   0x00000008L /* Calculate csp and msp */


#define PU_MONSTERS   0x00000040L /* Update monsters */


#define PU_PANEL   0x00000100L /* Update panel */


#define PU_SPELLS   0x00000010L /* Calculate spells */


#define PU_TORCH   0x00000002L /* Calculate torch radius */


#define PU_UPDATE_VIEW   0x00000020L /* Update field of view */

Function Documentation

◆ calc_blows()

int calc_blows ( struct player p,
const struct object obj,
struct player_state state,
int  extra_blows 

Calculate the blows a player would get.

objis the object for which we are calculating blows
stateis the player state for which we are calculating blows
extra_blowsis the number of +blows available from this object and this state

N.B. state->num_blows is now 100x the number of blows.

References adj_dex_blow, adj_str_blow, player_class::att_multiply, blows_table, player::class, MAX, player_class::max_attacks, MIN, player_class::min_weight, OPT, player_state::stat_ind, and object::weight.

Referenced by calc_bonuses().

◆ calc_bonuses()

void calc_bonuses ( struct player p,
struct player_state state,
bool  known_only,
bool  update 

Calculate the players current "state", taking into account not only race/class intrinsics, but also objects being worn and temporary spell effects.

See also calc_mana() and calc_hitpoints().

Take note of the new "speed code", in particular, a very strong player will start slowing down as soon as he reaches 150 pounds, but not until he reaches 450 pounds will he be half as fast as a normal kobold. This both hurts and helps the player, hurts because in the old days a player could just avoid 300 pounds, and helps because now carrying 300 pounds is not very painful.

The "weapon" and "bow" do not add to the bonuses to hit or to damage, since that would affect non-combat things. These values are actually added in later, at the appropriate place.

If known_only is true, calc_bonuses() will only use the known information of objects; thus it returns what the player knows the character state to be.

References player_state::ac, object::ac, adj_dex_dis, adj_dex_ta, adj_dex_th, adj_int_dev, adj_int_dis, adj_str_dig, adj_str_hold, adj_str_td, adj_str_th, adj_wis_sav, player_state::ammo_mult, player_state::ammo_tval, player_state::bless_wield, player::body, player_class::c_adj, player_class::c_skills, calc_blows(), calc_light(), calc_mana(), calc_shapechange(), character_dungeon, player::class, player_body::count, curse_max, curses, object::curses, player_state::dam_red, player_race::el_info, player_state::el_info, object::el_info, ELEM_MAX, equipped_item_by_slot_name(), player_state::flags, object::flags, player_state::heavy_shoot, player_state::heavy_wield, i, index, player_race::infra, kf_has, object::kind, object_kind::kind_flags, object::known, player::lev, MAX, MIN, object::modifiers, modify_stat_value(), player::msp, player_state::num_blows, player_state::num_moves, player_state::num_shots, curse::obj, player::obj_k, object_flags(), object_flags_known(), of_has, of_on, OF_SIZE, of_union, pf_copy, pf_on, pf_union, pf_wipe, player_race::pflags, player_class::pflags, player_state::pflags, player_flags(), player_flags_timed(), player_has, player_timed_grade_eq(), curse_data::power, object::pval, PY_FOOD_FULL, PY_FOOD_HUNGRY, PY_FOOD_MAX, player_race::r_adj, player_race::r_skills, player::race, element_info::res_level, player_state::see_infra, player::shape, SKILL_DEVICE, SKILL_DIGGING, SKILL_DISARM_MAGIC, SKILL_DISARM_PHYS, SKILL_MAX, SKILL_SAVE, SKILL_SEARCH, SKILL_STEALTH, SKILL_TO_HIT_MELEE, player_state::skills, slot_object(), slot_type_is(), player_state::speed, player_state::stat_add, player::stat_cur, player_state::stat_ind, STAT_MAX, player::stat_max, STAT_RANGE, player_state::stat_top, player_state::stat_use, player::timed, player_state::to_a, object::to_a, player_state::to_d, object::to_d, player_state::to_h, object::to_h, player_upkeep::total_weight, tval_is_digger(), player::upkeep, object::weight, weight_limit(), and player_class::x_skills.

Referenced by do_cmd_tunnel_aux(), o_obj_known_damage(), obj_known_blows(), obj_known_damage(), obj_known_digging(), obj_known_misc_combat(), and update_bonuses().

◆ calc_digging_chances()

void calc_digging_chances ( struct player_state state,
int  chances[DIGGING_MAX] 

Populates chances with the player's chance of digging through the diggable terrain types in one turn out of 1600.


Referenced by do_cmd_tunnel_aux(), and obj_known_digging().

◆ calc_inventory()

void calc_inventory ( struct player_upkeep upkeep,
struct object gear,
struct player_body  body 

◆ earlier_object()

bool earlier_object ( struct object orig,
struct object new,
bool  store 

Decide which object comes earlier in the standard inventory listing, defaulting to the first if nothing separates them.

whether to replace the original object with the new one

References player_state::ammo_tval, object_kind::flavor, object::kind, obj_can_browse(), object_flavor_is_aware(), object_value(), object::pval, player::state, object::sval, object::tval, tval_is_ammo(), and tval_is_light().

Referenced by calc_inventory(), and store_stock_list().

◆ equipped_item_slot()

int equipped_item_slot ( struct player_body  body,
struct object obj 

◆ handle_stuff()

void handle_stuff ( struct player p)

◆ health_track()

void health_track ( struct player_upkeep upkeep,
struct monster mon 

◆ monster_race_track()

void monster_race_track ( struct player_upkeep upkeep,
struct monster_race race 

◆ notice_stuff()

void notice_stuff ( struct player p)

◆ redraw_stuff()

void redraw_stuff ( struct player p)

◆ track_object()

void track_object ( struct player_upkeep upkeep,
struct object obj 

◆ track_object_cancel()

void track_object_cancel ( struct player_upkeep upkeep)

Cancel all object tracking.

References player_upkeep::object, player_upkeep::object_kind, PR_OBJECT, and player_upkeep::redraw.

Referenced by desc_obj_fake().

◆ track_object_kind()

void track_object_kind ( struct player_upkeep upkeep,
struct object_kind kind 

Track the given object kind.

References player_upkeep::object, player_upkeep::object_kind, PR_OBJECT, and player_upkeep::redraw.

Referenced by desc_obj_fake().

◆ tracked_object_is()

bool tracked_object_is ( struct player_upkeep upkeep,
struct object obj 

Is the given item tracked?

References player_upkeep::object.

Referenced by floor_object_for_use(), and gear_object_for_use().

◆ update_stuff()

void update_stuff ( struct player p)

◆ weight_remaining()

int weight_remaining ( struct player p)

Variable Documentation

◆ adj_con_fix

const int adj_con_fix[STAT_RANGE]

Stat Table (CON) – base regeneration rate.

Referenced by decrease_timeouts().

◆ adj_dex_safe

const int adj_dex_safe[STAT_RANGE]

Stat Table (DEX) – chance of avoiding "theft" and "falling".

Referenced by blow_color(), melee_effect_handler_EAT_GOLD(), and melee_effect_handler_EAT_ITEM().

◆ adj_dex_th

const int adj_dex_th[STAT_RANGE]

Stat Table (DEX) – bonus to hit.

Referenced by attempt_shield_bash(), calc_bonuses(), and steal_monster_item().

◆ adj_str_blow

const int adj_str_blow[STAT_RANGE]

Stat Table (STR) – help index into the "blow" table.

Referenced by calc_blows(), and do_cmd_throw().

◆ adj_str_hold

const int adj_str_hold[STAT_RANGE]

Stat Table (STR) – weapon weight limit in pounds.

Referenced by calc_bonuses().

◆ adj_str_td

const int adj_str_td[STAT_RANGE]

Stat Table (STR) – bonus to dam.

Referenced by attempt_shield_bash(), and calc_bonuses().