-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathcharacter.cpp
12993 lines (11501 loc) · 467 KB
/
character.cpp
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
#include "character.h"
#include <algorithm>
#include <array>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <functional>
#include <iterator>
#include <memory>
#include <numeric>
#include <ostream>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "action.h"
#include "activity_actor_definitions.h"
#include "activity_handlers.h"
#include "ammo.h"
#include "anatomy.h"
#include "avatar.h"
#include "avatar_action.h"
#include "bionics.h"
#include "cached_options.h"
#include "cata_utility.h"
#include "catacharset.h"
#include "character_attire.h"
#include "character_martial_arts.h"
#include "clzones.h"
#include "colony.h"
#include "color.h"
#include "construction.h"
#include "coordinate_conversions.h"
#include "coordinates.h"
#include "creature_tracker.h"
#include "cursesdef.h"
#include "disease.h"
#include "display.h"
#include "effect.h"
#include "effect_on_condition.h"
#include "effect_source.h"
#include "enums.h"
#include "event.h"
#include "event_bus.h"
#include "fault.h"
#include "field.h"
#include "field_type.h"
#include "fire.h"
#include "flag.h"
#include "fungal_effects.h"
#include "game.h"
#include "game_constants.h"
#include "gun_mode.h"
#include "handle_liquid.h"
#include "input.h"
#include "inventory.h"
#include "item_location.h"
#include "item_pocket.h"
#include "item_stack.h"
#include "itype.h"
#include "iuse.h"
#include "iuse_actor.h"
#include "json.h"
#include "lightmap.h"
#include "line.h"
#include "magic.h"
#include "magic_enchantment.h"
#include "make_static.h"
#include "map.h"
#include "map_iterator.h"
#include "map_selector.h"
#include "mapdata.h"
#include "material.h"
#include "math_defines.h"
#include "memorial_logger.h"
#include "messages.h"
#include "mission.h"
#include "monster.h"
#include "morale.h"
#include "morale_types.h"
#include "move_mode.h"
#include "mtype.h"
#include "mutation.h"
#include "npc.h"
#include "omdata.h"
#include "options.h"
#include "output.h"
#include "overlay_ordering.h"
#include "overmapbuffer.h"
#include "pathfinding.h"
#include "profession.h"
#include "proficiency.h"
#include "recipe_dictionary.h"
#include "ret_val.h"
#include "rng.h"
#include "scent_map.h"
#include "skill.h"
#include "skill_boost.h"
#include "sounds.h"
#include "stomach.h"
#include "string_formatter.h"
#include "submap.h"
#include "text_snippets.h"
#include "translations.h"
#include "trap.h"
#include "ui.h"
#include "ui_manager.h"
#include "units.h"
#include "value_ptr.h"
#include "veh_type.h"
#include "vehicle.h"
#include "vehicle_selector.h"
#include "viewer.h"
#include "vitamin.h"
#include "vpart_position.h"
#include "vpart_range.h"
#include "weakpoint.h"
#include "weather.h"
#include "weather_gen.h"
#include "weather_type.h"
struct dealt_projectile_attack;
static const activity_id ACT_ADV_INVENTORY( "ACT_ADV_INVENTORY" );
static const activity_id ACT_AUTODRIVE( "ACT_AUTODRIVE" );
static const activity_id ACT_CONSUME_DRINK_MENU( "ACT_CONSUME_DRINK_MENU" );
static const activity_id ACT_CONSUME_FOOD_MENU( "ACT_CONSUME_FOOD_MENU" );
static const activity_id ACT_CONSUME_MEDS_MENU( "ACT_CONSUME_MEDS_MENU" );
static const activity_id ACT_EAT_MENU( "ACT_EAT_MENU" );
static const activity_id ACT_FISH( "ACT_FISH" );
static const activity_id ACT_GAME( "ACT_GAME" );
static const activity_id ACT_HAND_CRANK( "ACT_HAND_CRANK" );
static const activity_id ACT_HEATING( "ACT_HEATING" );
static const activity_id ACT_MEDITATE( "ACT_MEDITATE" );
static const activity_id ACT_MEND_ITEM( "ACT_MEND_ITEM" );
static const activity_id ACT_MOVE_ITEMS( "ACT_MOVE_ITEMS" );
static const activity_id ACT_OPERATION( "ACT_OPERATION" );
static const activity_id ACT_READ( "ACT_READ" );
static const activity_id ACT_SOCIALIZE( "ACT_SOCIALIZE" );
static const activity_id ACT_STUDY_SPELL( "ACT_STUDY_SPELL" );
static const activity_id ACT_TOOLMOD_ADD( "ACT_TOOLMOD_ADD" );
static const activity_id ACT_TRAVELLING( "ACT_TRAVELLING" );
static const activity_id ACT_TREE_COMMUNION( "ACT_TREE_COMMUNION" );
static const activity_id ACT_TRY_SLEEP( "ACT_TRY_SLEEP" );
static const activity_id ACT_VIBE( "ACT_VIBE" );
static const activity_id ACT_VIEW_RECIPE( "ACT_VIEW_RECIPE" );
static const activity_id ACT_WAIT( "ACT_WAIT" );
static const activity_id ACT_WAIT_NPC( "ACT_WAIT_NPC" );
static const activity_id ACT_WAIT_STAMINA( "ACT_WAIT_STAMINA" );
static const addiction_id addiction_opiate( "opiate" );
static const addiction_id addiction_sleeping_pill( "sleeping pill" );
static const ammotype ammo_battery( "battery" );
static const anatomy_id anatomy_human_anatomy( "human_anatomy" );
static const bionic_id afs_bio_linguistic_coprocessor( "afs_bio_linguistic_coprocessor" );
static const bionic_id bio_gills( "bio_gills" );
static const bionic_id bio_ground_sonar( "bio_ground_sonar" );
static const bionic_id bio_hydraulics( "bio_hydraulics" );
static const bionic_id bio_memory( "bio_memory" );
static const bionic_id bio_ods( "bio_ods" );
static const bionic_id bio_railgun( "bio_railgun" );
static const bionic_id bio_shock_absorber( "bio_shock_absorber" );
static const bionic_id bio_sleep_shutdown( "bio_sleep_shutdown" );
static const bionic_id bio_soporific( "bio_soporific" );
static const bionic_id bio_synlungs( "bio_synlungs" );
static const bionic_id bio_uncanny_dodge( "bio_uncanny_dodge" );
static const bionic_id bio_ups( "bio_ups" );
static const bionic_id bio_voice( "bio_voice" );
static const character_modifier_id character_modifier_aim_speed_dex_mod( "aim_speed_dex_mod" );
static const character_modifier_id character_modifier_aim_speed_mod( "aim_speed_mod" );
static const character_modifier_id character_modifier_aim_speed_skill_mod( "aim_speed_skill_mod" );
static const character_modifier_id character_modifier_bleed_staunch_mod( "bleed_staunch_mod" );
static const character_modifier_id
character_modifier_crawl_speed_movecost_mod( "crawl_speed_movecost_mod" );
static const character_modifier_id character_modifier_limb_fall_mod( "limb_fall_mod" );
static const character_modifier_id character_modifier_limb_run_cost_mod( "limb_run_cost_mod" );
static const character_modifier_id character_modifier_limb_str_mod( "limb_str_mod" );
static const character_modifier_id
character_modifier_melee_stamina_cost_mod( "melee_stamina_cost_mod" );
static const character_modifier_id
character_modifier_move_mode_move_cost_mod( "move_mode_move_cost_mod" );
static const character_modifier_id
character_modifier_ranged_dispersion_vision_mod( "ranged_dispersion_vision_mod" );
static const character_modifier_id
character_modifier_stamina_move_cost_mod( "stamina_move_cost_mod" );
static const character_modifier_id
character_modifier_stamina_recovery_breathing_mod( "stamina_recovery_breathing_mod" );
static const character_modifier_id character_modifier_swim_mod( "swim_mod" );
static const damage_type_id damage_acid( "acid" );
static const damage_type_id damage_bash( "bash" );
static const damage_type_id damage_cut( "cut" );
static const damage_type_id damage_electric( "electric" );
static const damage_type_id damage_heat( "heat" );
static const damage_type_id damage_stab( "stab" );
static const effect_on_condition_id effect_on_condition_add_effect( "add_effect" );
static const efftype_id effect_adrenaline( "adrenaline" );
static const efftype_id effect_alarm_clock( "alarm_clock" );
static const efftype_id effect_bandaged( "bandaged" );
static const efftype_id effect_beartrap( "beartrap" );
static const efftype_id effect_bite( "bite" );
static const efftype_id effect_bleed( "bleed" );
static const efftype_id effect_blind( "blind" );
static const efftype_id effect_blood_spiders( "blood_spiders" );
static const efftype_id effect_bloodworms( "bloodworms" );
static const efftype_id effect_boomered( "boomered" );
static const efftype_id effect_brainworms( "brainworms" );
static const efftype_id effect_chafing( "chafing" );
static const efftype_id effect_common_cold( "common_cold" );
static const efftype_id effect_conjunctivitis_bacterial( "conjunctivitis_bacterial" );
static const efftype_id effect_conjunctivitis_viral( "conjunctivitis_viral" );
static const efftype_id effect_contacts( "contacts" );
static const efftype_id effect_controlled( "controlled" );
static const efftype_id effect_corroding( "corroding" );
static const efftype_id effect_cough_suppress( "cough_suppress" );
static const efftype_id effect_darkness( "darkness" );
static const efftype_id effect_deaf( "deaf" );
static const efftype_id effect_dermatik( "dermatik" );
static const efftype_id effect_disinfected( "disinfected" );
static const efftype_id effect_disrupted_sleep( "disrupted_sleep" );
static const efftype_id effect_downed( "downed" );
static const efftype_id effect_drunk( "drunk" );
static const efftype_id effect_earphones( "earphones" );
static const efftype_id effect_flu( "flu" );
static const efftype_id effect_foodpoison( "foodpoison" );
static const efftype_id effect_fungus( "fungus" );
static const efftype_id effect_glowing( "glowing" );
static const efftype_id effect_glowy_led( "glowy_led" );
static const efftype_id effect_harnessed( "harnessed" );
static const efftype_id effect_heavysnare( "heavysnare" );
static const efftype_id effect_in_pit( "in_pit" );
static const efftype_id effect_incorporeal( "incorporeal" );
static const efftype_id effect_infected( "infected" );
static const efftype_id effect_jetinjector( "jetinjector" );
static const efftype_id effect_lack_sleep( "lack_sleep" );
static const efftype_id effect_lying_down( "lying_down" );
static const efftype_id effect_masked_scent( "masked_scent" );
static const efftype_id effect_melatonin( "melatonin" );
static const efftype_id effect_mending( "mending" );
static const efftype_id effect_meth( "meth" );
static const efftype_id effect_monster_saddled( "monster_saddled" );
static const efftype_id effect_mute( "mute" );
static const efftype_id effect_narcosis( "narcosis" );
static const efftype_id effect_nausea( "nausea" );
static const efftype_id effect_no_sight( "no_sight" );
static const efftype_id effect_onfire( "onfire" );
static const efftype_id effect_paincysts( "paincysts" );
static const efftype_id effect_pkill1( "pkill1" );
static const efftype_id effect_pkill2( "pkill2" );
static const efftype_id effect_pkill3( "pkill3" );
static const efftype_id effect_pre_conjunctivitis_bacterial( "pre_conjunctivitis_bacterial" );
static const efftype_id effect_pre_conjunctivitis_viral( "pre_conjunctivitis_viral" );
static const efftype_id effect_recently_coughed( "recently_coughed" );
static const efftype_id effect_recover( "recover" );
static const efftype_id effect_ridden( "ridden" );
static const efftype_id effect_riding( "riding" );
static const efftype_id effect_sleep( "sleep" );
static const efftype_id effect_slept_through_alarm( "slept_through_alarm" );
static const efftype_id effect_slippery_terrain( "slippery_terrain" );
static const efftype_id effect_stumbled_into_invisible( "stumbled_into_invisible" );
static const efftype_id effect_stunned( "stunned" );
static const efftype_id effect_tapeworm( "tapeworm" );
static const efftype_id effect_tied( "tied" );
static const efftype_id effect_weed_high( "weed_high" );
static const efftype_id effect_winded( "winded" );
static const faction_id faction_no_faction( "no_faction" );
static const fault_id fault_bionic_salvaged( "fault_bionic_salvaged" );
static const field_type_str_id field_fd_clairvoyant( "fd_clairvoyant" );
static const furn_str_id furn_f_null( "f_null" );
static const itype_id fuel_type_animal( "animal" );
static const itype_id fuel_type_muscle( "muscle" );
static const itype_id itype_UPS( "UPS" );
static const itype_id itype_apparatus( "apparatus" );
static const itype_id itype_battery( "battery" );
static const itype_id itype_cookbook_human( "cookbook_human" );
static const itype_id itype_e_handcuffs( "e_handcuffs" );
static const itype_id itype_fire( "fire" );
static const itype_id itype_foodperson_mask( "foodperson_mask" );
static const itype_id itype_foodperson_mask_on( "foodperson_mask_on" );
static const itype_id itype_null( "null" );
static const itype_id itype_rm13_armor_on( "rm13_armor_on" );
static const json_character_flag json_flag_ACIDBLOOD( "ACIDBLOOD" );
static const json_character_flag json_flag_ALARMCLOCK( "ALARMCLOCK" );
static const json_character_flag json_flag_ALWAYS_HEAL( "ALWAYS_HEAL" );
static const json_character_flag json_flag_BLIND( "BLIND" );
static const json_character_flag json_flag_CLAIRVOYANCE( "CLAIRVOYANCE" );
static const json_character_flag json_flag_CLAIRVOYANCE_PLUS( "CLAIRVOYANCE_PLUS" );
static const json_character_flag json_flag_DEAF( "DEAF" );
static const json_character_flag json_flag_ECTOTHERM( "ECTOTHERM" );
static const json_character_flag json_flag_ENHANCED_VISION( "ENHANCED_VISION" );
static const json_character_flag json_flag_EYE_MEMBRANE( "EYE_MEMBRANE" );
static const json_character_flag json_flag_FEATHER_FALL( "FEATHER_FALL" );
static const json_character_flag json_flag_GRAB( "GRAB" );
static const json_character_flag json_flag_HEAL_OVERRIDE( "HEAL_OVERRIDE" );
static const json_character_flag json_flag_HEATSINK( "HEATSINK" );
static const json_character_flag json_flag_HYPEROPIC( "HYPEROPIC" );
static const json_character_flag json_flag_IMMUNE_HEARING_DAMAGE( "IMMUNE_HEARING_DAMAGE" );
static const json_character_flag json_flag_INFECTION_IMMUNE( "INFECTION_IMMUNE" );
static const json_character_flag json_flag_INFRARED( "INFRARED" );
static const json_character_flag json_flag_INSECTBLOOD( "INSECTBLOOD" );
static const json_character_flag json_flag_INVERTEBRATEBLOOD( "INVERTEBRATEBLOOD" );
static const json_character_flag json_flag_INVISIBLE( "INVISIBLE" );
static const json_character_flag json_flag_MYOPIC( "MYOPIC" );
static const json_character_flag json_flag_MYOPIC_IN_LIGHT( "MYOPIC_IN_LIGHT" );
static const json_character_flag json_flag_NIGHT_VISION( "NIGHT_VISION" );
static const json_character_flag json_flag_NON_THRESH( "NON_THRESH" );
static const json_character_flag json_flag_NO_RADIATION( "NO_RADIATION" );
static const json_character_flag json_flag_NO_THIRST( "NO_THIRST" );
static const json_character_flag json_flag_PAIN_IMMUNE( "PAIN_IMMUNE" );
static const json_character_flag json_flag_PLANTBLOOD( "PLANTBLOOD" );
static const json_character_flag json_flag_PRED2( "PRED2" );
static const json_character_flag json_flag_PRED3( "PRED3" );
static const json_character_flag json_flag_PRED4( "PRED4" );
static const json_character_flag json_flag_SEESLEEP( "SEESLEEP" );
static const json_character_flag json_flag_STEADY( "STEADY" );
static const json_character_flag json_flag_STOP_SLEEP_DEPRIVATION( "STOP_SLEEP_DEPRIVATION" );
static const json_character_flag json_flag_SUPER_CLAIRVOYANCE( "SUPER_CLAIRVOYANCE" );
static const json_character_flag json_flag_SUPER_HEARING( "SUPER_HEARING" );
static const json_character_flag json_flag_TOUGH_FEET( "TOUGH_FEET" );
static const json_character_flag json_flag_UNCANNY_DODGE( "UNCANNY_DODGE" );
static const json_character_flag json_flag_WALK_UNDERWATER( "WALK_UNDERWATER" );
static const json_character_flag json_flag_WATCH( "WATCH" );
static const json_character_flag json_flag_WEBBED_FEET( "WEBBED_FEET" );
static const json_character_flag json_flag_WEBBED_HANDS( "WEBBED_HANDS" );
static const limb_score_id limb_score_balance( "balance" );
static const limb_score_id limb_score_breathing( "breathing" );
static const limb_score_id limb_score_footing( "footing" );
static const limb_score_id limb_score_grip( "grip" );
static const limb_score_id limb_score_lift( "lift" );
static const limb_score_id limb_score_manip( "manip" );
static const limb_score_id limb_score_night_vis( "night_vis" );
static const limb_score_id limb_score_reaction( "reaction" );
static const limb_score_id limb_score_vision( "vision" );
static const matec_id tec_none( "tec_none" );
static const material_id material_budget_steel( "budget_steel" );
static const material_id material_ch_steel( "ch_steel" );
static const material_id material_flesh( "flesh" );
static const material_id material_hc_steel( "hc_steel" );
static const material_id material_hflesh( "hflesh" );
static const material_id material_iron( "iron" );
static const material_id material_lc_steel( "lc_steel" );
static const material_id material_mc_steel( "mc_steel" );
static const material_id material_qt_steel( "qt_steel" );
static const material_id material_steel( "steel" );
static const mon_flag_str_id mon_flag_COMBAT_MOUNT( "COMBAT_MOUNT" );
static const mon_flag_str_id mon_flag_LOUDMOVES( "LOUDMOVES" );
static const mon_flag_str_id mon_flag_MECH_RECON_VISION( "MECH_RECON_VISION" );
static const mon_flag_str_id mon_flag_RIDEABLE_MECH( "RIDEABLE_MECH" );
static const morale_type morale_cold( "morale_cold" );
static const morale_type morale_hot( "morale_hot" );
static const move_mode_id move_mode_prone( "prone" );
static const move_mode_id move_mode_walk( "walk" );
static const mtype_id mon_player_blob( "mon_player_blob" );
static const proficiency_id proficiency_prof_parkour( "prof_parkour" );
static const proficiency_id proficiency_prof_spotting( "prof_spotting" );
static const proficiency_id proficiency_prof_traps( "prof_traps" );
static const proficiency_id proficiency_prof_trapsetting( "prof_trapsetting" );
static const proficiency_id proficiency_prof_wound_care( "prof_wound_care" );
static const proficiency_id proficiency_prof_wound_care_expert( "prof_wound_care_expert" );
static const quality_id qual_DRILL( "DRILL" );
static const quality_id qual_HAMMER( "HAMMER" );
static const quality_id qual_LIFT( "LIFT" );
static const quality_id qual_SCREW( "SCREW" );
static const scenttype_id scent_sc_human( "sc_human" );
static const skill_id skill_archery( "archery" );
static const skill_id skill_dodge( "dodge" );
static const skill_id skill_driving( "driving" );
static const skill_id skill_melee( "melee" );
static const skill_id skill_pistol( "pistol" );
static const skill_id skill_speech( "speech" );
static const skill_id skill_swimming( "swimming" );
static const skill_id skill_throw( "throw" );
static const species_id species_HUMAN( "HUMAN" );
static const start_location_id start_location_sloc_shelter_a( "sloc_shelter_a" );
static const trait_id trait_ADRENALINE( "ADRENALINE" );
static const trait_id trait_ANTENNAE( "ANTENNAE" );
static const trait_id trait_AQUEOUS( "AQUEOUS" );
static const trait_id trait_BADBACK( "BADBACK" );
static const trait_id trait_BIRD_EYE( "BIRD_EYE" );
static const trait_id trait_BOOMING_VOICE( "BOOMING_VOICE" );
static const trait_id trait_CANNIBAL( "CANNIBAL" );
static const trait_id trait_CENOBITE( "CENOBITE" );
static const trait_id trait_CEPH_VISION( "CEPH_VISION" );
static const trait_id trait_CF_HAIR( "CF_HAIR" );
static const trait_id trait_CHEMIMBALANCE( "CHEMIMBALANCE" );
static const trait_id trait_CHLOROMORPH( "CHLOROMORPH" );
static const trait_id trait_CLUMSY( "CLUMSY" );
static const trait_id trait_COMPOUND_EYES( "COMPOUND_EYES" );
static const trait_id trait_DEBUG_CLOAK( "DEBUG_CLOAK" );
static const trait_id trait_DEBUG_HS( "DEBUG_HS" );
static const trait_id trait_DEBUG_LS( "DEBUG_LS" );
static const trait_id trait_DEBUG_NIGHTVISION( "DEBUG_NIGHTVISION" );
static const trait_id trait_DEBUG_NODMG( "DEBUG_NODMG" );
static const trait_id trait_DEBUG_SILENT( "DEBUG_SILENT" );
static const trait_id trait_DEBUG_STAMINA( "DEBUG_STAMINA" );
static const trait_id trait_DEFT( "DEFT" );
static const trait_id trait_DISRESISTANT( "DISRESISTANT" );
static const trait_id trait_DOWN( "DOWN" );
static const trait_id trait_EATHEALTH( "EATHEALTH" );
static const trait_id trait_ELFA_FNV( "ELFA_FNV" );
static const trait_id trait_ELFA_NV( "ELFA_NV" );
static const trait_id trait_FAT( "FAT" );
static const trait_id trait_FEL_NV( "FEL_NV" );
static const trait_id trait_GILLS( "GILLS" );
static const trait_id trait_GILLS_CEPH( "GILLS_CEPH" );
static const trait_id trait_GLASSJAW( "GLASSJAW" );
static const trait_id trait_HATES_BOOKS( "HATES_BOOKS" );
static const trait_id trait_HEAVYSLEEPER( "HEAVYSLEEPER" );
static const trait_id trait_HEAVYSLEEPER2( "HEAVYSLEEPER2" );
static const trait_id trait_HIBERNATE( "HIBERNATE" );
static const trait_id trait_ILLITERATE( "ILLITERATE" );
static const trait_id trait_INFRESIST( "INFRESIST" );
static const trait_id trait_INSOMNIA( "INSOMNIA" );
static const trait_id trait_INT_SLIME( "INT_SLIME" );
static const trait_id trait_LEG_TENT_BRACE( "LEG_TENT_BRACE" );
static const trait_id trait_LIGHTSTEP( "LIGHTSTEP" );
static const trait_id trait_LOVES_BOOKS( "LOVES_BOOKS" );
static const trait_id trait_MASOCHIST( "MASOCHIST" );
static const trait_id trait_MUCUS_SECRETION( "MUCUS_SECRETION" );
static const trait_id trait_MUTE( "MUTE" );
static const trait_id trait_M_IMMUNE( "M_IMMUNE" );
static const trait_id trait_M_SKIN3( "M_SKIN3" );
static const trait_id trait_NIGHTVISION( "NIGHTVISION" );
static const trait_id trait_NIGHTVISION2( "NIGHTVISION2" );
static const trait_id trait_NIGHTVISION3( "NIGHTVISION3" );
static const trait_id trait_NOMAD( "NOMAD" );
static const trait_id trait_NOMAD2( "NOMAD2" );
static const trait_id trait_NOMAD3( "NOMAD3" );
static const trait_id trait_PACIFIST( "PACIFIST" );
static const trait_id trait_PADDED_FEET( "PADDED_FEET" );
static const trait_id trait_PARAIMMUNE( "PARAIMMUNE" );
static const trait_id trait_PAWS( "PAWS" );
static const trait_id trait_PAWS_LARGE( "PAWS_LARGE" );
static const trait_id trait_PER_SLIME( "PER_SLIME" );
static const trait_id trait_PER_SLIME_OK( "PER_SLIME_OK" );
static const trait_id trait_PROF_DICEMASTER( "PROF_DICEMASTER" );
static const trait_id trait_PROF_FOODP( "PROF_FOODP" );
static const trait_id trait_PROF_SKATER( "PROF_SKATER" );
static const trait_id trait_PSYCHOPATH( "PSYCHOPATH" );
static const trait_id trait_QUILLS( "QUILLS" );
static const trait_id trait_ROOTS2( "ROOTS2" );
static const trait_id trait_ROOTS3( "ROOTS3" );
static const trait_id trait_SAPIOVORE( "SAPIOVORE" );
static const trait_id trait_SAVANT( "SAVANT" );
static const trait_id trait_SHELL2( "SHELL2" );
static const trait_id trait_SHELL3( "SHELL3" );
static const trait_id trait_SHOUT2( "SHOUT2" );
static const trait_id trait_SHOUT3( "SHOUT3" );
static const trait_id trait_SLIMESPAWNER( "SLIMESPAWNER" );
static const trait_id trait_SLIMY( "SLIMY" );
static const trait_id trait_SPINES( "SPINES" );
static const trait_id trait_SPIRITUAL( "SPIRITUAL" );
static const trait_id trait_STRONGBACK( "STRONGBACK" );
static const trait_id trait_SUNLIGHT_DEPENDENT( "SUNLIGHT_DEPENDENT" );
static const trait_id trait_THORNS( "THORNS" );
static const trait_id trait_THRESH_BEAST( "THRESH_BEAST" );
static const trait_id trait_THRESH_FELINE( "THRESH_FELINE" );
static const trait_id trait_THRESH_LUPINE( "THRESH_LUPINE" );
static const trait_id trait_THRESH_SPIDER( "THRESH_SPIDER" );
static const trait_id trait_TRANSPIRATION( "TRANSPIRATION" );
static const trait_id trait_URSINE_EYE( "URSINE_EYE" );
static const trait_id trait_VISCOUS( "VISCOUS" );
static const trait_id trait_WATERSLEEP( "WATERSLEEP" );
static const trait_id trait_WEB_SPINNER( "WEB_SPINNER" );
static const trait_id trait_WEB_WALKER( "WEB_WALKER" );
static const trait_id trait_WEB_WEAVER( "WEB_WEAVER" );
static const vitamin_id vitamin_calcium( "calcium" );
static const vitamin_id vitamin_iron( "iron" );
static const std::set<material_id> ferric = { material_iron, material_steel, material_budget_steel, material_ch_steel, material_hc_steel, material_lc_steel, material_mc_steel, material_qt_steel };
namespace io
{
template<>
std::string enum_to_string<blood_type>( blood_type data )
{
switch( data ) {
// *INDENT-OFF*
case blood_type::blood_O: return "O";
case blood_type::blood_A: return "A";
case blood_type::blood_B: return "B";
case blood_type::blood_AB: return "AB";
// *INDENT-ON*
case blood_type::num_bt:
break;
}
cata_fatal( "Invalid blood_type" );
}
} // namespace io
void Character::queue_effect( const std::string &name, const time_duration &delay,
const time_duration &effect_duration )
{
std::unordered_map<std::string, std::string> ctx = {
{ "npctalk_var_effect", name },
{ "npctalk_var_duration", std::to_string( to_turns<int>( effect_duration ) ) }
};
effect_on_conditions::queue_effect_on_condition( delay, effect_on_condition_add_effect, *this,
ctx );
}
int Character::count_queued_effects( const std::string &effect ) const
{
return std::count_if( queued_effect_on_conditions.list.begin(),
queued_effect_on_conditions.list.end(), [&effect]( const queued_eoc & eoc ) {
return eoc.eoc == effect_on_condition_add_effect &&
eoc.context.at( "npctalk_var_effect" ) == effect;
} );
}
// *INDENT-OFF*
Character::Character() :
id( -1 ),
next_climate_control_check( calendar::before_time_starts ),
last_climate_control_ret( false )
{
randomize_blood();
str_cur = 8;
str_max = 8;
dex_cur = 8;
dex_max = 8;
int_cur = 8;
int_max = 8;
per_cur = 8;
per_max = 8;
set_dodges_left(1);
blocks_left = 1;
str_bonus = 0;
dex_bonus = 0;
per_bonus = 0;
int_bonus = 0;
lifestyle = 0;
daily_health = 0;
health_tally = 0;
hunger = 0;
thirst = 0;
fatigue = 0;
sleep_deprivation = 0;
daily_sleep = 0_turns;
continuous_sleep = 0_turns;
radiation = 0;
slow_rad = 0;
set_stim( 0 );
set_stamina( 10000 ); //Temporary value for stamina. It will be reset later from external json option.
cardio_acc = 1000; // Temporary cardio accumulator. It will be updated when reset_cardio_acc is called.
set_anatomy( anatomy_human_anatomy );
update_type_of_scent( true );
pkill = 0;
// 55 Mcal or 55k kcal
healthy_calories = 55'000'000;
base_cardio_acc = 1000;
// this makes sure characters start with normal bmi
stored_calories = healthy_calories - 1'000'000;
initialize_stomach_contents();
name.clear();
custom_profession.clear();
*path_settings = pathfinding_settings{ 0, 1000, 1000, 0, true, true, true, true, false, true };
move_mode = move_mode_walk;
next_expected_position = std::nullopt;
invalidate_crafting_inventory();
set_power_level( 0_kJ );
cash = 0;
scent = 500;
male = true;
prof = profession::has_initialized() ? profession::generic() :
nullptr; //workaround for a potential structural limitation, see player::create
start_location = start_location_sloc_shelter_a;
moves = 100;
oxygen = 0;
in_vehicle = false;
controlling_vehicle = false;
grab_point = tripoint_zero;
hauling = false;
set_focus( 100 );
last_item = itype_null;
sight_max = 9999;
last_batch = 0;
death_drops = true;
nv_cached = false;
leak_level = 0.0f;
leak_level_dirty = true;
volume = 0;
set_value( "THIEF_MODE", "THIEF_ASK" );
for( const auto &v : vitamin::all() ) {
vitamin_levels[ v.first ] = 0;
daily_vitamins[v.first] = { 0,0 };
}
// Only call these if game is initialized
if( !!g && json_flag::is_ready() ) {
recalc_sight_limits();
calc_encumbrance();
worn.recalc_ablative_blocking(this);
}
}
// *INDENT-ON*
Character::~Character() = default;
Character::Character( Character && ) noexcept( map_is_noexcept ) = default;
Character &Character::operator=( Character && ) noexcept( list_is_noexcept ) = default;
void Character::setID( character_id i, bool force )
{
if( id.is_valid() && !force ) {
debugmsg( "tried to set id of a npc/player, but has already a id: %d", id.get_value() );
} else if( !i.is_valid() && !force ) {
debugmsg( "tried to set invalid id of a npc/player: %d", i.get_value() );
} else {
id = i;
}
}
character_id Character::getID() const
{
return this->id;
}
void Character::swap_character( Character &other )
{
npc tmp_npc;
Character &tmp = tmp_npc;
tmp = std::move( other );
other = std::move( *this );
*this = std::move( tmp );
}
void Character::randomize_height()
{
// Height distribution data is taken from CDC distributes statistics for the US population
// https://github.com/CleverRaven/Cataclysm-DDA/pull/49270#issuecomment-861339732
const int x = std::round( normal_roll( 168.35, 15.50 ) );
init_height = clamp( x, Character::min_height(), Character::max_height() );
}
item_location Character::get_wielded_item() const
{
return const_cast<Character *>( this )->get_wielded_item();
}
item_location Character::get_wielded_item()
{
if( weapon.is_null() ) {
return item_location();
}
return item_location( *this, &weapon );
}
void Character::set_wielded_item( const item &to_wield )
{
weapon = to_wield;
}
std::vector<matype_id> Character::known_styles( bool teachable_only ) const
{
return martial_arts_data->get_known_styles( teachable_only );
}
bool Character::has_martialart( const matype_id &m ) const
{
return martial_arts_data->has_martialart( m );
}
int Character::get_oxygen_max() const
{
return 30 + ( has_bionic( bio_synlungs ) ? 30 : 2 * str_cur );
}
bool Character::can_recover_oxygen() const
{
return get_limb_score( limb_score_breathing ) > 0.5f && !is_underwater() &&
!has_effect_with_flag( json_flag_GRAB ) && !( has_bionic( bio_synlungs ) &&
!has_active_bionic( bio_synlungs ) );
}
void Character::randomize_heartrate()
{
avg_nat_bpm = rng_normal( 60, 80 );
}
void Character::randomize_blood()
{
// Blood type distribution data is taken from this study on blood types of
// COVID-19 patients presented to five major hospitals in Massachusetts:
// https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7354354/
// and is adjusted for racial/ethnic distribution in game, which is defined in
// data/json/npcs/appearance_trait_groups.json
static const std::array<std::tuple<double, blood_type, bool>, 8> blood_type_distribution = {{
std::make_tuple( 0.3821, blood_type::blood_O, true ),
std::make_tuple( 0.0387, blood_type::blood_O, false ),
std::make_tuple( 0.3380, blood_type::blood_A, true ),
std::make_tuple( 0.0414, blood_type::blood_A, false ),
std::make_tuple( 0.1361, blood_type::blood_B, true ),
std::make_tuple( 0.0134, blood_type::blood_B, false ),
std::make_tuple( 0.0437, blood_type::blood_AB, true ),
std::make_tuple( 0.0066, blood_type::blood_AB, false )
}
};
const double x = rng_float( 0.0, 1.0 );
double cumulative_prob = 0.0;
for( const std::tuple<double, blood_type, bool> &type : blood_type_distribution ) {
cumulative_prob += std::get<0>( type );
if( x <= cumulative_prob ) {
my_blood_type = std::get<1>( type );
blood_rh_factor = std::get<2>( type );
return;
}
}
my_blood_type = blood_type::blood_AB;
blood_rh_factor = false;
}
field_type_id Character::bloodType() const
{
if( has_flag( json_flag_ACIDBLOOD ) ) {
return fd_acid;
}
if( has_flag( json_flag_PLANTBLOOD ) ) {
return fd_blood_veggy;
}
if( has_flag( json_flag_INSECTBLOOD ) ) {
return fd_blood_insect;
}
if( has_flag( json_flag_INVERTEBRATEBLOOD ) ) {
return fd_blood_invertebrate;
}
return fd_blood;
}
field_type_id Character::gibType() const
{
return fd_gibs_flesh;
}
bool Character::in_species( const species_id &spec ) const
{
return spec == species_HUMAN;
}
bool Character::is_warm() const
{
// TODO: is there a mutation (plant?) that makes a npc not warm blooded?
return true;
}
const std::string &Character::symbol() const
{
static const std::string character_symbol( "@" );
return character_symbol;
}
void Character::mod_stat( const std::string &stat, float modifier )
{
if( stat == "thirst" ) {
mod_thirst( modifier );
} else if( stat == "fatigue" ) {
mod_fatigue( modifier );
} else if( stat == "oxygen" ) {
oxygen += modifier;
} else if( stat == "stamina" ) {
mod_stamina( modifier );
} else if( stat == "str" ) {
mod_str_bonus( modifier );
} else if( stat == "dex" ) {
mod_dex_bonus( modifier );
} else if( stat == "per" ) {
mod_per_bonus( modifier );
} else if( stat == "int" ) {
mod_int_bonus( modifier );
} else if( stat == "healthy" ) {
mod_livestyle( modifier );
} else if( stat == "hunger" ) {
mod_hunger( modifier );
} else {
Creature::mod_stat( stat, modifier );
}
}
int Character::get_fat_to_hp() const
{
float mut_fat_hp = 0.0f;
for( const trait_id &mut : get_mutations() ) {
mut_fat_hp += mut.obj().fat_to_max_hp;
}
return mut_fat_hp * ( get_bmi_fat() - character_weight_category::normal );
}
creature_size Character::get_size() const
{
return size_class;
}
std::string Character::disp_name( bool possessive, bool capitalize_first ) const
{
if( !possessive ) {
if( is_avatar() ) {
return capitalize_first ? _( "You" ) : _( "you" );
}
return get_name();
} else {
if( is_avatar() ) {
return capitalize_first ? _( "Your" ) : _( "your" );
}
return string_format( _( "%s's" ), get_name() );
}
}
std::string Character::name_and_maybe_activity() const
{
return disp_name( false, true );
}
std::string Character::skin_name() const
{
// TODO: Return actual deflecting layer name
return _( "armor" );
}
//message related stuff
void Character::add_msg_if_player( const std::string &msg ) const
{
Messages::add_msg( msg );
}
void Character::add_msg_player_or_npc( const std::string &player_msg,
const std::string &/*npc_msg*/ ) const
{
Messages::add_msg( player_msg );
}
void Character::add_msg_if_player( const game_message_params ¶ms, const std::string &msg ) const
{
Messages::add_msg( params, msg );
}
void Character::add_msg_debug_if_player( debugmode::debug_filter type,
const std::string &msg ) const
{
Messages::add_msg_debug( type, msg );
}
void Character::add_msg_player_or_npc( const game_message_params ¶ms,
const std::string &player_msg,
const std::string &/*npc_msg*/ ) const
{
Messages::add_msg( params, player_msg );
}
void Character::add_msg_debug_player_or_npc( debugmode::debug_filter type,
const std::string &player_msg,
const std::string &/*npc_msg*/ ) const
{
Messages::add_msg_debug( type, player_msg );
}
void Character::add_msg_player_or_say( const std::string &player_msg,
const std::string &/*npc_speech*/ ) const
{
Messages::add_msg( player_msg );
}
void Character::add_msg_player_or_say( const game_message_params ¶ms,
const std::string &player_msg,
const std::string &/*npc_speech*/ ) const
{
Messages::add_msg( params, player_msg );
}
int Character::effective_dispersion( int dispersion, bool zoom ) const
{
return get_character_parallax( zoom ) + dispersion;
}
int Character::get_character_parallax( bool zoom ) const
{
/** @EFFECT_PER penalizes sight dispersion when low. */
int character_parallax = zoom ? static_cast<int>( ranged_per_mod() * 0.25 ) : ranged_per_mod();
character_parallax += get_modifier( character_modifier_ranged_dispersion_vision_mod );
return std::max( static_cast<int>( std::round( character_parallax ) ), 0 );
}
static double modified_sight_speed( double aim_speed_modifier, double effective_sight_dispersion,
double recoil )
{
if( recoil <= effective_sight_dispersion ) {
return 0;
}
// When recoil tends to effective_sight_dispersion, the aiming speed bonus will tend to 0
// When recoil > 3 * effective_sight_dispersion + 1, attenuation_factor = 1
// use 3 * effective_sight_dispersion + 1 instead of 3 * effective_sight_dispersion to avoid min=max
if( effective_sight_dispersion < 0 ) {
return 0;
}
double attenuation_factor = 1 - logarithmic_range( effective_sight_dispersion,
3 * effective_sight_dispersion + 1, recoil );
return ( 10.0 + aim_speed_modifier ) * attenuation_factor;
}
int Character::point_shooting_limit( const item &gun )const
{
// This value is not affected by PER, because the accuracy of aim shooting depends more on muscle memory and skill
skill_id gun_skill = gun.gun_skill();
if( gun_skill == skill_archery ) {
return 30 + 220 / ( 1 + std::min( get_skill_level( gun_skill ), static_cast<float>( MAX_SKILL ) ) );
} else {
return 200 - 10 * std::min( get_skill_level( gun_skill ), static_cast<float>( MAX_SKILL ) );
}
}
aim_mods_cache Character::gen_aim_mods_cache( const item &gun )const
{
parallax_cache parallaxes{ get_character_parallax( true ), get_character_parallax( false ) };
return { get_modifier( character_modifier_aim_speed_skill_mod, gun.gun_skill() ), get_modifier( character_modifier_aim_speed_dex_mod ), get_modifier( character_modifier_aim_speed_mod ), most_accurate_aiming_method_limit( gun ), aim_factor_from_volume( gun ), aim_factor_from_length( gun ), parallaxes };
}
double Character::fastest_aiming_method_speed( const item &gun, double recoil,
const Target_attributes &target_attributes,
const std::optional<std::reference_wrapper<const parallax_cache>> parallax_cache ) const
{
// Get fastest aiming method that can be used to improve aim further below @ref recoil.
skill_id gun_skill = gun.gun_skill();
// aim with instinct (point shooting)
// When it is a negative number, the effect of reducing the aiming speed is very significant.
// When it is a positive number, a large value is needed to significantly increase the aiming speed
double point_shooting_speed_modifier = 0;
if( gun_skill == skill_pistol ) {
point_shooting_speed_modifier = 10 + 4 * get_skill_level( gun_skill );
} else {
point_shooting_speed_modifier = get_skill_level( gun_skill );
}
double aim_speed_modifier = modified_sight_speed( point_shooting_speed_modifier,
point_shooting_limit( gun ), recoil );
// aim with iron sight
if( !gun.has_flag( flag_DISABLE_SIGHTS ) ) {
const int iron_sight_FOV = 480;
int effective_iron_sight_dispersion = effective_dispersion( gun.type->gun->sight_dispersion );
double iron_sight_speed = modified_sight_speed( 0, effective_iron_sight_dispersion, recoil );
if( effective_iron_sight_dispersion < recoil && iron_sight_speed > aim_speed_modifier &&
recoil <= iron_sight_FOV ) {
aim_speed_modifier = iron_sight_speed;
}
}
// aim with other sights
// to check whether laser sights are available
const int base_distance = 10;
const float light_limit = 120.0f;
bool laser_light_available = target_attributes.range <= ( base_distance + per_cur ) * std::max(
1.0f - target_attributes.light / light_limit, 0.0f ) && target_attributes.visible;
// There are only two kinds of parallaxes, one with zoom and one without. So cache them.
std::vector<std::optional<int>> parallaxes;
parallaxes.resize( 2 );
if( parallax_cache.has_value() ) {
parallaxes[0].emplace( parallax_cache.value().get().parallax_without_zoom );
parallaxes[1].emplace( parallax_cache.value().get().parallax_with_zoom );
}
for( const item *e : gun.gunmods() ) {
const islot_gunmod &mod = *e->type->gunmod;