Angband
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
player-calcs.h File Reference

Player temporary status structures. More...

#include "list-stats.h"
#include "list-player-flags.h"

Go to the source code of this file.

Data Structures

struct  equip_slot
struct  player_body
struct  player_state
 All the variable state that changes when you put on/take off equipment. More...
struct  player_upkeep
 Temporary, derived, player-related variables used during play but not saved. More...

Macros

#define STAT(a, b, c, d, e, f, g, h)   STAT_##a,
#define PF(a, b, c)   PF_##a,
#define PF_SIZE   FLAG_SIZE(PF_MAX)
#define pf_has(f, flag)   flag_has_dbg(f, PF_SIZE, flag, #f, #flag)
#define pf_next(f, flag)   flag_next(f, PF_SIZE, flag)
#define pf_is_empty(f)   flag_is_empty(f, PF_SIZE)
#define pf_is_full(f)   flag_is_full(f, PF_SIZE)
#define pf_is_inter(f1, f2)   flag_is_inter(f1, f2, PF_SIZE)
#define pf_is_subset(f1, f2)   flag_is_subset(f1, f2, PF_SIZE)
#define pf_is_equal(f1, f2)   flag_is_equal(f1, f2, PF_SIZE)
#define pf_on(f, flag)   flag_on_dbg(f, PF_SIZE, flag, #f, #flag)
#define pf_off(f, flag)   flag_off(f, PF_SIZE, flag)
#define pf_wipe(f)   flag_wipe(f, PF_SIZE)
#define pf_setall(f)   flag_setall(f, PF_SIZE)
#define pf_negate(f)   flag_negate(f, PF_SIZE)
#define pf_copy(f1, f2)   flag_copy(f1, f2, PF_SIZE)
#define pf_union(f1, f2)   flag_union(f1, f2, PF_SIZE)
#define pf_comp_union(f1, f2)   flag_comp_union(f1, f2, PF_SIZE)
#define pf_inter(f1, f2)   flag_inter(f1, f2, PF_SIZE)
#define pf_diff(f1, f2)   flag_diff(f1, f2, PF_SIZE)
#define player_has(flag)   (pf_has(player->race->pflags, (flag)) || pf_has(player->class->pflags, (flag)))
#define PN_COMBINE   0x00000001L /* Combine the pack */
#define PN_IGNORE   0x00000008L /* Ignore stuff */
#define PN_MON_MESSAGE   0x00000010L /* flush monster pain messages */
#define PU_BONUS   0x00000001L /* Calculate bonuses */
#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_FORGET_VIEW   0x00000020L /* Forget field of view */
#define PU_UPDATE_VIEW   0x00000040L /* Update field of view */
#define PU_FORGET_FLOW   0x00000080L /* Forget flow data */
#define PU_UPDATE_FLOW   0x00000100L /* Update flow data */
#define PU_MONSTERS   0x00000200L /* Update monsters */
#define PU_DISTANCE   0x00000400L /* Update distances */
#define PU_PANEL   0x00000800L /* Update panel */
#define PU_INVEN   0x00001000L /* Update inventory */
#define PR_MISC   0x00000001L /* Display Race/Class */
#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   0x00010000L /* 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_BASIC
#define PR_EXTRA   (PR_STATUS | PR_STATE | PR_STUDY)
#define STAT_RANGE   38
 The range of possible indexes into tables based upon stats.

Typedefs

typedef struct player_state player_state
 All the variable state that changes when you put on/take off equipment.
typedef struct player_upkeep player_upkeep
 Temporary, derived, player-related variables used during play but not saved.

Enumerations

enum  { STAT_MAX }
 Indexes of the various "stats" (hard-coded by savefiles, etc). More...
enum  { PF_MAX }
 Player race and class flags. More...
enum  {
  SKILL_DISARM, SKILL_DEVICE, SKILL_SAVE, SKILL_STEALTH,
  SKILL_SEARCH, SKILL_SEARCH_FREQUENCY, SKILL_TO_HIT_MELEE, SKILL_TO_HIT_BOW,
  SKILL_TO_HIT_THROW, SKILL_DIGGING, SKILL_MAX
}
 Skill indexes. More...
enum  {
  DIGGING_RUBBLE = 0, DIGGING_MAGMA, DIGGING_QUARTZ, DIGGING_GRANITE,
  DIGGING_DOORS, DIGGING_MAX
}

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.
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.
void calc_bonuses (object_type inventory[], player_state *state, bool known_only)
void calc_digging_chances (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.
int calc_blows (const object_type *o_ptr, player_state *state, int extra_blows)
 Calculate the blows a player would get.
void health_track (struct player_upkeep *upkeep, struct monster *m_ptr)
 

Monster and object tracking functions


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

Generic "deal with" functions


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

Variables

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

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 PF (   a,
  b,
 
)    PF_##a,
#define pf_comp_union (   f1,
  f2 
)    flag_comp_union(f1, f2, PF_SIZE)
#define pf_copy (   f1,
  f2 
)    flag_copy(f1, f2, PF_SIZE)

Referenced by calc_bonuses().

#define pf_diff (   f1,
  f2 
)    flag_diff(f1, f2, PF_SIZE)
#define pf_has (   f,
  flag 
)    flag_has_dbg(f, PF_SIZE, flag, #f, #flag)
#define pf_inter (   f1,
  f2 
)    flag_inter(f1, f2, PF_SIZE)
#define pf_is_empty (   f)    flag_is_empty(f, PF_SIZE)

Referenced by remove_bad_spells().

#define pf_is_equal (   f1,
  f2 
)    flag_is_equal(f1, f2, PF_SIZE)
#define pf_is_full (   f)    flag_is_full(f, PF_SIZE)
#define pf_is_inter (   f1,
  f2 
)    flag_is_inter(f1, f2, PF_SIZE)
#define pf_is_subset (   f1,
  f2 
)    flag_is_subset(f1, f2, PF_SIZE)
#define pf_negate (   f)    flag_negate(f, PF_SIZE)
#define pf_next (   f,
  flag 
)    flag_next(f, PF_SIZE, flag)
#define pf_off (   f,
  flag 
)    flag_off(f, PF_SIZE, flag)
#define pf_on (   f,
  flag 
)    flag_on_dbg(f, PF_SIZE, flag, #f, #flag)

Referenced by calc_bonuses().

#define pf_setall (   f)    flag_setall(f, PF_SIZE)
#define PF_SIZE   FLAG_SIZE(PF_MAX)
#define pf_union (   f1,
  f2 
)    flag_union(f1, f2, PF_SIZE)

Referenced by calc_bonuses().

#define pf_wipe (   f)    flag_wipe(f, PF_SIZE)

Referenced by calc_bonuses(), and remove_bad_spells().

#define player_has (   flag)    (pf_has(player->race->pflags, (flag)) || pf_has(player->class->pflags, (flag)))
#define PN_COMBINE   0x00000001L /* Combine the pack */
#define PN_IGNORE   0x00000008L /* Ignore stuff */
#define PN_MON_MESSAGE   0x00000010L /* flush monster pain messages */
#define PR_ARMOR   0x00000020L /* Display Armor */

Referenced by update_bonuses().

#define PR_BASIC
#define PR_DEPTH   0x00001000L /* Display Depth */

Referenced by target_set_interactive().

#define PR_DTRAP   0x00004000L /* Trap detection indicator */
#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_GOLD   0x00000100L /* Display Gold */
#define PR_HEALTH   0x00000200L /* Display Health Bar */
#define PR_HP   0x00000040L /* Display Hitpoints */
#define PR_INVEN   0x00010000L /* 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 */
#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) */
#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_TITLE   0x00000002L /* Display Title */
#define PU_BONUS   0x00000001L /* Calculate bonuses */
#define PU_DISTANCE   0x00000400L /* Update distances */
#define PU_FORGET_FLOW   0x00000080L /* Forget flow data */
#define PU_FORGET_VIEW   0x00000020L /* Forget field of view */
#define PU_HP   0x00000004L /* Calculate chp and mhp */
#define PU_INVEN   0x00001000L /* Update inventory */
#define PU_MANA   0x00000008L /* Calculate csp and msp */
#define PU_MONSTERS   0x00000200L /* Update monsters */
#define PU_PANEL   0x00000800L /* Update panel */

Referenced by monster_swap(), and update_stuff().

#define PU_SPELLS   0x00000010L /* Calculate spells */
#define PU_TORCH   0x00000002L /* Calculate torch radius */
#define PU_UPDATE_FLOW   0x00000100L /* Update flow data */
#define PU_UPDATE_VIEW   0x00000040L /* Update field of view */
#define STAT (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h 
)    STAT_##a,
#define STAT_RANGE   38

The range of possible indexes into tables based upon stats.

Currently things range from 3 to 18/220 = 40.

Referenced by calc_bonuses(), and obj_known_blows().

Typedef Documentation

typedef struct player_state player_state

All the variable state that changes when you put on/take off equipment.

Player flags are not currently variable, but useful here so monsters can learn them.

typedef struct player_upkeep player_upkeep

Temporary, derived, player-related variables used during play but not saved.

Some of these probably should go to the UI

Enumeration Type Documentation

anonymous enum

Indexes of the various "stats" (hard-coded by savefiles, etc).

Enumerator:
STAT_MAX 
anonymous enum

Player race and class flags.

Enumerator:
PF_MAX 
anonymous enum

Skill indexes.

Enumerator:
SKILL_DISARM 
SKILL_DEVICE 
SKILL_SAVE 
SKILL_STEALTH 
SKILL_SEARCH 
SKILL_SEARCH_FREQUENCY 
SKILL_TO_HIT_MELEE 
SKILL_TO_HIT_BOW 
SKILL_TO_HIT_THROW 
SKILL_DIGGING 
SKILL_MAX 
anonymous enum
Enumerator:
DIGGING_RUBBLE 
DIGGING_MAGMA 
DIGGING_QUARTZ 
DIGGING_GRANITE 
DIGGING_DOORS 
DIGGING_MAX 

Function Documentation

int calc_blows ( const object_type o_ptr,
player_state state,
int  extra_blows 
)

Calculate the blows a player would get.

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

Referenced by calc_bonuses(), and obj_known_blows().

void calc_bonuses ( object_type  inventory[],
player_state state,
bool  known_only 
)
void calc_digging_chances ( 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::cost, FALSE, object::kind, obj_can_browse(), object_flavor_is_aware(), object_is_known(), object::pval, object::sval, TRUE, object::tval, 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_upkeep upkeep)
void health_track ( struct player_upkeep upkeep,
struct monster m_ptr 
)
void monster_race_track ( struct player_upkeep upkeep,
struct monster_race race 
)
void notice_stuff ( struct player_upkeep upkeep)
void redraw_stuff ( struct player_upkeep upkeep)
void track_object ( struct player_upkeep upkeep,
struct object obj 
)
void track_object_kind ( struct player_upkeep upkeep,
struct object_kind kind 
)

Track the given object kind.

References object::kind, 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 gear_object_for_use().

void update_stuff ( struct player_upkeep upkeep)
int weight_remaining ( void  )

Variable Documentation

const byte adj_con_fix[STAT_RANGE]

Stat Table (CON) – base regeneration rate.

Referenced by decrease_timeouts().

const byte adj_dex_safe[STAT_RANGE]

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

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

const byte adj_str_blow[STAT_RANGE]

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

Referenced by calc_blows(), and do_cmd_throw().

const byte adj_str_hold[STAT_RANGE]

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

Referenced by calc_bonuses().