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

Player temporary status structures. More...

#include "player.h"

Go to the source code of this file.

Macros

#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_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_BASIC
 Display Basic Info. More...
 
#define PR_EXTRA   (PR_STATUS | PR_STATE | PR_STUDY)
 Display Extra Info. More...
 
#define PR_SUBWINDOW   (PR_MONSTER | PR_OBJECT | PR_MONLIST | PR_ITEMLIST)
 Display Subwindow Info. More...
 

Functions

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

More...
 
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

More...
 
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...
 

Variables

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
Value:
#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_EXP
Definition: player-calcs.h:54
#define PR_ARMOR
Definition: player-calcs.h:56
#define PR_MANA
Definition: player-calcs.h:58

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_EQUIP   0x00040000L /* Display equip/inven */
#define PR_EXP   0x00000008L /* Display Experience */

Referenced by adjust_level().

#define PR_EXTRA   (PR_STATUS | PR_STATE | PR_STUDY)
#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_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.

#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().

#define PR_SUBWINDOW   (PR_MONSTER | PR_OBJECT | PR_MONLIST | PR_ITEMLIST)

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

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

Calculate the blows a player would get.

Parameters
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, NULL, player_state::stat_ind, and object::weight.

Referenced by calc_bonuses(), and obj_known_blows().

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::body, player_class::c_adj, player_class::c_skills, calc_blows(), calc_mana(), calc_torch(), player::class, player_body::count, player::csp, curse_max, curses, object::curses, 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, player_state::icky_wield, index, player_race::infra, kf_has, object::kind, object_kind::kind_flags, object::known, player::lev, object::modifiers, modify_stat_value(), NULL, player_state::num_blows, player_state::num_shots, curse::obj, 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_has, curse_data::power, object::pval, player_race::r_adj, player_race::r_skills, player::race, element_info::res_level, player_state::see_infra, SKILL_DEVICE, SKILL_DIGGING, SKILL_DISARM_MAGIC, SKILL_DISARM_PHYS, SKILL_MAX, SKILL_SAVE, SKILL_SEARCH, SKILL_STEALTH, 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(), tval_is_pointy(), player::upkeep, object::weight, weight_limit(), and player_class::x_skills.

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

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.

References DIGGING_DOORS, DIGGING_GRANITE, DIGGING_MAGMA, DIGGING_MAX, DIGGING_QUARTZ, DIGGING_RUBBLE, i, MAX, SKILL_DIGGING, and player_state::skills.

Referenced by do_cmd_tunnel_aux(), and obj_known_digging().

void calc_inventory ( struct player_upkeep upkeep,
struct object gear,
struct player_body  body 
)
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.

Returns
whether to replace the original object with the new one

References object_kind::flavor, object::kind, new, obj_can_browse(), object_flavor_is_aware(), object_value(), object::pval, object::sval, object::tval, tval_is_ammo(), and tval_is_light().

Referenced by calc_inventory(), and store_stock_list().

int equipped_item_slot ( struct player_body  body,
struct object obj 
)
void handle_stuff ( struct player p)
void health_track ( struct player_upkeep upkeep,
struct monster mon 
)
void monster_race_track ( struct player_upkeep upkeep,
struct monster_race race 
)
void notice_stuff ( struct player p)
void redraw_stuff ( struct player p)
void track_object ( struct player_upkeep upkeep,
struct object obj 
)
void track_object_cancel ( struct player_upkeep upkeep)

Cancel all object tracking.

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

Referenced by desc_obj_fake().

void track_object_kind ( struct player_upkeep upkeep,
struct object_kind kind 
)

Track the given object kind.

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

Referenced by desc_obj_fake().

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().

void update_stuff ( struct player p)
int weight_remaining ( struct player p)

Variable Documentation

const int adj_con_fix[STAT_RANGE]

Stat Table (CON) – base regeneration rate.

Referenced by decrease_timeouts().

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().

const int adj_str_blow[STAT_RANGE]

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

Referenced by calc_blows(), and do_cmd_throw().

const int adj_str_hold[STAT_RANGE]

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

Referenced by calc_bonuses().