1 /**
2  * \file player-util.h
3  * \brief Player utility functions
4  *
5  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6  * Copyright (c) 2014 Nick McConnell
7  *
8  * This work is free software; you can redistribute it and/or modify it
9  * under the terms of either:
10  *
11  * a) the GNU General Public License as published by the Free Software
12  *    Foundation, version 2, or
13  *
14  * b) the "Angband licence":
15  *    This software may be copied and distributed for educational, research,
16  *    and not for profit purposes provided that this copyright and statement
17  *    are included in all such copies.  Other copyrights may also apply.
18  */
19 
20 #ifndef PLAYER_UTIL_H
21 #define PLAYER_UTIL_H
22 
23 #include "player.h"
24 
25 /* Player regeneration constants */
26 #define PY_REGEN_NORMAL		197		/* Regen factor*2^16 when full */
27 #define PY_REGEN_WEAK		98		/* Regen factor*2^16 when weak */
28 #define PY_REGEN_FAINT		33		/* Regen factor*2^16 when fainting */
29 #define PY_REGEN_HPBASE		1442	/* Min amount hp regen*2^16 */
30 #define PY_REGEN_MNBASE		524		/* Min amount mana regen*2^16 */
31 
32 /* Player over-exertion */
33 enum {
34 	PY_EXERT_NONE = 0x00,
35 	PY_EXERT_CON = 0x01,
36 	PY_EXERT_FAINT = 0x02,
37 	PY_EXERT_SCRAMBLE = 0x04,
38 	PY_EXERT_CUT = 0x08,
39 	PY_EXERT_CONF = 0x10,
40 	PY_EXERT_HALLU = 0x20,
41 	PY_EXERT_SLOW = 0x40,
42 	PY_EXERT_HP = 0x80
43 };
44 
45 /**
46  * Special values for the number of turns to rest, these need to be
47  * negative numbers, as postive numbers are taken to be a turncount,
48  * and zero means "not resting".
49  */
50 enum
51 {
52 	REST_COMPLETE = -2,
53 	REST_ALL_POINTS = -1,
54 	REST_SOME_POINTS = -3
55 };
56 
57 /**
58  * Minimum number of turns required for regeneration to kick in during resting.
59  */
60 #define REST_REQUIRED_FOR_REGEN 5
61 
62 int dungeon_get_next_level(int dlev, int added);
63 void player_set_recall_depth(struct player *p);
64 bool player_get_recall_depth(struct player *p);
65 void dungeon_change_level(struct player *p, int dlev);
66 void take_hit(struct player *p, int dam, const char *kb_str);
67 void death_knowledge(struct player *p);
68 int energy_per_move(struct player *p);
69 s16b modify_stat_value(int value, int amount);
70 void player_regen_hp(struct player *p);
71 void player_regen_mana(struct player *p);
72 void player_adjust_hp_precise(struct player *p, s32b hp_gain);
73 s32b player_adjust_mana_precise(struct player *p, s32b sp_gain);
74 void convert_mana_to_hp(struct player *p, s32b sp);
75 void player_update_light(struct player *p);
76 void player_over_exert(struct player *p, int flag, int chance, int amount);
77 struct object *player_best_digger(struct player *p, bool forbid_stack);
78 bool player_attack_random_monster(struct player *p);
79 int player_check_terrain_damage(struct player *p, struct loc grid);
80 void player_take_terrain_damage(struct player *p, struct loc grid);
81 struct player_shape *lookup_player_shape(const char *name);
82 int shape_name_to_idx(const char *name);
83 struct player_shape *player_shape_by_idx(int index);
84 void player_resume_normal_shape(struct player *p);
85 bool player_is_shapechanged(struct player *p);
86 bool player_is_trapsafe(struct player *p);
87 bool player_can_cast(struct player *p, bool show_msg);
88 bool player_can_study(struct player *p, bool show_msg);
89 bool player_can_read(struct player *p, bool show_msg);
90 bool player_can_fire(struct player *p, bool show_msg);
91 bool player_can_refuel(struct player *p, bool show_msg);
92 bool player_can_cast_prereq(void);
93 bool player_can_study_prereq(void);
94 bool player_can_read_prereq(void);
95 bool player_can_fire_prereq(void);
96 bool player_can_refuel_prereq(void);
97 bool player_book_has_unlearned_spells(struct player *p);
98 bool player_confuse_dir(struct player *p, int *dir, bool too);
99 bool player_resting_is_special(s16b count);
100 bool player_is_resting(struct player *p);
101 s16b player_resting_count(struct player *p);
102 void player_resting_set_count(struct player *p, s16b count);
103 void player_resting_cancel(struct player *p, bool disturb);
104 bool player_resting_can_regenerate(struct player *p);
105 void player_resting_step_turn(struct player *p);
106 void player_resting_complete_special(struct player *p);
107 int player_get_resting_repeat_count(struct player *p);
108 void player_set_resting_repeat_count(struct player *p, s16b count);
109 bool player_of_has(struct player *p, int flag);
110 bool player_resists(struct player *p, int element);
111 bool player_is_immune(struct player *p, int element);
112 void player_place(struct chunk *c, struct player *p, struct loc grid);
113 void disturb(struct player *p);
114 void search(struct player *p);
115 
116 #endif /* !PLAYER_UTIL_H */
117