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

Player implementation. More...

#include "guid.h"
#include "obj-properties.h"
#include "object.h"
#include "option.h"
#include "list-stats.h"
#include "list-player-flags.h"

Go to the source code of this file.

Data Structures

struct  quest
 Structure for the "quests". More...
 
struct  equip_slot
 A single equipment slot. More...
 
struct  player_body
 A player 'body'. More...
 
struct  player_race
 Player race info. More...
 
struct  start_item
 Items the player starts with. More...
 
struct  magic_realm
 Structure for magic realms. More...
 
struct  class_spell
 A structure to hold class-dependent information on spells. More...
 
struct  class_book
 A structure to hold class-dependent information on spell books. More...
 
struct  class_magic
 Information about class magic knowledge. More...
 
struct  player_class
 Player class info. More...
 
struct  history_entry
 Histories are a graph of charts; each chart contains a set of individual entries for that chart, and each entry contains a text description and a successor chart to move history generation to. More...
 
struct  history_chart
 
struct  player_history
 Player history information. More...
 
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...
 
struct  player
 Most of the "player" information goes here. More...
 

Macros

#define STAT(a)   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_inter(f1, f2)   flag_inter(f1, f2, PF_SIZE)
 
#define pf_diff(f1, f2)   flag_diff(f1, f2, PF_SIZE)
 
#define player_has(p, flag)   (pf_has(p->race->pflags, (flag)) || pf_has(p->class->pflags, (flag)))
 
#define STAT_RANGE   38
 The range of possible indexes into tables based upon stats. More...
 
#define PY_MAX_EXP   99999999L /* Maximum exp */
 Player constants. More...
 
#define PY_KNOW_LEVEL   30 /* Level to know all runes */
 
#define PY_MAX_LEVEL   50 /* Maximum level */
 
#define PY_SPELL_LEARNED   0x01 /* Spell has been learned */
 Flags for player.spell_flags[]. More...
 
#define PY_SPELL_WORKED   0x02 /* Spell has been successfully tried */
 
#define PY_SPELL_FORGOTTEN   0x04 /* Spell has been forgotten */
 
#define BTH_PLUS_ADJ   3 /* Adjust BTH per plus-to-hit */
 
#define NOSCORE_WIZARD   0x0002
 Ways in which players can be marked as cheaters. More...
 
#define NOSCORE_DEBUG   0x0008
 
#define NOSCORE_JUMPING   0x0010
 

Enumerations

enum  { STAT_MAX }
 Indexes of the player stats (hard-coded by savefiles). More...
 
enum  { PF_MAX }
 Player race and class flags. More...
 
enum  {
  DIGGING_RUBBLE = 0, DIGGING_MAGMA, DIGGING_QUARTZ, DIGGING_GRANITE,
  DIGGING_DOORS, DIGGING_MAX
}
 Terrain that the player has a chance of digging through. More...
 
enum  {
  SKILL_DISARM_PHYS, SKILL_DISARM_MAGIC, SKILL_DEVICE, SKILL_SAVE,
  SKILL_SEARCH, SKILL_STEALTH, SKILL_TO_HIT_MELEE, SKILL_TO_HIT_BOW,
  SKILL_TO_HIT_THROW, SKILL_DIGGING, SKILL_MAX
}
 Skill indexes. More...
 

Functions

struct player_classplayer_id2class (guid id)
 
int stat_name_to_idx (const char *name)
 
const char * stat_idx_to_name (int type)
 
const struct magic_realmlookup_realm (const char *code)
 
bool player_stat_inc (struct player *p, int stat)
 
bool player_stat_dec (struct player *p, int stat, bool permanent)
 
void player_exp_gain (struct player *p, s32b amount)
 
void player_exp_lose (struct player *p, s32b amount, bool permanent)
 
void player_flags (struct player *p, bitflag f[OF_SIZE])
 Obtain object flags for the player. More...
 
byte player_hp_attr (struct player *p)
 
byte player_sp_attr (struct player *p)
 
bool player_restore_mana (struct player *p, int amt)
 
void player_safe_name (char *safe, size_t safelen, const char *name, bool strip_suffix)
 Return a version of the player's name safe for use in filesystems. More...
 
struct player_raceplayer_id2race (guid id)
 

Variables

struct player_bodybodies
 

Externs

More...
 
struct player_raceraces
 
struct player_classclasses
 
struct magic_realmrealms
 
const s32b player_exp [PY_MAX_LEVEL]
 Base experience levels, may be adjusted up for race and/or class. More...
 
struct playerplayer
 Pointer to the player struct. More...
 

Detailed Description

Player implementation.

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke Copyright (c) 2011 elly+.nosp@m.angb.nosp@m.and@l.nosp@m.epto.nosp@m.quark.nosp@m..net. See COPYING. Copyright (c) 2015 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 BTH_PLUS_ADJ   3 /* Adjust BTH per plus-to-hit */
#define NOSCORE_DEBUG   0x0008

Referenced by enter_score(), and textui_cmd_debug().

#define NOSCORE_JUMPING   0x0010

Referenced by choose_profile(), and do_cmd_wiz_jump().

#define NOSCORE_WIZARD   0x0002

Ways in which players can be marked as cheaters.

Referenced by do_cmd_wizard(), enter_score(), savefile_load(), and wiz_cheat_death().

#define PF (   a,
  b,
 
)    PF_##a,
#define pf_copy (   f1,
  f2 
)    flag_copy(f1, f2, PF_SIZE)

Referenced by calc_bonuses(), and remove_bad_spells().

#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 (   p,
  flag 
)    (pf_has(p->race->pflags, (flag)) || pf_has(p->class->pflags, (flag)))
#define PY_KNOW_LEVEL   30 /* Level to know all runes */
#define PY_MAX_EXP   99999999L /* Maximum exp */

Player constants.

Referenced by adjust_level(), do_cmd_wiz_advance(), and effect_handler_GAIN_EXP().

#define PY_MAX_LEVEL   50 /* Maximum level */
#define PY_SPELL_FORGOTTEN   0x04 /* Spell has been forgotten */

Referenced by calc_spells(), and spell_menu_display().

#define PY_SPELL_LEARNED   0x01 /* Spell has been learned */
#define PY_SPELL_WORKED   0x02 /* Spell has been successfully tried */

Referenced by spell_cast(), and spell_menu_display().

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

Enumeration Type Documentation

anonymous enum

Indexes of the player stats (hard-coded by savefiles).

Enumerator
STAT_MAX 
anonymous enum

Player race and class flags.

Enumerator
PF_MAX 
anonymous enum

Terrain that the player has a chance of digging through.

Enumerator
DIGGING_RUBBLE 
DIGGING_MAGMA 
DIGGING_QUARTZ 
DIGGING_GRANITE 
DIGGING_DOORS 
DIGGING_MAX 
anonymous enum

Skill indexes.

Enumerator
SKILL_DISARM_PHYS 
SKILL_DISARM_MAGIC 
SKILL_DEVICE 
SKILL_SAVE 
SKILL_SEARCH 
SKILL_STEALTH 
SKILL_TO_HIT_MELEE 
SKILL_TO_HIT_BOW 
SKILL_TO_HIT_THROW 
SKILL_DIGGING 
SKILL_MAX 

Function Documentation

const struct magic_realm* lookup_realm ( const char *  code)
void player_exp_gain ( struct player p,
s32b  amount 
)
void player_exp_lose ( struct player p,
s32b  amount,
bool  permanent 
)
void player_flags ( struct player p,
bitflag  f[OF_SIZE] 
)

Obtain object flags for the player.

References player_race::flags, player::lev, of_on, player_has, and player::race.

Referenced by calc_bonuses(), display_player_sust_info(), and display_resistance_panel().

byte player_hp_attr ( struct player p)
struct player_class* player_id2class ( guid  id)
struct player_race* player_id2race ( guid  id)
bool player_restore_mana ( struct player p,
int  amt 
)
void player_safe_name ( char *  safe,
size_t  safelen,
const char *  name,
bool  strip_suffix 
)

Return a version of the player's name safe for use in filesystems.

XXX This does not belong here.

References find_roman_suffix_start(), i, MIN, my_strcpy(), and suffix().

Referenced by death_file(), do_cmd_change_name(), do_cmd_pref_file_hack(), get_pref_path(), process_character_pref_files(), and savefile_set_name().

byte player_sp_attr ( struct player p)
bool player_stat_dec ( struct player p,
int  stat,
bool  permanent 
)
bool player_stat_inc ( struct player p,
int  stat 
)
const char* stat_idx_to_name ( int  type)

References STAT_MAX, stat_name_list, and type.

int stat_name_to_idx ( const char *  name)

References i, my_stricmp(), and stat_name_list.

Referenced by effect_param(), and parse_realm_stat().

Variable Documentation

struct player_body* bodies
struct player_class* classes
struct player* player

Pointer to the player struct.

const s32b player_exp[PY_MAX_LEVEL]

Base experience levels, may be adjusted up for race and/or class.

Referenced by adjust_level(), prt_exp(), and show_adv_exp().

struct player_race* races
struct magic_realm* realms