Angband
player-calcs.h
Go to the documentation of this file.
1 
20 #ifndef PLAYER_CALCS_H
21 #define PLAYER_CALCS_H
22 
26 enum
27 {
28  #define STAT(a, b, c, d, e, f, g, h) STAT_##a,
29  #include "list-stats.h"
30  #undef STAT
31 
32  STAT_MAX
33 };
34 
35 
39 enum
40 {
41  #define PF(a,b,c) PF_##a,
42  #include "list-player-flags.h"
43  #undef PF
44  PF_MAX
45 };
46 
47 #define PF_SIZE FLAG_SIZE(PF_MAX)
48 
49 #define pf_has(f, flag) flag_has_dbg(f, PF_SIZE, flag, #f, #flag)
50 #define pf_next(f, flag) flag_next(f, PF_SIZE, flag)
51 #define pf_is_empty(f) flag_is_empty(f, PF_SIZE)
52 #define pf_is_full(f) flag_is_full(f, PF_SIZE)
53 #define pf_is_inter(f1, f2) flag_is_inter(f1, f2, PF_SIZE)
54 #define pf_is_subset(f1, f2) flag_is_subset(f1, f2, PF_SIZE)
55 #define pf_is_equal(f1, f2) flag_is_equal(f1, f2, PF_SIZE)
56 #define pf_on(f, flag) flag_on_dbg(f, PF_SIZE, flag, #f, #flag)
57 #define pf_off(f, flag) flag_off(f, PF_SIZE, flag)
58 #define pf_wipe(f) flag_wipe(f, PF_SIZE)
59 #define pf_setall(f) flag_setall(f, PF_SIZE)
60 #define pf_negate(f) flag_negate(f, PF_SIZE)
61 #define pf_copy(f1, f2) flag_copy(f1, f2, PF_SIZE)
62 #define pf_union(f1, f2) flag_union(f1, f2, PF_SIZE)
63 #define pf_comp_union(f1, f2) flag_comp_union(f1, f2, PF_SIZE)
64 #define pf_inter(f1, f2) flag_inter(f1, f2, PF_SIZE)
65 #define pf_diff(f1, f2) flag_diff(f1, f2, PF_SIZE)
66 
67 #define player_has(flag) (pf_has(player->race->pflags, (flag)) || pf_has(player->class->pflags, (flag)))
68 
69 
73 enum
74 {
75  SKILL_DISARM, /* Skill: Disarming */
76  SKILL_DEVICE, /* Skill: Magic Devices */
77  SKILL_SAVE, /* Skill: Saving throw */
78  SKILL_STEALTH, /* Skill: Stealth factor */
79  SKILL_SEARCH, /* Skill: Searching ability */
80  SKILL_SEARCH_FREQUENCY, /* Skill: Searching frequency */
81  SKILL_TO_HIT_MELEE, /* Skill: To hit (normal) */
82  SKILL_TO_HIT_BOW, /* Skill: To hit (shooting) */
83  SKILL_TO_HIT_THROW, /* Skill: To hit (throwing) */
84  SKILL_DIGGING, /* Skill: Digging */
85 
87 };
88 
89 /* Terrain that the player has a chance of digging through */
90 enum
91 {
97 
99 };
100 
101 /*
102  * Bit flags for the "player->notice" variable
103  */
104 #define PN_COMBINE 0x00000001L /* Combine the pack */
105 #define PN_IGNORE 0x00000008L /* Ignore stuff */
106 #define PN_MON_MESSAGE 0x00000010L /* flush monster pain messages */
107 
108 
109 /*
110  * Bit flags for the "player->update" variable
111  */
112 #define PU_BONUS 0x00000001L /* Calculate bonuses */
113 #define PU_TORCH 0x00000002L /* Calculate torch radius */
114 #define PU_HP 0x00000004L /* Calculate chp and mhp */
115 #define PU_MANA 0x00000008L /* Calculate csp and msp */
116 #define PU_SPELLS 0x00000010L /* Calculate spells */
117 #define PU_FORGET_VIEW 0x00000020L /* Forget field of view */
118 #define PU_UPDATE_VIEW 0x00000040L /* Update field of view */
119 #define PU_FORGET_FLOW 0x00000080L /* Forget flow data */
120 #define PU_UPDATE_FLOW 0x00000100L /* Update flow data */
121 #define PU_MONSTERS 0x00000200L /* Update monsters */
122 #define PU_DISTANCE 0x00000400L /* Update distances */
123 #define PU_PANEL 0x00000800L /* Update panel */
124 #define PU_INVEN 0x00001000L /* Update inventory */
125 
126 
127 /*
128  * Bit flags for the "player->redraw" variable
129  */
130 #define PR_MISC 0x00000001L /* Display Race/Class */
131 #define PR_TITLE 0x00000002L /* Display Title */
132 #define PR_LEV 0x00000004L /* Display Level */
133 #define PR_EXP 0x00000008L /* Display Experience */
134 #define PR_STATS 0x00000010L /* Display Stats */
135 #define PR_ARMOR 0x00000020L /* Display Armor */
136 #define PR_HP 0x00000040L /* Display Hitpoints */
137 #define PR_MANA 0x00000080L /* Display Mana */
138 #define PR_GOLD 0x00000100L /* Display Gold */
139 #define PR_HEALTH 0x00000200L /* Display Health Bar */
140 #define PR_SPEED 0x00000400L /* Display Extra (Speed) */
141 #define PR_STUDY 0x00000800L /* Display Extra (Study) */
142 #define PR_DEPTH 0x00001000L /* Display Depth */
143 #define PR_STATUS 0x00002000L
144 #define PR_DTRAP 0x00004000L /* Trap detection indicator */
145 #define PR_STATE 0x00008000L /* Display Extra (State) */
146 #define PR_MAP 0x00010000L /* Redraw whole map */
147 #define PR_INVEN 0x00010000L /* Display inven/equip */
148 #define PR_EQUIP 0x00040000L /* Display equip/inven */
149 #define PR_MESSAGE 0x00080000L /* Display messages */
150 #define PR_MONSTER 0x00100000L /* Display monster recall */
151 #define PR_OBJECT 0x00200000L /* Display object recall */
152 #define PR_MONLIST 0x00400000L /* Display monster list */
153 #define PR_ITEMLIST 0x00800000L /* Display item list */
154 
155 /* Display Basic Info */
156 #define PR_BASIC \
157  (PR_MISC | PR_TITLE | PR_STATS | PR_LEV |\
158  PR_EXP | PR_GOLD | PR_ARMOR | PR_HP |\
159  PR_MANA | PR_DEPTH | PR_HEALTH | PR_SPEED)
160 
161 /* Display Extra Info */
162 #define PR_EXTRA \
163  (PR_STATUS | PR_STATE | PR_STUDY)
164 
169 #define STAT_RANGE 38
170 
171 
172 /*** Structures ***/
173 
174 struct equip_slot {
175  struct equip_slot *next;
176 
178  char *name;
179  struct object *obj;
180 };
181 
182 struct player_body {
183  struct player_body *next;
184  char *name;
186  struct equip_slot *slots;
187 };
188 
194 typedef struct player_state {
195  s16b speed; /* Current speed */
196 
197  s16b num_blows; /* Number of blows x100 */
198  s16b num_shots; /* Number of shots */
199 
200  byte ammo_mult; /* Ammo multiplier */
201  byte ammo_tval; /* Ammo variety */
202 
203  s16b stat_add[STAT_MAX]; /* Equipment stat bonuses */
204  s16b stat_ind[STAT_MAX]; /* Indexes into stat tables */
205  s16b stat_use[STAT_MAX]; /* Current modified stats */
206  s16b stat_top[STAT_MAX]; /* Maximal modified stats */
207 
208  s16b ac; /* Base ac */
209  s16b to_a; /* Bonus to ac */
210  s16b to_h; /* Bonus to hit */
211  s16b to_d; /* Bonus to dam */
212 
213  s16b see_infra; /* Infravision range */
214 
215  s16b cur_light; /* Radius of light (if any) */
216 
217  s16b skills[SKILL_MAX]; /* Skills */
218 
219  int noise; /* Derived from stealth */
220 
221  bool heavy_wield; /* Heavy weapon */
222  bool heavy_shoot; /* Heavy shooter */
223  bool icky_wield; /* Icky weapon shooter */
224 
225  bool cumber_armor; /* Mana draining armor */
226  bool cumber_glove; /* Mana draining gloves */
227 
228  bitflag flags[OF_SIZE]; /* Status flags from race and items */
229  bitflag pflags[PF_SIZE]; /* Player intrinsic flags */
230  struct element_info el_info[ELEM_MAX]; /* Resists from race and items */
231 } player_state;
232 
238 typedef struct player_upkeep {
239  bool playing; /* True if player is playing */
240  bool autosave; /* True if autosave is pending */
241  bool generate_level; /* True if level needs regenerating */
242  bool only_partial; /* True if only partial updates are needed */
243 
244  int energy_use; /* Energy use this turn */
245  int new_spells; /* Number of spells available */
246 
247  struct monster *health_who; /* Health bar trackee */
248  struct monster_race *monster_race; /* Monster race trackee */
249  struct object *object; /* Object trackee */
250  struct object_kind *object_kind; /* Object kind trackee */
251 
252  u32b notice; /* Bit flags for pending actions such as
253  * reordering inventory, ignoring, etc. */
254  u32b update; /* Bit flags for recalculations needed
255  * such as HP, or visible area */
256  u32b redraw; /* Bit flags for things that /have/ changed,
257  * and just need to be redrawn by the UI,
258  * such as HP, Speed, etc.*/
259 
260  int command_wrk; /* Used by the UI to decide whether
261  * to start off showing equipment or
262  * inventory listings when offering
263  * a choice. See obj-ui.c */
264 
265  bool create_up_stair; /* Create up stair on next level */
266  bool create_down_stair; /* Create down stair on next level */
267 
268  int running; /* Running counter */
269  bool running_withpathfind; /* Are we using the pathfinder ? */
270  bool running_firststep; /* Is this our first step running? */
271 
272  struct object **quiver; /* Quiver objects */
273  struct object **inven; /* Inventory objects */
274  int total_weight; /* Total weight being carried */
275  int inven_cnt; /* Number of items in inventory */
276  int equip_cnt; /* Number of items in equipment */
277  int quiver_cnt; /* Number of items in the quiver */
278 } player_upkeep;
279 
280 
281 extern const byte adj_str_blow[STAT_RANGE];
282 extern const byte adj_dex_safe[STAT_RANGE];
283 extern const byte adj_con_fix[STAT_RANGE];
284 extern const byte adj_str_hold[STAT_RANGE];
285 
286 bool earlier_object(struct object *orig, struct object *new, bool store);
287 int equipped_item_slot(struct player_body body, struct object *obj);
288 void calc_inventory(struct player_upkeep *upkeep, struct object *gear,
289  struct player_body body);
290 void calc_bonuses(object_type inventory[], player_state *state, bool known_only);
291 void calc_digging_chances(player_state *state, int chances[DIGGING_MAX]);
292 int calc_blows(const object_type *o_ptr, player_state *state, int extra_blows);
293 
294 void health_track(struct player_upkeep *upkeep, struct monster *m_ptr);
295 void monster_race_track(struct player_upkeep *upkeep,
296  struct monster_race *race);
297 void track_object(struct player_upkeep *upkeep, struct object *obj);
298 void track_object_kind(struct player_upkeep *upkeep, struct object_kind *kind);
299 bool tracked_object_is(struct player_upkeep *upkeep, struct object *obj);
300 
301 void notice_stuff(struct player_upkeep *upkeep);
302 void update_stuff(struct player_upkeep *upkeep);
303 void redraw_stuff(struct player_upkeep *upkeep);
304 void handle_stuff(struct player_upkeep *upkeep);
305 int weight_remaining(void);
306 
307 #endif /* !PLAYER_CALCS_H */