-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
character.h
4199 lines (3732 loc) · 202 KB
/
character.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#ifndef CATA_SRC_CHARACTER_H
#define CATA_SRC_CHARACTER_H
#include <algorithm>
#include <bitset>
#include <climits>
#include <cstdint>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include "activity_tracker.h"
#include "activity_type.h"
#include "addiction.h"
#include "body_part_set.h"
#include "bodypart.h"
#include "calendar.h"
#include "cata_utility.h"
#include "character_attire.h"
#include "character_id.h"
#include "city.h" // IWYU pragma: keep
#include "compatibility.h"
#include "coords_fwd.h"
#include "creature.h"
#include "damage.h"
#include "enums.h"
#include "flat_set.h"
#include "game_constants.h"
#include "inventory.h"
#include "item.h"
#include "item_location.h"
#include "magic_enchantment.h"
#include "pimpl.h"
#include "player_activity.h"
#include "pocket_type.h"
#include "point.h"
#include "ranged.h"
#include "ret_val.h"
#include "safe_reference.h"
#include "sleep.h"
#include "stomach.h"
#include "string_formatter.h"
#include "subbodypart.h"
#include "type_id.h"
#include "units.h"
#include "visitable.h"
#include "weakpoint.h"
#include "weighted_list.h"
class JsonObject;
class JsonOut;
class SkillLevel;
class SkillLevelMap;
class activity_actor;
class basecamp;
class bionic_collection;
class character_martial_arts;
class craft_command;
class dispersion_sources;
class effect;
class effect_source;
class faction;
class item_pocket;
class known_magic;
class ma_technique;
class map;
class monster;
class nc_color;
class player_morale;
class profession;
class proficiency_set;
class recipe;
class recipe_subset;
class spell;
class ui_adaptor;
class vehicle;
class vpart_reference;
namespace catacurses
{
class window;
} // namespace catacurses
struct bionic;
struct construction;
struct dealt_projectile_attack;
struct display_proficiency;
struct field_immunity_data;
/// @brief Item slot used to apply modifications from food and meds
struct islot_comestible;
struct item_comp;
struct itype;
struct mutation_branch;
struct mutation_category_trait;
struct mutation_variant;
struct pathfinding_settings;
struct projectile;
struct requirement_data;
struct tool_comp;
struct trait_and_var;
struct trap;
struct w_point;
template <typename E> struct enum_traits;
enum npc_attitude : int;
enum action_id : int;
enum class recipe_filter_flags : int;
enum class steed_type : int;
enum class proficiency_bonus_type : int;
using drop_location = std::pair<item_location, int>;
using drop_locations = std::list<drop_location>;
using bionic_uid = unsigned int;
constexpr int MAX_CLAIRVOYANCE = 40;
// kcal in a kilogram of fat, used to convert stored kcal into body weight. 3500kcal/lb * 2.20462lb/kg = 7716.17
constexpr float KCAL_PER_KG = 3500 * 2.20462;
/// @brief type of conditions that effect vision
/// @note vision modes do not necessarily match json ids or flags
enum vision_modes {
DEBUG_NIGHTVISION,
NV_GOGGLES,
NIGHTVISION_1,
NIGHTVISION_2,
NIGHTVISION_3,
FULL_ELFA_VISION,
ELFA_VISION,
CEPH_VISION,
/// mutate w/ id "FEL_NV" & name "Feline Vision" see pretty well at night
FELINE_VISION,
/// Bird mutation named "Avian Eyes": Perception +4
BIRD_EYE,
/// mutate w/ id "URSINE_EYE" & name "Ursine Vision" see better in dark, nearsight in light
URSINE_VISION,
BOOMERED,
DARKNESS,
IR_VISION,
VISION_CLAIRVOYANCE,
VISION_CLAIRVOYANCE_PLUS,
VISION_CLAIRVOYANCE_SUPER,
NUM_VISION_MODES
};
enum class sleepiness_levels : int {
TIRED = 191,
DEAD_TIRED = 383,
EXHAUSTED = 575,
MASSIVE_SLEEPINESS = 1000
};
const std::unordered_map<std::string, sleepiness_levels> sleepiness_level_strs = { {
{ "TIRED", sleepiness_levels::TIRED },
{ "DEAD_TIRED", sleepiness_levels::DEAD_TIRED },
{ "EXHAUSTED", sleepiness_levels::EXHAUSTED },
{ "MASSIVE_SLEEPINESS", sleepiness_levels::MASSIVE_SLEEPINESS }
}
};
constexpr inline bool operator>=( const sleepiness_levels &lhs, const sleepiness_levels &rhs )
{
return static_cast<int>( lhs ) >= static_cast<int>( rhs );
}
constexpr inline bool operator<( const sleepiness_levels &lhs, const sleepiness_levels &rhs )
{
return static_cast<int>( lhs ) < static_cast<int>( rhs );
}
template<typename T>
constexpr inline bool operator>=( const T &lhs, const sleepiness_levels &rhs )
{
return lhs >= static_cast<T>( rhs );
}
template<typename T>
constexpr inline bool operator>( const T &lhs, const sleepiness_levels &rhs )
{
return lhs > static_cast<T>( rhs );
}
template<typename T>
constexpr inline bool operator<=( const T &lhs, const sleepiness_levels &rhs )
{
return lhs <= static_cast<T>( rhs );
}
template<typename T>
constexpr inline bool operator<( const T &lhs, const sleepiness_levels &rhs )
{
return lhs < static_cast<T>( rhs );
}
template<typename T>
constexpr inline int operator/( const sleepiness_levels &lhs, const T &rhs )
{
return static_cast<T>( lhs ) / rhs;
}
template<typename T>
constexpr inline int operator+( const sleepiness_levels &lhs, const T &rhs )
{
return static_cast<T>( lhs ) + rhs;
}
template<typename T>
constexpr inline int operator-( const sleepiness_levels &lhs, const T &rhs )
{
return static_cast<T>( lhs ) - rhs;
}
template<typename T>
constexpr inline int operator-( const T &lhs, const sleepiness_levels &rhs )
{
return lhs - static_cast<T>( rhs );
}
/** @brief five levels of consequences for days without sleep
@details Sleep deprivation, distinct from sleepiness, is defined in minutes. Although most
calculations scale linearly, malus is bestowed only upon reaching the tiers defined below.
@note Sleep deprivation increases sleepiness. Sleepiness increase scales with the severity of sleep
deprivation.
@note Sleep deprivation kicks in if lack of sleep is avoided with stimulants or otherwise for
long periods of time
@see https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/character.cpp#L5566
*/
enum sleep_deprivation_levels {
/// 2 days
SLEEP_DEPRIVATION_HARMLESS = 2 * 24 * 60,
/// 4 days
SLEEP_DEPRIVATION_MINOR = 4 * 24 * 60,
/// 7 days
SLEEP_DEPRIVATION_SERIOUS = 7 * 24 * 60,
/// 10 days
SLEEP_DEPRIVATION_MAJOR = 10 * 24 * 60,
/// 14 days
SLEEP_DEPRIVATION_MASSIVE = 14 * 24 * 60
};
enum class blood_type {
blood_O,
blood_A,
blood_B,
blood_AB,
num_bt
};
template<>
struct enum_traits<blood_type> {
static constexpr blood_type last = blood_type::num_bt;
};
/// @brief how digestible or palatable an item is
/// @details This tries to represent both rating and character's decision to respect said rating
/// (ie "they can eat it, though they are disgusted by it")
enum edible_rating {
/// Edible or we pretend it is
EDIBLE,
/// Not food at all
INEDIBLE,
/// Not food because character has mutated mouth/system
INEDIBLE_MUTATION,
/// You can eat it, but it will hurt morale because of negative trait such as Hates Fruit
ALLERGY,
/// Smaller allergy penalty
ALLERGY_WEAK,
/// Penalty for eating human flesh (unless psycho/cannibal)
CANNIBALISM,
/// Comestible has parasites
PARASITES,
/// Rotten (or, for saprophages, not rotten enough)
ROTTEN,
/// Can provoke vomiting if you already feel nauseous.
NAUSEA,
/// We can eat this, but we'll suffer from overeat
TOO_FULL,
/// Some weird stuff that requires a tool we don't have
NO_TOOL
};
enum crush_tool_type {
CRUSH_EMPTY_HANDS,
CRUSH_HAMMER,
CRUSH_DRILL_OR_HAMMER_AND_SCREW,
CRUSH_NO_TOOL
};
struct queued_eoc {
public:
effect_on_condition_id eoc;
time_point time;
std::unordered_map<std::string, std::string> context;
};
struct eoc_compare {
bool operator()( const queued_eoc &lhs, const queued_eoc &rhs ) const {
return lhs.time > rhs.time;
}
};
struct queued_eocs {
using storage_iter = std::list<queued_eoc>::iterator;
struct eoc_compare : ::eoc_compare {
bool operator()( const storage_iter &lhs, const storage_iter &rhs ) const {
return ::eoc_compare::operator()( *lhs, *rhs );
}
};
std::priority_queue<storage_iter, std::vector<storage_iter>, eoc_compare> queue;
std::list<queued_eoc> list;
queued_eocs() = default;
queued_eocs( const queued_eocs &rhs ) {
list = rhs.list;
for( auto it = list.begin(), end = list.end(); it != end; ++it ) {
queue.emplace( it );
}
};
queued_eocs( queued_eocs &&rhs ) noexcept {
queue.swap( rhs.queue );
list.swap( rhs.list );
}
queued_eocs &operator=( const queued_eocs &rhs ) {
list = rhs.list;
// Why doesn't std::priority_queue have a clear() function.
queue = {};
for( auto it = list.begin(), end = list.end(); it != end; ++it ) {
queue.emplace( it );
}
return *this;
}
queued_eocs &operator=( queued_eocs &&rhs ) noexcept {
queue.swap( rhs.queue );
list.swap( rhs.list );
return *this;
}
/* std::priority_queue compatibility layer where performance is less relevant */
bool empty() const {
return queue.empty();
}
const queued_eoc &top() const {
return *queue.top();
}
void push( const queued_eoc &eoc ) {
auto it = list.emplace( list.end(), eoc );
queue.push( it );
}
void pop() {
auto it = queue.top();
queue.pop();
list.erase( it );
}
};
struct aim_type {
std::string name;
std::string action;
std::string help;
bool has_threshold;
int threshold;
bool operator==( const aim_type &other ) const {
return has_threshold == other.has_threshold &&
threshold == other.threshold &&
name == other.name &&
action == other.action &&
help == other.help;
}
};
struct parallax_cache {
int parallax_with_zoom;
int parallax_without_zoom;
};
struct aim_mods_cache {
float aim_speed_skill_mod;
float aim_speed_dex_mod;
float aim_speed_mod;
int limit;
double aim_factor_from_volume;
double aim_factor_from_length;
parallax_cache parallaxes;
};
struct special_attack {
std::string text;
damage_instance damage;
};
struct consumption_event {
time_point time;
itype_id type_id;
uint64_t component_hash;
consumption_event() = default;
explicit consumption_event( const item &food ) : time( calendar::turn ) {
type_id = food.typeId();
component_hash = food.make_component_hash();
}
void serialize( JsonOut &json ) const;
void deserialize( const JsonObject &jo );
};
struct stat_mod {
int strength = 0;
int dexterity = 0;
int intelligence = 0;
int perception = 0;
int speed = 0;
};
inline social_modifiers operator+( social_modifiers lhs, const social_modifiers &rhs )
{
lhs += rhs;
return lhs;
}
/// @brief Four ability stats available on character creation
/// @details Default is 8. Minimum value is 4 and 14 is considered to be max human value.
enum class character_stat : char {
STRENGTH,
DEXTERITY,
INTELLIGENCE,
PERCEPTION,
DUMMY_STAT
};
enum class customize_appearance_choice : int {
EYES, // customize eye color
HAIR, // customize hair
HAIR_F, // customize facial hair
SKIN // customize skin color
};
enum class book_mastery {
CANT_DETERMINE, // book not yet identified, so you don't know yet
CANT_UNDERSTAND, // does not have enough skill to read
LEARNING,
MASTERED // can no longer increase skill by reading
};
enum class read_condition_result {
SUCCESS = 0,
NOT_BOOK = 1 << 0,
CANT_UNDERSTAND = 1 << 1,
MASTERED = 1 << 2,
DRIVING = 1 << 3,
ILLITERATE = 1 << 4,
NEED_GLASSES = 1 << 5,
TOO_DARK = 1 << 6,
MORALE_LOW = 1 << 7,
BLIND = 1 << 8
};
template<>
struct enum_traits<read_condition_result> {
static constexpr bool is_flag_enum = true;
};
/** @relates ret_val */
template<>
struct ret_val<edible_rating>::default_success : public
std::integral_constant<edible_rating, EDIBLE> {};
/** @relates ret_val */
template<>
struct ret_val<edible_rating>::default_failure : public
std::integral_constant<edible_rating, INEDIBLE> {};
/** @relates ret_val */
template<>
struct ret_val<crush_tool_type>::default_success : public
std::integral_constant<crush_tool_type, CRUSH_EMPTY_HANDS> {};
/** @relates ret_val */
template<>
struct ret_val<crush_tool_type>::default_failure : public
std::integral_constant<crush_tool_type, CRUSH_NO_TOOL> {};
struct needs_rates {
float thirst = 0.0f;
float hunger = 0.0f;
float sleepiness = 0.0f;
float recovery = 0.0f;
float kcal = 0.0f;
};
struct pocket_data_with_parent {
const item_pocket *pocket_ptr;
item_location parent;
int nested_level;
};
struct speed_bonus_effect {
std::string description;
int bonus = 0;
};
struct run_cost_effect {
std::string description;
float times = 1.0;
float plus = 0;
};
nutrients default_character_compute_effective_nutrients( const item &comest );
class Character : public Creature, public visitable
{
public:
Character( const Character & ) = delete;
Character &operator=( const Character & ) = delete;
~Character() override;
// initialize avatar and avatar mocks
void initialize( bool learn_recipes = true );
Character *as_character() override {
return this;
}
const Character *as_character() const override {
return this;
}
bool is_npc() const override {
return false; // Overloaded for NPCs in npc.h
}
// populate variables, inventory items, and misc from json object
virtual void deserialize( const JsonObject &jsobj ) = 0;
// by default save all contained info
virtual void serialize( JsonOut &jsout ) const = 0;
character_id getID() const;
/// sets the ID, will *only* succeed when the current id is not valid
/// allows forcing a -1 id which is required for templates to not throw errors
void setID( character_id i, bool force = false );
field_type_id bloodType() const override;
field_type_id gibType() const override;
bool is_warm() const override;
bool in_species( const species_id &spec ) const override;
/// Turned to false for simulating NPCs on distant missions so they don't drop all their gear in sight
bool death_drops;
/// Is currently in control of a vehicle
bool controlling_vehicle = false;
/// @brief Character stats
/// @todo Make those protected
int str_max;
int dex_max;
int int_max;
int per_max;
int str_cur;
int dex_cur;
int int_cur;
int per_cur;
// Used to display pain penalties
int ppen_str;
int ppen_dex;
int ppen_int;
int ppen_per;
int ppen_spd;
int kill_xp = 0;
// Level-up points spent on Stats through Kills
int spent_upgrade_points = 0;
float cached_organic_size;
const profession *prof;
std::set<const profession *> hobbies;
void randomize_hobbies();
void add_random_hobby( std::vector<profession_id> &choices );
// Relative direction of a grab, add to posx, posy to get the coordinates of the grabbed thing.
tripoint_rel_ms grab_point;
std::optional<city> starting_city;
std::optional<point_abs_om> world_origin;
bool random_start_location = true;
start_location_id start_location;
bool manual_examine = false;
int volume = 0;
// The prevalence of getter, setter, and mutator functions here is partially
// a result of the slow, piece-wise migration of the player class upwards into
// the character class. As enough logic is moved upwards to fully separate
// utility upwards out of the player class, as many of these as possible should
// be eliminated to allow for proper code separation. (Note: Not "all", many").
/** Getters for stats exclusive to characters */
int get_str() const;
int get_dex() const;
int get_per() const;
int get_int() const;
int get_str_base() const;
int get_dex_base() const;
int get_per_base() const;
int get_int_base() const;
int get_str_bonus() const;
int get_dex_bonus() const;
int get_per_bonus() const;
int get_int_bonus() const;
/** Cache variables to store stamina use info
* these will be updated when the player's limb makeup changes
* _power_use is how many joules to spend per stamina instead of stamina (default 0)
* _stam_mult is how much to multiply the incoming stamina cost's stamina drain (default of 1)
*/
int arms_power_use; // millijoules
int legs_power_use; // millijoules
float arms_stam_mult;
float legs_stam_mult;
/** Getters for above stats */
int get_arms_power_use() const;
int get_legs_power_use() const;
float get_arms_stam_mult() const;
float get_legs_stam_mult() const;
private:
/** Modifiers to character speed, with descriptions */
std::vector<speed_bonus_effect> speed_bonus_effects;
int dodges_left;
public:
std::vector<speed_bonus_effect> get_speed_bonus_effects() const;
int get_speed() const override;
int get_enchantment_speed_bonus() const;
// Strength modified by limb lifting score
int get_arm_str() const;
// Defines distance from which CAMOUFLAGE mobs are visible
int get_eff_per() const override;
// Penalty modifiers applied for ranged attacks due to low stats
int ranged_dex_mod() const;
int ranged_per_mod() const;
/** Setters for stats exclusive to characters */
void set_str_bonus( int nstr );
void set_dex_bonus( int ndex );
void set_per_bonus( int nper );
void set_int_bonus( int nint );
void mod_str_bonus( int nstr );
void mod_dex_bonus( int ndex );
void mod_per_bonus( int nper );
void mod_int_bonus( int nint );
/** Setters for stats shared with other creatures */
using Creature::mod_speed_bonus;
void mod_speed_bonus( int nspeed, const std::string &desc );
/** Getters for health values exclusive to characters */
int get_lifestyle() const;
int get_daily_health() const;
int get_health_tally() const;
/** Modifiers for health values exclusive to characters */
void mod_livestyle( int nhealthy );
void mod_daily_health( int nhealthy_mod, int cap );
void mod_health_tally( int mod );
/** Setters for health values exclusive to characters */
void set_lifestyle( int nhealthy );
void set_daily_health( int nhealthy_mod );
/** Getter for need values exclusive to characters */
int get_stored_kcal() const;
int get_healthy_kcal() const;
// Returns stored kcals as a proportion of "healthy" kcals (1.0 == healthy)
float get_kcal_percent() const;
int kcal_speed_penalty() const;
int get_hunger() const;
int get_starvation() const;
virtual int get_thirst() const;
virtual int get_instant_thirst() const;
time_duration get_daily_sleep() const;
void mod_daily_sleep( time_duration mod );
void reset_daily_sleep();
time_duration get_continuous_sleep() const;
void mod_continuous_sleep( time_duration mod );
void reset_continuous_sleep();
int get_sleepiness() const;
int get_sleep_deprivation() const;
/** Modifiers for need values exclusive to characters */
void mod_stored_kcal( int nkcal, bool ignore_weariness = false );
void mod_hunger( int nhunger );
void mod_thirst( int nthirst );
void mod_sleepiness( int nsleepiness );
void mod_sleep_deprivation( int nsleep_deprivation );
/** Setters for need values exclusive to characters */
void set_stored_kcal( int kcal );
void set_hunger( int nhunger );
void set_thirst( int nthirst );
void set_sleepiness( int nsleepiness );
void set_sleepiness( sleepiness_levels nsleepiness );
void set_sleep_deprivation( int nsleep_deprivation );
protected:
// These accept values in calories, 1/1000s of kcals (or Calories)
void mod_stored_calories( int ncal, bool ignore_weariness = false );
void set_stored_calories( int cal );
public:
void gravity_check();
void stagger();
void mod_stat( const std::string &stat, float modifier ) override;
int get_standard_stamina_cost( const item *thrown_item = nullptr ) const;
/**Get bonus to max_hp from excess stored fat*/
int get_fat_to_hp() const;
/** Get size class of character **/
creature_size get_size() const override;
/** Recalculate size class of character **/
void recalculate_size();
/** Displays character name with a npc_class/profession suffix
**/
std::string disp_name( bool possessive = false, bool capitalize_first = false ) const override;
/** Returns the player's profession or an NPC's suffix if they have one
* @param npc_override for now, professions don't display by default as suffixes. Set to true to get the profession name if it exists.
**/
std::string disp_profession() const;
virtual std::string name_and_maybe_activity() const;
/** Returns the name of the player's outer layer, e.g. "armor plates" */
std::string skin_name() const override;
//message related stuff
using Creature::add_msg_if_player;
void add_msg_if_player( const std::string &msg ) const override;
void add_msg_if_player( const game_message_params ¶ms, const std::string &msg ) const override;
using Creature::add_msg_player_or_npc;
void add_msg_player_or_npc( const std::string &player_msg,
const std::string &npc_str ) const override;
void add_msg_player_or_npc( const game_message_params ¶ms, const std::string &player_msg,
const std::string &npc_msg ) const override;
using Creature::add_msg_player_or_say;
void add_msg_player_or_say( const std::string &player_msg,
const std::string &npc_speech ) const override;
void add_msg_player_or_say( const game_message_params ¶ms, const std::string &player_msg,
const std::string &npc_speech ) const override;
/* returns the character's faction */
virtual faction *get_faction() const {
return nullptr;
}
void set_fac_id( const std::string &my_fac_id );
virtual bool is_ally( const Character &p ) const = 0;
virtual bool is_obeying( const Character &p ) const = 0;
//returns character's profession
const profession *get_profession() const;
void add_profession_items();
//returns the hobbies
std::set<const profession *> get_hobbies() const;
// Has item with mission_id
bool has_mission_item( int mission_id ) const;
/* Adjusts provided sight dispersion to account for player stats */
int effective_dispersion( int dispersion, bool zoom = false ) const;
dispersion_sources total_gun_dispersion( const item &gun, double recoil, int spread ) const;
int get_character_parallax( bool zoom = false ) const;
/* Accessors for aspects of aim speed. */
std::vector<aim_type> get_aim_types( const item &gun ) const;
int point_shooting_limit( const item &gun ) const;
double fastest_aiming_method_speed( const item &gun, double recoil,
const Target_attributes &target_attributes = Target_attributes(),
std::optional<std::reference_wrapper<const parallax_cache>> parallax_cache = std::nullopt ) const;
int most_accurate_aiming_method_limit( const item &gun ) const;
double aim_factor_from_volume( const item &gun ) const;
double aim_factor_from_length( const item &gun ) const;
aim_mods_cache gen_aim_mods_cache( const item &gun )const;
// Get the value of the specified character modifier.
// (some modifiers require a skill_id, ex: aim_speed_skill_mod)
float get_modifier( const character_modifier_id &mod,
const skill_id &skill = skill_id::NULL_ID() ) const;
/* Gun stuff */
/**
* Check whether the player has a gun that uses the given type of ammo.
*/
bool has_gun_for_ammo( const ammotype &at ) const;
bool has_magazine_for_ammo( const ammotype &at ) const;
/* Calculate aim improvement per move spent aiming at a given @ref recoil
* Use a struct to avoid repeatedly calculate some modifiers that are actually persistent for aiming UI drawing.
*/
double aim_per_move( const item &gun, double recoil,
const Target_attributes &target_attributes = Target_attributes(),
std::optional<std::reference_wrapper<const aim_mods_cache>> aim_cache = std::nullopt ) const;
int get_dodges_left() const;
void set_dodges_left( int dodges );
void mod_dodges_left( int mod );
void consume_dodge_attempts();
ret_val<void> can_try_dodge( bool ignore_dodges_left = false ) const;
float get_stamina_dodge_modifier() const;
/** Called after the player has successfully dodged an attack */
void on_dodge( Creature *source, float difficulty, float training_level = 0.0f ) override;
/** Called after the player has tryed to dodge an attack */
void on_try_dodge() override;
/** Combat getters */
float get_dodge_base() const override;
/** Returns the player's dodge_roll to be compared against an aggressor's hit_roll() */
float dodge_roll() const override;
/** Returns Creature::get_dodge() modified by any Character effects */
float get_dodge() const override;
/** in this case spell resistance is just the spellcraft skill for characters. */
int get_spell_resist() const override;
/** Handles the uncanny dodge bionic and effects, returns true if the player successfully dodges */
bool uncanny_dodge() override;
bool check_avoid_friendly_fire() const override;
float get_hit_base() const override;
/** total hitsize of all non cybernetic body parts */
void tally_organic_size();
float get_cached_organic_size() const;
/** Called on limb change to update the usage values */
void recalc_limb_energy_usage();
/** Returns the player's sight range */
int sight_range( float light_level ) const override;
/** Returns the player maximum vision range factoring in mutations, diseases, and other effects */
int unimpaired_range() const;
/** Returns true if overmap tile is within player line-of-sight */
bool overmap_los( const tripoint_abs_omt &omt, int sight_points ) const;
/** Returns the distance the player can see on the overmap */
int overmap_sight_range( float light_level ) const;
/** Returns the distance the player can see on the overmap, modified by zoom & height */
int overmap_modified_sight_range( float light_level ) const;
/** Returns the distance the player can see through walls */
int clairvoyance() const;
/** Returns true if the player has some form of impaired sight */
bool sight_impaired() const;
/** Returns true if the player or their vehicle has an alarm clock */
bool has_alarm_clock() const;
/** Returns true if the player or their vehicle has a watch */
bool has_watch() const;
/** Called after every action, invalidates player caches */
void action_taken();
/** Returns true if the player is knocked over, has broken legs or is lying down */
bool is_on_ground() const override;
/** Returns the player's movecost for swimming across water tiles. NOT SPEED! */
int swim_speed() const;
/** Returns melee skill level, to be used to throttle dodge practice. **/
float get_melee() const override;
/**
* @brief Adds a reason for why the player would miss a melee attack.
*
* @details To possibly be messaged to the player when he misses a melee attack.
* @param reason A message for the player that gives a reason for him missing.
* @param weight The weight used when choosing what reason to pick when the
* player misses.
*/
void add_miss_reason( const std::string &reason, unsigned int weight );
/** Clears the list of reasons for why the player would miss a melee attack. */
void clear_miss_reasons();
/**
* Returns an explanation for why the player would miss a melee attack.
*/
std::string get_miss_reason();
/**
* Handles passive regeneration of pain and maybe hp.
*/
void regen( int rate_multiplier );
/**
* Check player capable of taking off an item.
* @param it Thing to be taken off
*/
ret_val<void> can_takeoff( const item &it, const std::list<item> *res = nullptr );
/** @return Odds for success (pair.first) and gunmod damage (pair.second) */
std::pair<int, int> gunmod_installation_odds( const item_location &gun, const item &mod ) const;
/** Calculates the various speed bonuses we will get from mutations, etc. */
void recalc_speed_bonus();
void set_underwater( bool );
bool is_hallucination() const override;
// true if the character produces electrical radiation
bool is_electrical() const override;
// true if the character is a faerie creature (has the FAE_CREATURE flag or the trait FAERIECREATURE)
bool is_fae() const override;
// true if the character is from the nether
bool is_nether() const override;
// true if the character has a sapient mind
bool has_mind() const override;
/** Returns the penalty to speed from thirst */
static int thirst_speed_penalty( int thirst );
/** Returns the effect of pain on stats */
stat_mod get_pain_penalty() const;
stat_mod read_pain_penalty() const;
/** returns players strength adjusted by any traits that affect strength during lifting jobs */
int get_lift_str() const;
/** Takes off an item, returning false on fail. The taken off item is processed in the interact */
bool takeoff( item_location loc, std::list<item> *res = nullptr );
bool takeoff( int pos );
/** Handles health fluctuations over time */
virtual void update_health();
/** Updates all "biology" by one turn. Should be called once every turn. */
void update_body();
/** Updates all "biology" as if time between `from` and `to` passed. */
void update_body( const time_point &from, const time_point &to );
/** Updates the stomach to give accurate hunger messages */
void update_stomach( const time_point &from, const time_point &to );
/** Updates the mutations from enchantments */
void update_enchantment_mutations();
/** Returns true if character needs food, false if character is an NPC with NO_NPC_FOOD set */
bool needs_food() const;
/** Increases hunger, thirst, sleepiness and stimulants wearing off. `rate_multiplier` is for retroactive updates. */
void update_needs( int rate_multiplier );
needs_rates calc_needs_rates() const;
void calc_sleep_recovery_rate( needs_rates &rates ) const;
/** Kills the player if too hungry, stimmed up etc., forces tired player to sleep and prints warnings. */
void check_needs_extremes();
/** Handles the chance to be infected by random diseases */
void get_sick( bool is_flu = false );
/** Returns if the player has hibernation mutation and is asleep and well fed */
bool is_hibernating() const;
/** Maintains body temperature */
void update_bodytemp();
void update_frostbite( const bodypart_id &bp, int FBwindPower,
const std::map<bodypart_id, int> &warmth_per_bp );
/** Equalizes heat between body parts */
void temp_equalizer( const bodypart_id &bp1, const bodypart_id &bp2 );
/** Returns focus equilibrium cap due to sleepiness **/
int focus_equilibrium_sleepiness_cap( int equilibrium ) const;
/** Uses morale and other factors to return the character's focus target goto value */
int calc_focus_equilibrium( bool ignore_pain = false ) const;
/** Calculates actual focus gain/loss value from focus equilibrium*/
int calc_focus_change() const;
/** Uses calc_focus_change to update the character's current focus */
void update_mental_focus();
/** Resets the value of all bonus fields to 0. */
void reset_bonuses() override;
/** Resets stats, and applies effects in an idempotent manner */
void reset_stats() override;
/** Handles stat and bonus reset. */
void reset() override;
/** Returns ENC provided by armor, etc. */
int encumb( const bodypart_id &bp ) const;
int avg_encumb_of_limb_type( body_part_type::type part_type ) const;
/** Returns body weight plus weight of inventory and worn/wielded items */
units::mass get_weight() const override;
// formats and prints encumbrance info to specified window
void print_encumbrance( ui_adaptor &ui, const catacurses::window &win, int line = -1,
const item *selected_clothing = nullptr ) const;
/** Returns true if the character is wearing power armor */
bool is_wearing_power_armor( bool *hasHelmet = nullptr ) const;
/** Returns true if the character is wearing active power */
bool is_wearing_active_power_armor() const;
/** Returns true if the player is wearing an active optical cloak */
bool is_wearing_active_optcloak() const;
/** Returns strength of any climate control affecting character, for heating and chilling respectively */
std::pair<int, int> climate_control_strength() const;