3 * @brief Player related functions.
16 #include "place-info.h"
18 #include "religion-enum.h"
24 #define CONDENSATION_SHIELD_KEY "condensation_shield_pow"
25 #define ICY_ARMOUR_KEY "ozocubu's_armour_pow"
26 #define STONESKIN_KEY "stoneskin_pow"
27 #define TRANSFORM_POW_KEY "transform_pow"
28 #define BARBS_MOVE_KEY "moved_with_barbs_status"
29 #define HORROR_PENALTY_KEY "horror_penalty"
32 // display/messaging breakpoints for penalties from Ru's MUT_HORROR
33 #define HORROR_LVL_EXTREME 3
34 #define HORROR_LVL_OVERWHELMING 5
36 /// The standard unit of regen; one level in artifact inscriptions
37 static const int REGEN_PIP = 40;
38 /// The standard unit of MR; one level in %/@ screens
39 static const int MR_PIP = 40;
40 /// The standard unit of stealth; one level in %/@ screens
41 static const int STEALTH_PIP = 50;
43 /// The rough number of aut getting hit takes off your bone armour
44 static const int BONE_ARMOUR_HIT_RATIO = 50;
46 /// The minimum aut cost for a player move (before haste)
47 static const int FASTEST_PLAYER_MOVE_SPEED = 6;
48 // relevant for swiftness, etc
54 // needed for assert in is_player()
56 #define you (*real_you)
60 typedef FixedVector<int, NUM_DURATIONS> durations_t;
61 class player : public actor
65 // Character save chunk data:
66 // None of this is really necessary, except for some complicated
67 // hacks with player_save_info. Should only be used in tags.cc or
68 // player_save_info::operator=(player).
70 string chr_species_name;
71 string chr_class_name;
81 // This field is here even in non-WIZARD compiles, since the
82 // player might have been playing previously under wiz mode.
83 bool wizard; // true if player has entered wiz mode.
84 bool explore; // true if player has entered explore mode.
85 time_t birth_time; // start time of game
91 int elapsed_time; // total amount of elapsed time in the game
92 int elapsed_time_at_last_input; // used for elapsed_time delta display
96 int hp_max_adj_temp; // temporary max HP loss (rotting)
97 int hp_max_adj_perm; // base HPs from background (and permanent loss)
100 int max_magic_points;
101 int mp_max_adj; // max MP loss (ability costs, tutorial bonus)
103 FixedVector<int8_t, NUM_STATS> stat_loss;
104 FixedVector<int8_t, NUM_STATS> base_stats;
108 hunger_state_t hunger_state;
110 int hit_points_regeneration;
111 int magic_points_regeneration;
112 unsigned int experience;
113 unsigned int total_experience; // Unaffected by draining. Used for skill cost.
114 int experience_level;
116 int zigs_completed, zig_max;
118 FixedVector<int8_t, NUM_EQUIP> equip;
119 FixedBitVector<NUM_EQUIP> melded;
120 // Whether these are unrands that we should run the _*_world_reacts func for
121 FixedBitVector<NUM_EQUIP> unrand_reacts;
123 FixedArray<int, NUM_OBJECT_CLASSES, MAX_SUBTYPES> force_autopickup;
125 // PC's symbol (usually @) and colour.
127 transformation_type form;
129 FixedVector< item_def, ENDOFPACK > inv;
130 FixedBitVector<NUM_RUNE_TYPES> runes;
131 int obtainable_runes; // can be != 15 in Sprint
133 FixedVector<spell_type, MAX_KNOWN_SPELLS> spells;
134 set<spell_type> old_vehumet_gifts, vehumet_gifts;
137 game_direction_type char_direction;
138 bool royal_jelly_dead;
139 bool transform_uncancellable;
140 bool fishtail; // Merfolk fishtail transformation
142 unsigned short pet_target;
144 durations_t duration;
146 bool apply_berserk_penalty; // Whether to apply the berserk penalty at
148 int berserk_penalty; // The penalty for moving while berserk
150 FixedVector<int, NUM_ATTRIBUTES> attribute;
151 FixedVector<uint8_t, NUM_AMMO> quiver; // default items for quiver
152 FixedVector<int, NUM_TIMERS> last_timer_effect;
153 FixedVector<int, NUM_TIMERS> next_timer_effect;
155 bool dead; // ... but pending revival
158 #if TAG_MAJOR_VERSION == 34
159 float temperature; // For lava orcs.
160 float temperature_last;
163 FixedVector<uint8_t, NUM_SKILLS> skills; ///< skill level
164 FixedVector<int8_t, NUM_SKILLS> train; ///< 0: disabled, 1: normal, 2: focus
165 FixedVector<int8_t, NUM_SKILLS> train_alt; ///< config of the other mode
166 FixedVector<unsigned int, NUM_SKILLS> training; ///< percentage of XP used
167 FixedBitVector<NUM_SKILLS> can_train; ///< Is training this skill allowed?
168 FixedVector<unsigned int, NUM_SKILLS> skill_points;
169 FixedVector<unsigned int, NUM_SKILLS> ct_skill_points;///<track skill points
170 ///<gained by crosstraining
171 FixedVector<uint8_t, NUM_SKILLS> skill_order;
174 list<skill_type> exercises; ///< recent practise events
175 list<skill_type> exercises_all; ///< also include events for disabled skills
176 set<skill_type> stop_train; ///< need to check if we can still train
177 set<skill_type> start_train; ///< we can resume training
180 skill_menu_state skill_menu_do;
181 skill_menu_state skill_menu_view;
183 //Ashenzari transfer knowledge
184 skill_type transfer_from_skill;
185 skill_type transfer_to_skill;
186 unsigned int transfer_skill_points;
187 unsigned int transfer_total_skill_points;
189 int skill_cost_level;
191 int zot_points; // ZotDef currency
193 FixedVector<int, NUM_GODS> exp_docked;
194 FixedVector<int, NUM_GODS> exp_docked_total; // XP-based wrath
196 FixedArray<uint32_t, 6, MAX_SUBTYPES> item_description;
197 FixedVector<unique_item_status_type, MAX_UNRANDARTS> unique_items;
198 FixedBitVector<NUM_MONSTERS> unique_creatures;
200 // NOTE: The kills member is a pointer to a KillMaster object,
201 // rather than the object itself, so that we can get away with
202 // just a forward declare of the KillMaster class, rather than
203 // having to #include kills.h and thus make every single .cc file
204 // dependent on kills.h. Having a pointer means that we have
205 // to do our own implementations of copying the player object,
206 // since the default implementations will lead to the kills member
207 // pointing to freed memory, or worse yet lead to the same piece of
208 // memory being freed twice.
211 branch_type where_are_you;
214 FixedVector<uint8_t, 30> branch_stairs;
217 string jiyva_second_name; // Random second name of Jiyva
219 uint8_t piety_hysteresis; // amount of stored-up docking
220 uint8_t gift_timeout;
221 FixedVector<uint8_t, NUM_GODS> penance;
222 FixedVector<uint8_t, NUM_GODS> worshipped;
223 FixedVector<short, NUM_GODS> num_current_gifts;
224 FixedVector<short, NUM_GODS> num_total_gifts;
225 FixedBitVector< NUM_GODS> one_time_ability_used;
226 FixedVector<uint8_t, NUM_GODS> piety_max;
228 FixedVector<uint8_t, NUM_MUTATIONS> mutation;
229 FixedVector<uint8_t, NUM_MUTATIONS> innate_mutation;
230 FixedVector<uint8_t, NUM_MUTATIONS> temp_mutation;
231 FixedVector<uint8_t, NUM_MUTATIONS> sacrifices;
236 mutation_type mutation;
239 vector<demon_trait> demonic_traits;
241 int magic_contamination;
243 FixedBitVector<NUM_FIXED_BOOKS> had_book;
244 FixedBitVector<NUM_SPELLS> seen_spell;
245 FixedVector<uint32_t, NUM_WEAPONS> seen_weapon;
246 FixedVector<uint32_t, NUM_ARMOURS> seen_armour;
247 FixedBitVector<NUM_MISCELLANY> seen_misc;
248 uint8_t octopus_king_rings;
250 uint8_t normal_vision; // how far the species gets to see
251 uint8_t current_vision; // current sight radius (cells)
253 int real_time; // real time played (in seconds)
254 int num_turns; // number of turns taken
255 int exploration; // levels explored (16.16 bit real number)
257 int last_view_update; // what turn was the view last updated?
259 // Warning: these two are quite different.
261 // The spell table is an index to a specific spell slot (you.spells).
262 // The ability table lists the ability (ABIL_*) which prefers that letter.
264 // In other words, the spell table contains hard links and the ability
265 // table contains soft links.
266 FixedVector<int, 52> spell_letter_table; // ref to spell by slot
267 FixedVector<ability_type, 52> ability_letter_table; // ref to abil by enum
269 // Maps without allow_dup that have been already used.
270 set<string> uniq_map_tags;
271 set<string> uniq_map_names;
272 // All maps, by level.
273 map<level_id, vector<string> > vault_list;
275 PlaceInfo global_info;
276 player_quiver* m_quiver;
278 // monsters mesmerising player; should be protected, but needs to be saved
280 vector<mid_t> beholders;
282 // monsters causing fear to the player; see above
283 vector<mid_t> fearmongers;
285 // Delayed level actions. This array is never trimmed, as usually D:1 won't
286 // be loaded again until the very end.
287 vector<daction_type> dactions;
289 // Path back from portal levels.
290 vector<level_pos> level_stack;
292 // The player's knowledge about item types.
294 // Additional information, about tried unidentified items.
295 // (e.g. name of item, for scrolls of RC, ID, EA)
296 CrawlHashTable type_id_props;
298 // The version the save was last played with.
299 string prev_save_version;
301 // The type of a zotdef wave, if any.
302 string zotdef_wave_name;
303 // The biggest assigned monster id so far.
306 // Count of various types of actions made.
307 map<pair<caction_type, int>, FixedVector<int, 27> > action_count;
309 // Which branches have been noted to have been left during this game.
310 FixedBitVector<NUM_BRANCHES> branches_left;
312 // For now, only control the speed of abyss morphing.
315 // Prompts or actions the player must answer before continuing.
316 // A stack -- back() is the first to go.
317 vector<pair<uncancellable_type, int> > uncancel;
319 // A list of allies awaiting an active recall
320 vector<mid_t> recall_list;
322 // Hash seeds for deterministic stuff.
323 FixedVector<uint32_t, NUM_SEEDS> game_seeds;
325 // -------------------
326 // Non-saved UI state:
327 // -------------------
328 unsigned short prev_targ;
329 coord_def prev_grd_targ;
332 // Coordinates of last travel target; note that this is never used by
333 // travel itself, only by the level-map to remember the last travel target.
334 short travel_x, travel_y;
337 runrest running; // Nonzero if running/traveling.
338 bool travel_ally_pace;
340 bool received_weapon_warning;
341 bool received_noskill_warning;
342 bool wizmode_teleported_into_rock;
344 delay_queue_type delay_queue; // pending actions
346 time_t last_keypress_time;
348 int8_t bondage_level; // how much an Ash worshipper is into bondage
349 int8_t bondage[NUM_ET];
350 map<skill_type, int8_t> skill_boost; // Skill bonuses.
353 // The last spell cast by the player.
354 spell_type last_cast_spell;
355 map<int,int> last_pickup;
358 // ---------------------------
359 // Volatile (same-turn) state:
360 // ---------------------------
361 bool turn_is_over; // flag signaling that player has performed a timed action
363 // If true, player is headed to the Abyss.
367 bool wield_change; // redraw weapon
368 bool redraw_quiver; // redraw quiver
369 uint64_t redraw_status_flags;
372 bool redraw_hit_points;
373 bool redraw_magic_points;
374 #if TAG_MAJOR_VERSION == 34
375 bool redraw_temperature;
377 FixedVector<bool, NUM_STATS> redraw_stats;
378 bool redraw_experience;
379 bool redraw_armour_class;
382 colour_t flash_colour;
383 targetter *flash_where;
387 int old_hunger; // used for hunger delta-meter (see output.cc)
389 // Set when the character is going to a new level, to guard against levgen
391 dungeon_feature_type transit_stair;
394 int escaped_death_cause;
395 string escaped_death_aux;
397 int turn_damage; // cumulative damage per turn
398 mid_t damage_source; // death source of last damage done to player
399 int source_damage; // cumulative damage for you.damage_source
401 // When other levels are loaded (e.g. viewing), is the player on this level?
402 bool on_current_level;
404 // View code clears and needs new data in places where we can't announce the
405 // portal right away; delay the announcements then.
407 // Same with invisible monsters, for ring auto-id.
410 // Number of viewport refreshes.
411 unsigned int frame_no;
414 // ---------------------
415 // The save file itself.
416 // ---------------------
420 FixedVector<PlaceInfo, NUM_BRANCHES> branch_info;
424 player(const player &other);
427 void copy_from(const player &other);
432 // Set player position without updating view geometry.
433 void set_position(const coord_def &c);
434 // Low-level move the player. Use this instead of changing pos directly.
435 void moveto(const coord_def &c, bool clear_net = true);
436 bool move_to_pos(const coord_def &c, bool clear_net = true,
437 bool /*force*/ = false);
438 // Move the player during an abyss shift.
439 void shiftto(const coord_def &c);
440 bool blink_to(const coord_def& c, bool quiet = false);
442 void reset_prev_move();
444 int stat(stat_type stat, bool nonneg = true) const;
445 int strength(bool nonneg = true) const;
446 int intel(bool nonneg = true) const;
447 int dex(bool nonneg = true) const;
448 int max_stat(stat_type stat, bool base = false) const;
449 int max_strength() const;
450 int max_intel() const;
453 bool in_water() const;
454 bool in_lava() const;
455 bool in_liquid() const;
456 bool can_swim(bool permanently = false) const;
457 int visible_igrd(const coord_def&) const;
458 bool can_cling_to_walls() const;
459 bool is_banished() const;
460 bool is_web_immune() const;
461 bool cannot_speak() const;
462 bool invisible() const;
463 bool can_see_invisible() const;
464 bool can_see_invisible(bool unid, bool items = true) const;
465 bool visible_to(const actor *looker) const;
466 bool can_see(const actor* a) const;
467 undead_state_type undead_state(bool temp = true) const;
468 bool nightvision() const;
469 reach_type reach_range() const;
470 bool see_cell(const coord_def& p) const;
472 // Is c in view but behind a transparent wall?
473 bool trans_wall_blocking(const coord_def &c) const;
476 bool is_fiery() const;
477 bool is_skeletal() const;
479 bool tengu_flight() const;
482 int spell_hp_cost() const;
483 bool spellcasting_unholy() const;
485 // Dealing with beholders. Implemented in behold.cc.
486 void add_beholder(const monster* mon, bool axe = false);
488 bool beheld_by(const monster* mon) const;
489 monster* get_beholder(const coord_def &pos) const;
490 monster* get_any_beholder() const;
491 void remove_beholder(const monster* mon);
492 void clear_beholders();
493 void beholders_check_noise(int loudness, bool axe = false);
494 void update_beholders();
495 void update_beholder(const monster* mon);
496 bool possible_beholder(const monster* mon) const;
498 // Dealing with fearmongers. Implemented in fearmonger.cc.
499 bool add_fearmonger(const monster* mon);
501 bool afraid_of(const monster* mon) const;
502 monster* get_fearmonger(const coord_def &pos) const;
503 monster* get_any_fearmonger() const;
504 void remove_fearmonger(const monster* mon);
505 void clear_fearmongers();
506 void fearmongers_check_noise(int loudness, bool axe = false);
507 void update_fearmongers();
508 void update_fearmonger(const monster* mon);
510 bool made_nervous_by(const coord_def &pos);
512 kill_category kill_alignment() const;
514 bool has_spell(spell_type spell) const;
516 string shout_verb(bool directed = false) const;
517 int shout_volume() const;
519 item_def *slot_item(equipment_type eq, bool include_melded=false) const;
521 int base_ac_from(const item_def &armour, int scale = 1) const;
522 void maybe_degrade_bone_armour(int mult);
526 int get_hit_dice() const;
527 int get_experience_level() const;
528 int get_max_xl() const;
529 bool is_player() const
531 #ifndef DEBUG_GLOBALS
532 ASSERT(this == (actor*)&you); // there can be only one
536 monster* as_monster() { return nullptr; }
537 player* as_player() { return this; }
538 const monster* as_monster() const { return nullptr; }
539 const player* as_player() const { return this; }
541 god_type deity() const;
543 bool is_summoned(int* duration = nullptr,
544 int* summon_type = nullptr) const;
545 bool is_perm_summoned() const { return false; };
547 bool swimming() const;
548 bool submerged() const;
549 bool floundering() const;
550 bool extra_balanced() const;
551 bool shove(const char* feat_name = "");
552 bool can_pass_through_feat(dungeon_feature_type grid) const;
553 bool is_habitable_feat(dungeon_feature_type actual_grid) const;
554 size_type body_size(size_part_type psize = PSIZE_TORSO, bool base = false) const;
555 brand_type damage_brand(int which_attack = -1);
556 int damage_type(int which_attack = -1);
557 random_var attack_delay(const item_def *weapon, const
558 item_def *projectile = nullptr,
559 bool random = true, bool scaled = true,
560 bool do_shield = true) const;
561 int constriction_damage() const;
563 int has_claws(bool allow_tran = true) const;
564 bool has_usable_claws(bool allow_tran = true) const;
565 int has_talons(bool allow_tran = true) const;
566 bool has_usable_talons(bool allow_tran = true) const;
567 int has_hooves(bool allow_tran = true) const;
568 bool has_usable_hooves(bool allow_tran = true) const;
569 int has_fangs(bool allow_tran = true) const;
570 int has_usable_fangs(bool allow_tran = true) const;
571 int has_tail(bool allow_tran = true) const;
572 int has_usable_tail(bool allow_tran = true) const;
573 bool has_usable_offhand() const;
574 int has_pseudopods(bool allow_tran = true) const;
575 int has_usable_pseudopods(bool allow_tran = true) const;
576 int has_tentacles(bool allow_tran = true) const;
577 int has_usable_tentacles(bool allow_tran = true) const;
579 int wearing(equipment_type slot, int sub_type, bool calc_unid = true) const;
580 int wearing_ego(equipment_type slot, int type, bool calc_unid = true) const;
581 int scan_artefacts(artefact_prop_type which_property,
582 bool calc_unid = true,
583 vector<item_def> *matches = nullptr) const;
585 item_def *weapon(int which_attack = -1) const;
586 item_def *shield() const;
588 hands_reqd_type hands_reqd(const item_def &item) const;
590 bool can_wield(const item_def &item,
591 bool ignore_curse = false,
592 bool ignore_brand = false,
593 bool ignore_shield = false,
594 bool ignore_transform = false) const;
595 bool could_wield(const item_def &item,
596 bool ignore_brand = false,
597 bool ignore_transform = false,
598 bool quiet = true) const;
600 string name(description_level_type type, bool force_visible = false,
601 bool force_article = false) const;
602 string pronoun(pronoun_type pro, bool force_visible = false) const;
603 string conj_verb(const string &verb) const;
604 string hand_name(bool plural, bool *can_plural = nullptr) const;
605 string hands_verb(const string &plural_verb) const;
606 string hands_act(const string &plural_verb, const string &object) const;
607 string foot_name(bool plural, bool *can_plural = nullptr) const;
608 string arm_name(bool plural, bool *can_plural = nullptr) const;
609 string unarmed_attack_name() const;
611 bool fumbles_attack();
612 bool cannot_fight() const;
613 bool fights_well_unarmed(int heavy_armour_penalty);
615 void attacking(actor *other, bool ranged = false);
616 bool can_go_berserk() const;
617 bool can_go_berserk(bool intentional, bool potion = false,
618 bool quiet = false) const;
619 bool go_berserk(bool intentional, bool potion = false);
620 bool berserk() const;
621 bool can_mutate() const;
622 bool can_safely_mutate(bool temp = true) const;
623 bool is_lifeless_undead(bool temp = true) const;
624 bool can_polymorph() const;
625 bool can_bleed(bool allow_tran = true) const;
626 bool is_stationary() const;
627 bool malmutate(const string &reason);
628 bool polymorph(int pow);
630 void banish(actor* /*agent*/, const string &who = "");
631 void blink(bool allow_partial_control = true);
632 void teleport(bool right_now = false,
633 bool wizard_tele = false);
634 void drain_stat(stat_type stat, int amount);
636 void expose_to_element(beam_type element, int strength = 0,
637 bool slow_cold_blood = true);
638 void god_conduct(conduct_type thing_done, int level);
640 void make_hungry(int nutrition, bool silent = true);
641 bool poison(actor *agent, int amount = 1, bool force = false);
642 bool sicken(int amount);
643 void paralyse(actor *, int str, string source = "");
644 void petrify(actor *, bool force = false);
645 bool fully_petrify(actor *foe, bool quiet = false);
646 void slow_down(actor *, int str);
647 void confuse(actor *, int strength);
648 void weaken(actor *attacker, int pow);
649 bool heal(int amount, bool max_too = false);
650 bool drain_exp(actor *, bool quiet = false, int pow = 3);
651 bool rot(actor *, int amount, bool quiet = false);
652 void splash_with_acid(const actor* evildoer, int acid_strength,
653 bool allow_corrosion = true,
654 const char* hurt_msg = nullptr);
655 void corrode_equipment(const char* corrosion_source = "the acid",
657 void sentinel_mark(bool trap = false);
658 int hurt(const actor *attacker, int amount,
659 beam_type flavour = BEAM_MISSILE,
660 kill_method_type kill_type = KILLED_BY_MONSTER,
663 bool cleanup_dead = true,
664 bool attacker_effects = true);
666 bool wont_attack() const { return true; };
667 mon_attitude_type temp_attitude() const { return ATT_FRIENDLY; };
669 monster_type mons_species(bool zombie_base = false) const;
671 mon_holy_type holiness(bool temp = true) const;
672 bool undead_or_demonic() const;
673 bool holy_wrath_susceptible() const;
674 bool is_holy(bool spells = true) const;
675 bool is_unholy(bool spells = true) const;
676 bool is_evil(bool spells = true) const;
677 int how_chaotic(bool check_spells_god) const;
678 bool is_artificial(bool temp = true) const;
679 bool is_unbreathing() const;
680 bool is_insubstantial() const;
681 int res_acid(bool calc_unid = true) const;
682 bool res_hellfire() const { return false; };
683 int res_fire() const;
684 int res_steam() const;
685 int res_cold() const;
686 int res_elec() const;
687 int res_poison(bool temp = true) const;
688 int res_rotting(bool temp = true) const;
689 int res_water_drowning() const;
690 bool res_sticky_flame() const;
691 int res_holy_energy(const actor *) const;
692 int res_negative_energy(bool intrinsic_only = false) const;
693 bool res_torment() const;
694 bool res_wind() const;
695 bool res_petrify(bool temp = true) const;
696 int res_constrict() const;
697 int res_magic() const;
698 bool no_tele(bool calc_unid = true, bool /*permit_id*/ = true,
699 bool blink = false) const;
700 string no_tele_reason(bool calc_unid = true, bool blink = false) const;
701 bool no_tele_print_reason(bool calc_unid = true, bool blink = false) const;
702 bool antimagic_susceptible() const;
704 bool gourmand(bool calc_unid = true, bool items = true) const;
705 bool res_corr(bool calc_unid = true, bool items = true) const;
706 bool clarity(bool calc_unid = true, bool items = true) const;
707 bool stasis(bool calc_unid = true, bool items = true) const;
709 bool airborne() const;
710 bool cancellable_flight() const;
711 bool permanent_flight() const;
712 bool racial_permanent_flight() const;
714 bool paralysed() const;
715 bool cannot_move() const;
716 bool cannot_act() const;
717 bool confused() const;
719 bool backlit(bool self_halo = true) const;
721 int halo_radius2() const;
722 int silence_radius2() const;
723 int liquefying_radius2() const;
724 int umbra_radius2() const;
725 #if TAG_MAJOR_VERSION == 34
726 int heat_radius2() const;
728 bool glows_naturally() const;
729 bool petrifying() const;
730 bool petrified() const;
731 bool liquefied_ground() const;
732 bool incapacitated() const
734 return actor::incapacitated() || duration[DUR_CLUMSY];
738 void put_to_sleep(actor *, int power = 0, bool hibernate = false);
740 void check_awaken(int disturbance);
741 int beam_resists(bolt &beam, int hurted, bool doEffects, string source);
743 bool can_throw_large_rocks() const;
744 bool can_smell() const;
746 int racial_ac(bool temp) const;
747 int armour_class(bool /*calc_unid*/ = true) const;
748 int gdr_perc() const;
749 int evasion(ev_ignore_type evit = EV_IGNORE_NONE,
750 const actor *attacker = nullptr) const;
752 int stat_hp() const { return hp; }
753 int stat_maxhp() const { return hp_max; }
754 int stealth() const { return check_stealth(); }
756 bool shielded() const;
757 int shield_bonus() const;
758 int shield_block_penalty() const;
759 int shield_bypass_ability(int tohit) const;
760 void shield_block_succeeded(actor *foe);
761 int missile_deflection() const;
762 void ablate_deflection();
764 // Combat-related adjusted penalty calculation methods
765 int unadjusted_body_armour_penalty() const;
766 int adjusted_body_armour_penalty(int scale = 1) const;
767 int adjusted_shield_penalty(int scale = 1) const;
768 float get_shield_skill_to_offset_penalty(const item_def &item);
769 int armour_tohit_penalty(bool random_factor, int scale = 1) const;
770 int shield_tohit_penalty(bool random_factor, int scale = 1) const;
772 bool wearing_light_armour(bool with_skill = false) const;
773 int skill(skill_type skill, int scale =1,
774 bool real = false, bool drained = true) const;
778 bool can_do_shaft_ability(bool quiet = false) const;
779 bool do_shaft_ability();
781 bool can_device_heal();
783 void apply_location_effects(const coord_def &oldpos,
784 killer_type killer = KILL_NONE,
787 ////////////////////////////////////////////////////////////////
789 PlaceInfo& get_place_info() const ; // Current place info
790 PlaceInfo& get_place_info(branch_type branch) const;
791 void clear_place_info();
793 void goto_place(const level_id &level);
795 void set_place_info(PlaceInfo info);
796 // Returns copies of the PlaceInfo; modifying the vector won't
797 // modify the player object.
798 vector<PlaceInfo> get_all_place_info(bool visited_only = false,
799 bool dungeon_only = false) const;
801 bool did_escape_death() const;
802 void reset_escaped_death();
804 void add_gold(int delta);
805 void del_gold(int delta);
806 void set_gold(int amount);
808 void increase_duration(duration_type dur, int turns, int cap = 0,
809 const char* msg = nullptr);
810 void set_duration(duration_type dur, int turns, int cap = 0,
811 const char *msg = nullptr);
813 bool attempt_escape(int attempts = 1);
814 int usable_tentacles() const;
815 bool has_usable_tentacle() const;
817 bool form_uses_xl() const;
819 bool clear_far_engulf();
822 void _removed_beholder(bool quiet = false);
823 bool _possible_beholder(const monster* mon) const;
825 void _removed_fearmonger(bool quiet = false);
826 bool _possible_fearmonger(const monster* mon) const;
829 struct player_save_info
832 unsigned int experience;
833 int experience_level;
835 species_type species;
840 string jiyva_second_name;
841 game_type saved_game_type;
850 player_save_info& operator=(const player& rhs);
851 bool operator<(const player_save_info& rhs) const;
852 string short_desc() const;
858 // Helper. Use move_player_to_grid or player::apply_location_effects instead.
859 void moveto_location_effects(dungeon_feature_type old_feat,
860 bool stepped=false, const coord_def& old_pos=coord_def());
862 bool check_moveto(const coord_def& p, const string &move_verb = "step",
863 const string &msg = "");
864 bool check_moveto_terrain(const coord_def& p, const string &move_verb,
865 const string &msg = "", bool *prompted = nullptr);
866 bool check_moveto_cloud(const coord_def& p, const string &move_verb = "step",
867 bool *prompted = nullptr);
868 bool check_moveto_exclusion(const coord_def& p,
869 const string &move_verb = "step",
870 bool *prompted = nullptr);
871 bool check_moveto_trap(const coord_def& p, const string &move_verb = "step",
872 bool *prompted = nullptr);
874 bool swap_check(monster* mons, coord_def &loc, bool quiet = false);
876 void move_player_to_grid(const coord_def& p, bool stepped);
878 bool is_map_persistent();
879 bool player_in_connected_branch();
880 bool player_in_hell();
881 bool player_in_starting_abyss();
883 static inline bool player_in_branch(int branch)
885 return you.where_are_you == branch;
888 bool berserk_check_wielded_weapon();
889 bool player_equip_unrand(int unrand_index);
890 bool player_can_hit_monster(const monster* mon);
891 bool player_can_hear(const coord_def& p, int hear_distance = 999);
893 bool player_is_shapechanged();
895 bool is_effectively_light_armour(const item_def *item);
896 bool player_effectively_in_light_armour();
900 int player_shield_racial_factor();
901 int player_armour_shield_spell_penalty();
903 int player_movement_speed();
905 int player_hunger_rate(bool temp = true);
907 int calc_hunger(int food_cost);
909 int player_icemail_armour_class();
911 bool player_stoneskin();
913 int player_wizardry(spell_type spell);
915 int player_prot_life(bool calc_unid = true, bool temp = true,
920 int player_res_cold(bool calc_unid = true, bool temp = true,
922 int player_res_acid(bool calc_unid = true, bool items = true);
924 bool player_res_torment(bool random = true);
925 bool player_kiku_res_torment();
927 int player_likes_chunks(bool permanently = false);
928 bool player_likes_water(bool permanently = false);
929 bool player_likes_lava(bool permanently = false);
931 int player_mutation_level(mutation_type mut, bool temp = true);
933 int player_res_electricity(bool calc_unid = true, bool temp = true,
936 int player_res_fire(bool calc_unid = true, bool temp = true,
938 int player_res_sticky_flame(bool calc_unid = true, bool temp = true,
940 int player_res_steam(bool calc_unid = true, bool temp = true,
943 int player_res_poison(bool calc_unid = true, bool temp = true,
945 int player_res_magic(bool calc_unid = true, bool temp = true);
947 bool player_control_teleport(bool temp = true);
949 int player_shield_class();
950 int player_displayed_shield_class();
952 int player_spec_air();
953 int player_spec_cold();
954 int player_spec_conj();
955 int player_spec_death();
956 int player_spec_earth();
957 int player_spec_fire();
958 int player_spec_hex();
959 int player_spec_charm();
960 int player_spec_poison();
961 int player_spec_summ();
965 int player_spell_levels();
967 bool player_sust_abil(bool calc_unid = true);
969 int player_teleport(bool calc_unid = true);
971 int player_monster_detect_radius();
973 int slaying_bonus(bool ranged = false);
975 unsigned int exp_needed(int lev, int exp_apt = -99);
976 bool will_gain_life(int lev);
978 int get_expiration_threshold(duration_type dur);
979 bool dur_expiring(duration_type dur);
980 void display_char_status();
982 void forget_map(bool rot = false);
984 int get_exp_progress();
985 void gain_exp(unsigned int exp_gained, unsigned int* actual_gain = nullptr);
987 bool player_can_open_doors();
989 void level_change(bool skip_attribute_increase = false);
990 void adjust_level(int diff, bool just_xp = false);
992 bool is_player_same_genus(const monster_type mon);
993 monster_type player_mons(bool transform = true);
994 void update_player_symbol();
995 void update_vision_range();
997 maybe_bool you_can_wear(equipment_type eq, bool temp = false);
998 bool player_has_feet(bool temp = true);
1000 bool enough_hp(int minimum, bool suppress_msg, bool abort_macros = true);
1001 bool enough_mp(int minimum, bool suppress_msg, bool abort_macros = true);
1002 bool enough_zp(int minimum, bool suppress_msg);
1007 void dec_hp(int hp_loss, bool fatal, const char *aux = nullptr);
1008 void dec_mp(int mp_loss, bool silent = false);
1009 void drain_mp(int mp_loss);
1011 void inc_mp(int mp_gain, bool silent = false);
1012 void inc_hp(int hp_gain);
1015 void rot_hp(int hp_loss);
1016 // Unrot the player and return excess HP if any.
1017 int unrot_hp(int hp_recovered);
1018 int player_rotted();
1019 void rot_mp(int mp_loss);
1021 void inc_max_hp(int hp_gain);
1022 void dec_max_hp(int hp_loss);
1024 void deflate_hp(int new_level, bool floor);
1025 void set_hp(int new_amount);
1027 int get_real_hp(bool trans, bool rotted = false);
1028 int get_real_mp(bool include_items);
1030 int get_contamination_level();
1031 string describe_contamination(int level);
1033 void set_mp(int new_amount);
1035 void contaminate_player(int change, bool controlled = false, bool msg = true);
1037 bool confuse_player(int amount, bool quiet = false);
1039 bool poison_player(int amount, string source, string source_aux = "",
1040 bool force = false);
1041 void paralyse_player(string source, int amount = 0);
1042 void handle_player_poison(int delay);
1043 void reduce_player_poison(int amount);
1044 int get_player_poisoning();
1045 bool poison_is_lethal();
1046 int poison_survival();
1048 bool miasma_player(actor *who, string source_aux = "");
1050 bool napalm_player(int amount, string source, string source_aux = "");
1051 void dec_napalm_player(int delay);
1053 bool spell_slow_player(int pow);
1054 bool slow_player(int turns);
1055 void dec_slow_player(int delay);
1056 void dec_exhaust_player(int delay);
1058 bool haste_player(int turns, bool rageext = false);
1059 void dec_haste_player(int delay);
1060 void dec_elixir_player(int delay);
1061 void dec_ambrosia_player(int delay);
1062 bool flight_allowed(bool quiet = false);
1063 void fly_player(int pow, bool already_flying = false);
1064 void float_player();
1065 bool land_player(bool quiet = false);
1066 void player_open_door(coord_def doorpos);
1067 void player_close_door(coord_def doorpos);
1069 void dec_disease_player(int delay);
1071 void handle_player_drowning(int delay);
1073 // Determines if the given grid is dangerous for the player to enter.
1074 bool is_feat_dangerous(dungeon_feature_type feat, bool permanently = false,
1075 bool ignore_flight = false);
1077 int count_worn_ego(int which_ego);
1078 bool need_expiration_warning(duration_type dur, dungeon_feature_type feat);
1079 bool need_expiration_warning(dungeon_feature_type feat);
1080 bool need_expiration_warning(duration_type dur, coord_def p = you.pos());
1081 bool need_expiration_warning(coord_def p = you.pos());
1083 void count_action(caction_type type, int subtype = 0);
1084 bool player_has_orb();
1086 #if TAG_MAJOR_VERSION == 34
1087 enum temperature_level
1089 TEMP_MIN = 1, // Minimum (and starting) temperature. Not any warmer than bare rock.
1093 TEMP_WARM = 9, // Warmer than most creatures.
1095 TEMP_FIRE = 13, // Hot enough to ignite paper around you.
1096 TEMP_MAX = 15, // Maximum temperature. As hot as lava!
1099 enum temperature_effect
1114 int temperature_last();
1115 void temperature_check();
1116 void temperature_increment(float degree);
1117 void temperature_decrement(float degree);
1118 void temperature_changed(float change);
1119 void temperature_decay();
1120 bool temperature_tier(int which);
1121 bool temperature_effect(int which);
1122 int temperature_colour(int temp);
1123 string temperature_string(int temp);
1124 string temperature_text(int temp);