Go to the documentation of this file.
20 #ifndef PLAYER_UTIL_H
21 #define PLAYER_UTIL_H
23 #include "player.h"
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 */
32 /* Player over-exertion */
33 enum {
34  PY_EXERT_NONE = 0x00,
35  PY_EXERT_CON = 0x01,
38  PY_EXERT_CUT = 0x08,
39  PY_EXERT_CONF = 0x10,
41  PY_EXERT_SLOW = 0x40,
42  PY_EXERT_HP = 0x80
43 };
50 enum
51 {
55 };
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 s16b modify_stat_value(int value, int amount);
69 void player_regen_hp(struct player *p);
70 void player_regen_mana(struct player *p);
71 void player_adjust_hp_precise(struct player *p, s32b hp_gain);
72 s32b player_adjust_mana_precise(struct player *p, s32b sp_gain);
73 void convert_mana_to_hp(struct player *p, s32b sp);
74 void player_update_light(struct player *p);
75 void player_over_exert(struct player *p, int flag, int chance, int amount);
76 struct object *player_best_digger(struct player *p, bool forbid_stack);
78 int player_check_terrain_damage(struct player *p, struct loc grid);
79 void player_take_terrain_damage(struct player *p, struct loc grid);
80 struct player_shape *lookup_player_shape(const char *name);
81 int shape_name_to_idx(const char *name);
83 void player_resume_normal_shape(struct player *p);
84 bool player_is_shapechanged(struct player *p);
85 bool player_is_trapsafe(struct player *p);
86 bool player_can_cast(struct player *p, bool show_msg);
87 bool player_can_study(struct player *p, bool show_msg);
88 bool player_can_read(struct player *p, bool show_msg);
89 bool player_can_fire(struct player *p, bool show_msg);
90 bool player_can_refuel(struct player *p, bool show_msg);
91 bool player_can_cast_prereq(void);
92 bool player_can_study_prereq(void);
93 bool player_can_read_prereq(void);
94 bool player_can_fire_prereq(void);
95 bool player_can_refuel_prereq(void);
97 bool player_confuse_dir(struct player *p, int *dir, bool too);
99 bool player_is_resting(struct player *p);
101 void player_resting_set_count(struct player *p, s16b count);
102 void player_resting_cancel(struct player *p, bool disturb);
104 void player_resting_step_turn(struct player *p);
107 void player_set_resting_repeat_count(struct player *p, s16b count);
108 bool player_of_has(struct player *p, int flag);
109 bool player_resists(struct player *p, int element);
110 bool player_is_immune(struct player *p, int element);
111 void player_place(struct chunk *c, struct player *p, struct loc grid);
112 void disturb(struct player *p);
113 void search(struct player *p);
115 #endif /* !PLAYER_UTIL_H */
bool player_can_fire(struct player *p, bool show_msg)
Return true if the player can fire something with a launcher.
Definition: player-util.c:977
bool player_can_refuel(struct player *p, bool show_msg)
Return true if the player can refuel their light source.
Definition: player-util.c:998
void player_regen_mana(struct player *p)
Regenerate one turn's worth of mana.
Definition: player-util.c:372
bool player_resting_is_special(s16b count)
Return true if the provided count is one of the conditional REST_ flags.
Definition: player-util.c:1125
Definition: z-type.h:24
bool player_can_cast_prereq(void)
Prerequiste function for command.
Definition: player-util.c:1016
struct loc grid
position on map, or (0, 0)
Definition: object.h:429
png_infop png_uint_32 flag
Definition: libpng12/png.h:2191
Definition: player-util.h:40
bool player_of_has(struct player *p, int flag)
Check if the player state has the given OF_ flag.
Definition: player-util.c:1290
bool player_can_study_prereq(void)
Prerequiste function for command.
Definition: player-util.c:1024
void player_resting_step_turn(struct player *p)
Perform one turn of resting.
Definition: player-util.c:1214
Definition: player-util.h:53
s16b modify_stat_value(int value, int amount)
Modify a stat value by a "modifier", return new value.
Definition: player-util.c:286
bool player_resists(struct player *p, int element)
Check if the player resists (or better) an element.
Definition: player-util.c:1299
struct object * player_best_digger(struct player *p, bool forbid_stack)
Find the player's best digging tool.
Definition: player-util.c:596
int player_check_terrain_damage(struct player *p, struct loc grid)
See how much damage the player will take from damaging terrain.
Definition: player-util.c:732
void player_update_light(struct player *p)
Update the player's light fuel.
Definition: player-util.c:535
void player_resting_complete_special(struct player *p)
Handle the conditions for conditional resting (resting with the REST_ constants). ...
Definition: player-util.c:1237
Player implementation.
struct player_shape * player_shape_by_idx(int index)
Find a player shape from the index.
Definition: player-util.c:803
Definition: cave.h:180
bool player_can_read_prereq(void)
Prerequiste function for command.
Definition: player-util.c:1032
bool player_is_immune(struct player *p, int element)
Check if the player resists (or better) an element.
Definition: player-util.c:1307
void player_regen_hp(struct player *p)
Regenerate one turn's worth of hit points.
Definition: player-util.c:321
Definition: player-util.h:42
Object information, for a specific object.
Definition: object.h:418
void player_resting_cancel(struct player *p, bool disturb)
Cancel current rest.
Definition: player-util.c:1192
Definition: player-util.h:35
s32b player_adjust_mana_precise(struct player *p, s32b sp_gain)
Accept a 4 byte signed int, divide it by 65k, and add to current spell points.
Definition: player-util.c:457
bool player_is_shapechanged(struct player *p)
Check if the player is shapechanged.
Definition: player-util.c:836
int dungeon_get_next_level(int dlev, int added)
Increment to the next or decrement to the preceeding level accounting for the stair skip value in con...
Definition: player-util.c:50
Definition: player-util.h:52
bool player_can_refuel_prereq(void)
Prerequiste function for command.
Definition: player-util.c:1048
void disturb(struct player *p)
Definition: player-util.c:1342
bool player_can_read(struct player *p, bool show_msg)
Return true if the player can read scrolls or books.
Definition: player-util.c:937
void player_take_terrain_damage(struct player *p, struct loc grid)
Terrain damages the player.
Definition: player-util.c:755
void player_resume_normal_shape(struct player *p)
Revert to normal shape.
Definition: player-util.c:819
bool player_can_fire_prereq(void)
Prerequiste function for command.
Definition: player-util.c:1040
Definition: player-util.h:34
const char ** p[]
Definition: name.c:40
bool player_book_has_unlearned_spells(struct player *p)
Return true if the player has access to a book that has unlearned spells.
Definition: player-util.c:1058
int16_t s16b
Definition: h-basic.h:162
int shape_name_to_idx(const char *name)
Find a player shape index from the shape name.
Definition: player-util.c:790
bool player_can_study(struct player *p, bool show_msg)
Return true if the player can study a spell.
Definition: player-util.c:891
bool player_confuse_dir(struct player *p, int *dir, bool too)
Apply confusion, if needed, to a direction.
Definition: player-util.c:1096
Definition: player-util.h:39
void take_hit(struct player *p, int dam, const char *kb_str)
Decreases players hit points and sets death flag if necessary.
Definition: player-util.c:152
bool player_is_resting(struct player *p)
Return true if the player is resting.
Definition: player-util.c:1140
struct player_shape * lookup_player_shape(const char *name)
Find a player shape from the name.
Definition: player-util.c:774
Definition: player-util.h:54
void player_place(struct chunk *c, struct player *p, struct loc grid)
Places the player at the given coordinates in the cave.
Definition: player-util.c:1315
void dungeon_change_level(struct player *p, int dlev)
Change dungeon level - e.g.
Definition: player-util.c:127
Player shapechange shape info.
Definition: player.h:213
void player_set_recall_depth(struct player *p)
Set recall depth for a player recalling from town.
Definition: player-util.c:75
void death_knowledge(struct player *p)
Win or not, know inventory, home items and history upon death, enter score.
Definition: player-util.c:238
void player_adjust_hp_precise(struct player *p, s32b hp_gain)
Definition: player-util.c:417
s16b player_resting_count(struct player *p)
Return the remaining number of resting turns.
Definition: player-util.c:1149
void convert_mana_to_hp(struct player *p, s32b sp)
Definition: player-util.c:508
void search(struct player *p)
Search for traps or secret doors.
Definition: player-util.c:1375
bool player_attack_random_monster(struct player *p)
Melee a random adjacent monster.
Definition: player-util.c:627
void player_set_resting_repeat_count(struct player *p, s16b count)
Set the number of resting turns to repeat.
Definition: player-util.c:1282
int32_t s32b
Definition: h-basic.h:165
Definition: player-util.h:41
Intialize random names
Definition: init.c:1084
void player_over_exert(struct player *p, int flag, int chance, int amount)
Have random bad stuff happen to the player from over-exertion.
Definition: player-util.c:652
Most of the "player" information goes here.
Definition: player.h:503
void player_resting_set_count(struct player *p, s16b count)
Set the number of resting turns.
Definition: player-util.c:1167
int player_get_resting_repeat_count(struct player *p)
Get the number of resting turns to repeat.
Definition: player-util.c:1272
bool player_resting_can_regenerate(struct player *p)
Return true if the player should get a regeneration bonus for the current rest.
Definition: player-util.c:1203
Definition: player-util.h:38
png_voidp int value
Definition: libpng12/png.h:2145
bool player_can_cast(struct player *p, bool show_msg)
Return true if the player can cast a spell.
Definition: player-util.c:858
Definition: player-util.h:36
int index
Definition: obj-info.c:68
bool player_is_trapsafe(struct player *p)
Check if the player is immune from traps.
Definition: player-util.c:844
bool player_get_recall_depth(struct player *p)
Give the player the choice of persistent level to recall to.
Definition: player-util.c:94
Definition: player-util.h:37