Angband
player.h
Go to the documentation of this file.
1 
21 #ifndef PLAYER_H
22 #define PLAYER_H
23 
24 #include "guid.h"
25 #include "obj-properties.h"
26 #include "object.h"
27 #include "option.h"
28 #include "player-calcs.h"
29 
30 
37 #define PY_MAX_EXP 99999999L /* Maximum exp */
38 #define PY_MAX_LEVEL 50 /* Maximum level */
39 
43 #define PY_SPELL_LEARNED 0x01 /* Spell has been learned */
44 #define PY_SPELL_WORKED 0x02 /* Spell has been successfully tried */
45 #define PY_SPELL_FORGOTTEN 0x04 /* Spell has been forgotten */
46 
47 #define BTH_PLUS_ADJ 3 /* Adjust BTH per plus-to-hit */
48 
52 enum
53 {
54  #define REALM(a, b, c, d, e, f) REALM_##a,
55  #include "list-magic-realms.h"
56  #undef REALM
57  REALM_MAX
58 };
59 
63 #define NOSCORE_WIZARD 0x0002
64 #define NOSCORE_DEBUG 0x0008
65 #define NOSCORE_JUMPING 0x0010
66 
67 extern struct player_body *bodies;
68 
69 
78 struct quest
79 {
80  struct quest *next;
82  char *name;
83  byte level; /* Dungeon level */
84  struct monster_race *race; /* Monster race */
85  int cur_num; /* Number killed (unused) */
86  int max_num; /* Number required (unused) */
87 };
88 
100 typedef struct player {
101  s16b py; /* Player location */
102  s16b px; /* Player location */
103 
104  const struct player_race *race;
105  const struct player_class *class;
106 
107  byte hitdie; /* Hit dice (sides) */
108  byte expfact; /* Experience factor */
109 
110  s16b age; /* Characters age */
111  s16b ht; /* Height */
112  s16b wt; /* Weight */
113 
114  s32b au; /* Current Gold */
115 
116  s16b max_depth; /* Max depth */
117  s16b depth; /* Cur depth */
118 
119  s16b max_lev; /* Max level */
120  s16b lev; /* Cur level */
121 
122  s32b max_exp; /* Max experience */
123  s32b exp; /* Cur experience */
124  u16b exp_frac; /* Cur exp frac (times 2^16) */
125 
126  s16b mhp; /* Max hit pts */
127  s16b chp; /* Cur hit pts */
128  u16b chp_frac; /* Cur hit frac (times 2^16) */
129 
130  s16b msp; /* Max mana pts */
131  s16b csp; /* Cur mana pts */
132  u16b csp_frac; /* Cur mana frac (times 2^16) */
133 
134  s16b stat_max[STAT_MAX]; /* Current "maximal" stat values */
135  s16b stat_cur[STAT_MAX]; /* Current "natural" stat values */
136 
137  s16b *timed; /* Timed effects */
138 
139  s16b word_recall; /* Word of recall counter */
140  s16b deep_descent; /* Deep Descent counter */
141 
142  s16b energy; /* Current energy */
143  u32b total_energy; /* Total energy used (including resting) */
144  u32b resting_turn; /* Number of player turns spent resting */
145 
146  s16b food; /* Current nutrition */
147 
148  byte confusing; /* Glowing hands */
149  byte searching; /* Currently searching */
150  byte unignoring; /* Unignoring */
151 
152  byte *spell_flags; /* Spell flags */
153  byte *spell_order; /* Spell order */
154 
155  s16b player_hp[PY_MAX_LEVEL]; /* HP Array */
156 
157  char died_from[80]; /* Cause of death */
158  char *history; /* Player history */
159  struct quest *quests; /* Quest history */
160  u16b total_winner; /* Total winner */
161 
162  u16b noscore; /* Cheating flags */
163 
164  bool is_dead; /* Player is dead */
165 
166  bool wizard; /* Player is in wizard mode */
167 
168  /* Generation fields (for quick start) */
169  s32b au_birth; /* Birth gold when option birth_money is false */
170  s16b stat_birth[STAT_MAX]; /* Birth "natural" stat values */
171  s16b ht_birth; /* Birth Height */
172  s16b wt_birth; /* Birth Weight */
173 
174  /* Variable and calculatable player state */
177 
178  /* Tracking of various temporary player-related values */
180 
181  /* Real gear */
182  struct object *gear;
183  /* Known gear */
184  struct object *gear_k;
185 
187 } player_type;
188 
189 
190 
194 struct player_race {
195  struct player_race *next;
196  const char *name;
197 
198  unsigned int ridx;
199 
200  int r_adj[STAT_MAX]; /* Racial stat bonuses */
201 
202  int r_skills[SKILL_MAX]; /* racial skills */
203 
204  int r_mhp; /* Race hit-dice modifier */
205  int r_exp; /* Race experience factor */
206 
207  int b_age; /* base age */
208  int m_age; /* mod age */
209 
210  int base_hgt; /* base height */
211  int mod_hgt; /* mod height */
212  int base_wgt; /* base weight */
213  int mod_wgt; /* mod weight */
214 
215  int infra; /* Infra-vision range */
216 
217  int body; /* Race body */
219 
220  bitflag flags[OF_SIZE]; /* Racial (object) flags */
221  bitflag pflags[PF_SIZE]; /* Racial (player) flags */
222 
223  struct element_info el_info[ELEM_MAX]; /* Racial resists */
224 };
225 
226 extern struct player_race *races;
227 
232 struct start_item {
234  int min; /* Minimum starting amount */
235  int max; /* Maximum starting amount */
236 
237  struct start_item *next;
238 };
239 
240 
244 struct magic_realm {
245  int index;
246  int stat;
247  const char *verb;
248  const char *spell_noun;
249  const char *book_noun;
250  const char *adjective;
251 };
252 
253 extern struct magic_realm realms[REALM_MAX];
254 
258 typedef struct {
259  char *name;
260  char *text;
261 
262  struct effect *effect;
264  int sidx;
265  int bidx;
266  int slevel;
267  int smana;
268  int sfail;
269  int sexp;
270 } class_spell;
271 
272 
276 typedef struct {
277  int tval;
278  int sval;
279  int realm;
282 } class_book;
283 
284 
288 typedef struct {
292  int num_books;
295 } class_magic;
296 
297 
301 typedef struct player_class {
303  const char *name;
304  unsigned int cidx;
305 
306  const char *title[10]; /* Titles */
307 
308  int c_adj[STAT_MAX]; /* Class stat modifier */
309 
310  int c_skills[SKILL_MAX]; /* class skills */
311  int x_skills[SKILL_MAX]; /* extra skills */
312 
313  int c_mhp; /* Class hit-dice adjustment */
314  int c_exp; /* Class experience factor */
315 
316  bitflag pflags[PF_SIZE]; /* Class (player) flags */
317 
318  int max_attacks; /* Maximum possible attacks */
319  int min_weight; /* Minimum weapon weight for calculations */
320  int att_multiply; /* Multiplier for attack calculations */
321 
322  int sense_base; /* Base pseudo-id value */
323  int sense_div; /* Pseudo-id divisor */
324 
325  struct start_item *start_items; /* Starting inventory */
326 
327  class_magic magic; /* Magic spells */
328 } player_class;
329 
330 extern struct player_class *classes;
331 
358  int isucc;
359  int roll;
360  char *text;
361 };
362 
366  unsigned int idx;
367 };
368 
375 typedef struct {
376  char full_name[32]; /* Full name */
377 
378  bool opt[OPT_MAX]; /* Options */
379 
380  byte hitpoint_warn; /* Hitpoint warning (0 to 9) */
381  u16b lazymove_delay; /* Delay in cs before moving to allow another key */
382  byte delay_factor; /* Delay factor (0 to 9) */
383 
384  byte name_suffix; /* numeric suffix for player name */
385 } player_other;
386 
387 
393 extern const s32b player_exp[PY_MAX_LEVEL];
394 extern player_other *op_ptr;
395 extern player_type *player;
396 
397 
398 /* player-class.c */
399 extern struct player_class *player_id2class(guid id);
400 
401 /* player.c */
402 int stat_name_to_idx(const char *name);
403 const char *stat_idx_to_name(int type);
404 extern bool player_stat_inc(struct player *p, int stat);
405 extern bool player_stat_dec(struct player *p, int stat, bool permanent);
406 extern void player_exp_gain(struct player *p, s32b amount);
407 extern void player_exp_lose(struct player *p, s32b amount, bool permanent);
408 extern void player_flags(struct player *p, bitflag f[OF_SIZE]);
409 
410 extern byte player_hp_attr(struct player *p);
411 extern byte player_sp_attr(struct player *p);
412 
413 extern bool player_restore_mana(struct player *p, int amt);
414 
415 extern const char *player_safe_name(struct player *p, bool strip_suffix);
416 
417 /* player-race.c */
418 extern struct player_race *player_id2race(guid id);
419 
420 #endif /* !PLAYER_H */