-
Notifications
You must be signed in to change notification settings - Fork 288
/
Copy pathactivity_handlers.cpp
4832 lines (4400 loc) · 184 KB
/
activity_handlers.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 "activity_handlers.h"
#include <climits>
#include <cstddef>
#include <algorithm>
#include <cmath>
#include <queue>
#include <array>
#include <iterator>
#include <memory>
#include <ostream>
#include <set>
#include <stdexcept>
#include <string>
#include <utility>
#include "action.h"
#include "advanced_inv.h"
#include "avatar.h"
#include "avatar_action.h"
#include "cata_string_consts.h"
#include "clzones.h"
#include "construction.h"
#include "coordinate_conversions.h"
#include "craft_command.h"
#include "debug.h"
#include "event_bus.h"
#include "fault.h"
#include "field.h"
#include "game.h"
#include "game_inventory.h"
#include "gates.h"
#include "handle_liquid.h"
#include "harvest.h"
#include "iexamine.h"
#include "itype.h"
#include "iuse_actor.h"
#include "magic.h"
#include "map.h"
#include "map_iterator.h"
#include "mapdata.h"
#include "martialarts.h"
#include "messages.h"
#include "mongroup.h"
#include "morale_types.h"
#include "mtype.h"
#include "npc.h"
#include "npctalk.h"
#include "output.h"
#include "overmapbuffer.h"
#include "player.h"
#include "ranged.h"
#include "recipe.h"
#include "requirements.h"
#include "rng.h"
#include "skill.h"
#include "sounds.h"
#include "string_formatter.h"
#include "text_snippets.h"
#include "translations.h"
#include "ui.h"
#include "uistate.h"
#include "veh_interact.h"
#include "vehicle.h"
#include "vpart_position.h"
#include "map_selector.h"
#include "bodypart.h"
#include "calendar.h"
#include "cata_utility.h"
#include "character.h"
#include "creature.h"
#include "damage.h"
#include "enums.h"
#include "int_id.h"
#include "inventory.h"
#include "item.h"
#include "item_group.h"
#include "item_location.h"
#include "item_stack.h"
#include "iuse.h"
#include "line.h"
#include "monster.h"
#include "omdata.h"
#include "optional.h"
#include "pimpl.h"
#include "pldata.h"
#include "ret_val.h"
#include "string_id.h"
#include "units.h"
#include "type_id.h"
#include "timed_event.h"
#include "options.h"
#include "colony.h"
#include "color.h"
#include "flat_set.h"
#include "game_constants.h"
#include "point.h"
#include "weather.h"
#define dbg(x) DebugLog((x),D_GAME) << __FILE__ << ":" << __LINE__ << ": "
static const activity_id ACT_ADV_INVENTORY( "ACT_ADV_INVENTORY" );
static const activity_id ACT_AIM( "ACT_AIM" );
static const activity_id ACT_ARMOR_LAYERS( "ACT_ARMOR_LAYERS" );
static const activity_id ACT_ATM( "ACT_ATM" );
static const activity_id ACT_AUTODRIVE( "ACT_AUTODRIVE" );
static const activity_id ACT_BUILD( "ACT_BUILD" );
static const activity_id ACT_BURROW( "ACT_BURROW" );
static const activity_id ACT_BUTCHER( "ACT_BUTCHER" );
static const activity_id ACT_BUTCHER_FULL( "ACT_BUTCHER_FULL" );
static const activity_id ACT_CHOP_LOGS( "ACT_CHOP_LOGS" );
static const activity_id ACT_CHOP_PLANKS( "ACT_CHOP_PLANKS" );
static const activity_id ACT_CHOP_TREE( "ACT_CHOP_TREE" );
static const activity_id ACT_CHURN( "ACT_CHURN" );
static const activity_id ACT_CLEAR_RUBBLE( "ACT_CLEAR_RUBBLE" );
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_CRACKING( "ACT_CRACKING" );
static const activity_id ACT_CRAFT( "ACT_CRAFT" );
static const activity_id ACT_DIG( "ACT_DIG" );
static const activity_id ACT_DIG_CHANNEL( "ACT_DIG_CHANNEL" );
static const activity_id ACT_DISASSEMBLE( "ACT_DISASSEMBLE" );
static const activity_id ACT_DISMEMBER( "ACT_DISMEMBER" );
static const activity_id ACT_DISSECT( "ACT_DISSECT" );
static const activity_id ACT_DROP( "ACT_DROP" );
static const activity_id ACT_EAT_MENU( "ACT_EAT_MENU" );
static const activity_id ACT_FERTILIZE_PLOT( "ACT_FERTILIZE_PLOT" );
static const activity_id ACT_FETCH_REQUIRED( "ACT_FETCH_REQUIRED" );
static const activity_id ACT_FIELD_DRESS( "ACT_FIELD_DRESS" );
static const activity_id ACT_FILL_LIQUID( "ACT_FILL_LIQUID" );
static const activity_id ACT_MILK( "ACT_MILK" );
static const activity_id ACT_FILL_PIT( "ACT_FILL_PIT" );
static const activity_id ACT_FIND_MOUNT( "ACT_FIND_MOUNT" );
static const activity_id ACT_FIRSTAID( "ACT_FIRSTAID" );
static const activity_id ACT_FISH( "ACT_FISH" );
static const activity_id ACT_FORAGE( "ACT_FORAGE" );
static const activity_id ACT_GAME( "ACT_GAME" );
static const activity_id ACT_GENERIC_GAME( "ACT_GENERIC_GAME" );
static const activity_id ACT_GUNMOD_ADD( "ACT_GUNMOD_ADD" );
static const activity_id ACT_HACKING( "ACT_HACKING" );
static const activity_id ACT_HACKSAW( "ACT_HACKSAW" );
static const activity_id ACT_HAIRCUT( "ACT_HAIRCUT" );
static const activity_id ACT_HAND_CRANK( "ACT_HAND_CRANK" );
static const activity_id ACT_HEATING( "ACT_HEATING" );
static const activity_id ACT_HOTWIRE_CAR( "ACT_HOTWIRE_CAR" );
static const activity_id ACT_JACKHAMMER( "ACT_JACKHAMMER" );
static const activity_id ACT_LONGSALVAGE( "ACT_LONGSALVAGE" );
static const activity_id ACT_MAKE_ZLAVE( "ACT_MAKE_ZLAVE" );
static const activity_id ACT_MEDITATE( "ACT_MEDITATE" );
static const activity_id ACT_MEND_ITEM( "ACT_MEND_ITEM" );
static const activity_id ACT_MIND_SPLICER( "ACT_MIND_SPLICER" );
static const activity_id ACT_MOVE_ITEMS( "ACT_MOVE_ITEMS" );
static const activity_id ACT_MOVE_LOOT( "ACT_MOVE_LOOT" );
static const activity_id ACT_MULTIPLE_BUTCHER( "ACT_MULTIPLE_BUTCHER" );
static const activity_id ACT_MULTIPLE_CHOP_PLANKS( "ACT_MULTIPLE_CHOP_PLANKS" );
static const activity_id ACT_MULTIPLE_CHOP_TREES( "ACT_MULTIPLE_CHOP_TREES" );
static const activity_id ACT_MULTIPLE_CONSTRUCTION( "ACT_MULTIPLE_CONSTRUCTION" );
static const activity_id ACT_MULTIPLE_FARM( "ACT_MULTIPLE_FARM" );
static const activity_id ACT_MULTIPLE_FISH( "ACT_MULTIPLE_FISH" );
static const activity_id ACT_NULL( "ACT_NULL" );
static const activity_id ACT_OPEN_GATE( "ACT_OPEN_GATE" );
static const activity_id ACT_OPERATION( "ACT_OPERATION" );
static const activity_id ACT_OXYTORCH( "ACT_OXYTORCH" );
static const activity_id ACT_PICKAXE( "ACT_PICKAXE" );
static const activity_id ACT_PICKUP( "ACT_PICKUP" );
static const activity_id ACT_PLANT_SEED( "ACT_PLANT_SEED" );
static const activity_id ACT_PLAY_WITH_PET( "ACT_PLAY_WITH_PET" );
static const activity_id ACT_PRY_NAILS( "ACT_PRY_NAILS" );
static const activity_id ACT_PULP( "ACT_PULP" );
static const activity_id ACT_QUARTER( "ACT_QUARTER" );
static const activity_id ACT_READ( "ACT_READ" );
static const activity_id ACT_RELOAD( "ACT_RELOAD" );
static const activity_id ACT_REPAIR_ITEM( "ACT_REPAIR_ITEM" );
static const activity_id ACT_ROBOT_CONTROL( "ACT_ROBOT_CONTROL" );
static const activity_id ACT_SHAVE( "ACT_SHAVE" );
static const activity_id ACT_SKIN( "ACT_SKIN" );
static const activity_id ACT_SOCIALIZE( "ACT_SOCIALIZE" );
static const activity_id ACT_SPELLCASTING( "ACT_SPELLCASTING" );
static const activity_id ACT_START_ENGINES( "ACT_START_ENGINES" );
static const activity_id ACT_START_FIRE( "ACT_START_FIRE" );
static const activity_id ACT_STASH( "ACT_STASH" );
static const activity_id ACT_STUDY_SPELL( "ACT_STUDY_SPELL" );
static const activity_id ACT_TIDY_UP( "ACT_TIDY_UP" );
static const activity_id ACT_TOOLMOD_ADD( "ACT_TOOLMOD_ADD" );
static const activity_id ACT_TRAIN( "ACT_TRAIN" );
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_UNLOAD_MAG( "ACT_UNLOAD_MAG" );
static const activity_id ACT_VEHICLE( "ACT_VEHICLE" );
static const activity_id ACT_VEHICLE_DECONSTRUCTION( "ACT_VEHICLE_DECONSTRUCTION" );
static const activity_id ACT_VEHICLE_REPAIR( "ACT_VEHICLE_REPAIR" );
static const activity_id ACT_VIBE( "ACT_VIBE" );
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 activity_id ACT_WAIT_WEATHER( "ACT_WAIT_WEATHER" );
static const activity_id ACT_WASH( "ACT_WASH" );
static const activity_id ACT_WEAR( "ACT_WEAR" );
static const zone_type_id zone_type_FARM_PLOT( "FARM_PLOT" );
static const skill_id skill_computer( "computer" );
static const skill_id skill_electronics( "electronics" );
static const skill_id skill_fabrication( "fabrication" );
static const skill_id skill_firstaid( "firstaid" );
static const skill_id skill_survival( "survival" );
static const quality_id qual_BUTCHER( "BUTCHER" );
static const quality_id qual_CUT_FINE( "CUT_FINE" );
static const quality_id qual_SAW_M( "SAW_M" );
static const quality_id qual_SAW_W( "SAW_W" );
static const species_id HUMAN( "HUMAN" );
static const species_id ZOMBIE( "ZOMBIE" );
static const std::string trait_flag_CANNIBAL( "CANNIBAL" );
static const std::string trait_flag_PSYCHOPATH( "PSYCHOPATH" );
static const std::string trait_flag_SAPIOVORE( "SAPIOVORE" );
static const mtype_id mon_zombie( "mon_zombie" );
static const mtype_id mon_zombie_fat( "mon_zombie_fat" );
static const mtype_id mon_zombie_rot( "mon_zombie_rot" );
static const mtype_id mon_skeleton( "mon_skeleton" );
static const mtype_id mon_zombie_crawler( "mon_zombie_crawler" );
static const bionic_id bio_ears( "bio_ears" );
static const bionic_id bio_fingerhack( "bio_fingerhack" );
static const bionic_id bio_painkiller( "bio_painkiller" );
using namespace activity_handlers;
const std::map< activity_id, std::function<void( player_activity *, player * )> >
activity_handlers::do_turn_functions = {
{ ACT_BURROW, burrow_do_turn },
{ ACT_CRAFT, craft_do_turn },
{ ACT_FILL_LIQUID, fill_liquid_do_turn },
{ ACT_PICKAXE, pickaxe_do_turn },
{ ACT_DROP, drop_do_turn },
{ ACT_STASH, stash_do_turn },
{ ACT_PULP, pulp_do_turn },
{ ACT_GAME, game_do_turn },
{ ACT_GENERIC_GAME, generic_game_do_turn },
{ ACT_START_FIRE, start_fire_do_turn },
{ ACT_VIBE, vibe_do_turn },
{ ACT_HAND_CRANK, hand_crank_do_turn },
{ ACT_OXYTORCH, oxytorch_do_turn },
{ ACT_AIM, aim_do_turn },
{ ACT_PICKUP, pickup_do_turn },
{ ACT_WEAR, wear_do_turn },
{ ACT_MULTIPLE_FISH, multiple_fish_do_turn },
{ ACT_MULTIPLE_CONSTRUCTION, multiple_construction_do_turn },
{ ACT_MULTIPLE_BUTCHER, multiple_butcher_do_turn },
{ ACT_MULTIPLE_FARM, multiple_farm_do_turn },
{ ACT_FETCH_REQUIRED, fetch_do_turn },
{ ACT_BUILD, build_do_turn },
{ ACT_EAT_MENU, eat_menu_do_turn },
{ ACT_VEHICLE_DECONSTRUCTION, vehicle_deconstruction_do_turn },
{ ACT_VEHICLE_REPAIR, vehicle_repair_do_turn },
{ ACT_MULTIPLE_CHOP_TREES, chop_trees_do_turn },
{ ACT_CONSUME_FOOD_MENU, consume_food_menu_do_turn },
{ ACT_CONSUME_DRINK_MENU, consume_drink_menu_do_turn },
{ ACT_CONSUME_MEDS_MENU, consume_meds_menu_do_turn },
{ ACT_MOVE_ITEMS, move_items_do_turn },
{ ACT_MOVE_LOOT, move_loot_do_turn },
{ ACT_ADV_INVENTORY, adv_inventory_do_turn },
{ ACT_ARMOR_LAYERS, armor_layers_do_turn },
{ ACT_ATM, atm_do_turn },
{ ACT_CRACKING, cracking_do_turn },
{ ACT_FISH, fish_do_turn },
{ ACT_REPAIR_ITEM, repair_item_do_turn },
{ ACT_BUTCHER, butcher_do_turn },
{ ACT_BUTCHER_FULL, butcher_do_turn },
{ ACT_TRAVELLING, travel_do_turn },
{ ACT_AUTODRIVE, drive_do_turn },
{ ACT_FIELD_DRESS, butcher_do_turn },
{ ACT_SKIN, butcher_do_turn },
{ ACT_QUARTER, butcher_do_turn },
{ ACT_DISMEMBER, butcher_do_turn },
{ ACT_DISSECT, butcher_do_turn },
{ ACT_HACKSAW, hacksaw_do_turn },
{ ACT_PRY_NAILS, pry_nails_do_turn },
{ ACT_CHOP_TREE, chop_tree_do_turn },
{ ACT_CHOP_LOGS, chop_tree_do_turn },
{ ACT_TIDY_UP, tidy_up_do_turn },
{ ACT_CHOP_PLANKS, chop_tree_do_turn },
{ ACT_TIDY_UP, tidy_up_do_turn },
{ ACT_JACKHAMMER, jackhammer_do_turn },
{ ACT_FIND_MOUNT, find_mount_do_turn },
{ ACT_DIG, dig_do_turn },
{ ACT_DIG_CHANNEL, dig_channel_do_turn },
{ ACT_FILL_PIT, fill_pit_do_turn },
{ ACT_MULTIPLE_CHOP_PLANKS, multiple_chop_planks_do_turn },
{ ACT_FERTILIZE_PLOT, fertilize_plot_do_turn },
{ ACT_TRY_SLEEP, try_sleep_do_turn },
{ ACT_OPERATION, operation_do_turn },
{ ACT_ROBOT_CONTROL, robot_control_do_turn },
{ ACT_TREE_COMMUNION, tree_communion_do_turn },
{ ACT_STUDY_SPELL, study_spell_do_turn},
{ ACT_READ, read_do_turn},
{ ACT_WAIT_STAMINA, wait_stamina_do_turn }
};
const std::map< activity_id, std::function<void( player_activity *, player * )> >
activity_handlers::finish_functions = {
{ ACT_BURROW, burrow_finish },
{ ACT_BUTCHER, butcher_finish },
{ ACT_BUTCHER_FULL, butcher_finish },
{ ACT_FIELD_DRESS, butcher_finish },
{ ACT_SKIN, butcher_finish },
{ ACT_QUARTER, butcher_finish },
{ ACT_DISMEMBER, butcher_finish },
{ ACT_DISSECT, butcher_finish },
{ ACT_FIRSTAID, firstaid_finish },
{ ACT_FISH, fish_finish },
{ ACT_FORAGE, forage_finish },
{ ACT_HOTWIRE_CAR, hotwire_finish },
{ ACT_LONGSALVAGE, longsalvage_finish },
{ ACT_MAKE_ZLAVE, make_zlave_finish },
{ ACT_PICKAXE, pickaxe_finish },
{ ACT_RELOAD, reload_finish },
{ ACT_START_FIRE, start_fire_finish },
{ ACT_TRAIN, train_finish },
{ ACT_CHURN, churn_finish },
{ ACT_PLANT_SEED, plant_seed_finish },
{ ACT_VEHICLE, vehicle_finish },
{ ACT_START_ENGINES, start_engines_finish },
{ ACT_OXYTORCH, oxytorch_finish },
{ ACT_PULP, pulp_finish },
{ ACT_CRACKING, cracking_finish },
{ ACT_OPEN_GATE, open_gate_finish },
{ ACT_REPAIR_ITEM, repair_item_finish },
{ ACT_HEATING, heat_item_finish },
{ ACT_MEND_ITEM, mend_item_finish },
{ ACT_GUNMOD_ADD, gunmod_add_finish },
{ ACT_TOOLMOD_ADD, toolmod_add_finish },
{ ACT_CLEAR_RUBBLE, clear_rubble_finish },
{ ACT_MEDITATE, meditate_finish },
{ ACT_READ, read_finish },
{ ACT_WAIT, wait_finish },
{ ACT_WAIT_WEATHER, wait_weather_finish },
{ ACT_WAIT_NPC, wait_npc_finish },
{ ACT_WAIT_STAMINA, wait_stamina_finish },
{ ACT_SOCIALIZE, socialize_finish },
{ ACT_TRY_SLEEP, try_sleep_finish },
{ ACT_OPERATION, operation_finish },
{ ACT_DISASSEMBLE, disassemble_finish },
{ ACT_VIBE, vibe_finish },
{ ACT_ATM, atm_finish },
{ ACT_AIM, aim_finish },
{ ACT_EAT_MENU, eat_menu_finish },
{ ACT_CONSUME_FOOD_MENU, eat_menu_finish },
{ ACT_CONSUME_DRINK_MENU, eat_menu_finish },
{ ACT_CONSUME_MEDS_MENU, eat_menu_finish },
{ ACT_WASH, washing_finish },
{ ACT_HACKSAW, hacksaw_finish },
{ ACT_PRY_NAILS, pry_nails_finish },
{ ACT_CHOP_TREE, chop_tree_finish },
{ ACT_MILK, milk_finish },
{ ACT_CHOP_LOGS, chop_logs_finish },
{ ACT_CHOP_PLANKS, chop_planks_finish },
{ ACT_JACKHAMMER, jackhammer_finish },
{ ACT_DIG, dig_finish },
{ ACT_DIG_CHANNEL, dig_channel_finish },
{ ACT_FILL_PIT, fill_pit_finish },
{ ACT_PLAY_WITH_PET, play_with_pet_finish },
{ ACT_SHAVE, shaving_finish },
{ ACT_HAIRCUT, haircut_finish },
{ ACT_UNLOAD_MAG, unload_mag_finish },
{ ACT_ROBOT_CONTROL, robot_control_finish },
{ ACT_MIND_SPLICER, mind_splicer_finish },
{ ACT_HACKING, hacking_finish },
{ ACT_SPELLCASTING, spellcasting_finish },
{ ACT_STUDY_SPELL, study_spell_finish }
};
bool activity_handlers::resume_for_multi_activities( player &p )
{
if( !p.backlog.empty() ) {
player_activity &back_act = p.backlog.front();
if( back_act.is_multi_type() ) {
p.assign_activity( p.backlog.front().id() );
p.backlog.clear();
return true;
}
}
return false;
}
void activity_handlers::burrow_do_turn( player_activity *act, player * )
{
sfx::play_activity_sound( "activity", "burrow", sfx::get_heard_volume( act->placement ) );
if( calendar::once_every( 1_minutes ) ) {
sounds::sound( act->placement, 10, sounds::sound_t::movement,
//~ Sound of a Rat mutant burrowing!
_( "ScratchCrunchScrabbleScurry." ) );
}
}
void activity_handlers::burrow_finish( player_activity *act, player *p )
{
const tripoint &pos = act->placement;
if( g->m.is_bashable( pos ) && g->m.has_flag( flag_SUPPORTS_ROOF, pos ) &&
g->m.ter( pos ) != t_tree ) {
// Tunneling through solid rock is hungry, sweaty, tiring, backbreaking work
// Not quite as bad as the pickaxe, though
p->mod_stored_nutr( 10 );
p->mod_thirst( 10 );
p->mod_fatigue( 15 );
p->mod_pain( 3 * rng( 1, 3 ) );
} else if( g->m.move_cost( pos ) == 2 && g->get_levz() == 0 &&
g->m.ter( pos ) != t_dirt && g->m.ter( pos ) != t_grass ) {
//Breaking up concrete on the surface? not nearly as bad
p->mod_stored_nutr( 5 );
p->mod_thirst( 5 );
p->mod_fatigue( 10 );
}
p->add_msg_if_player( m_good, _( "You finish burrowing." ) );
g->m.destroy( pos, true );
act->set_to_null();
}
static bool check_butcher_cbm( const int roll )
{
// Failure rates for dissection rolls
// 90% at roll 0, 72% at roll 1, 60% at roll 2, 51% @ 3, 45% @ 4, 40% @ 5, ... , 25% @ 10
// Roll is roughly a rng(0, -3 + 1st_aid + fine_cut_quality + 1/2 electronics + small_dex_bonus)
// Roll is reduced by corpse damage level, but to no less then 0
add_msg( m_debug, _( "Roll = %i" ), roll );
add_msg( m_debug, _( "Failure chance = %f%%" ), ( 9.0f / ( 10.0f + roll * 2.5f ) ) * 100.0f );
const bool failed = x_in_y( 9, ( 10 + roll * 2.5 ) );
return !failed;
}
static void butcher_cbm_item( const std::string &what, const tripoint &pos,
const time_point &age, const int roll, const std::vector<std::string> &flags,
const std::vector<fault_id> &faults )
{
if( roll < 0 ) {
return;
}
if( item::find_type( itype_id( what ) )->bionic ) {
item cbm( check_butcher_cbm( roll ) ? what : "burnt_out_bionic", age );
for( const std::string &flg : flags ) {
cbm.set_flag( flg );
}
for( const fault_id &flt : faults ) {
cbm.faults.emplace( flt );
}
add_msg( m_good, _( "You discover a %s!" ), cbm.tname() );
g->m.add_item( pos, cbm );
} else if( check_butcher_cbm( roll ) ) {
item something( what, age );
for( const std::string &flg : flags ) {
something.set_flag( flg );
}
for( const fault_id &flt : faults ) {
something.faults.emplace( flt );
}
add_msg( m_good, _( "You discover a %s!" ), something.tname() );
g->m.add_item( pos, something );
} else {
add_msg( m_bad, _( "You discover only damaged organs." ) );
}
}
static void butcher_cbm_group( const std::string &group, const tripoint &pos,
const time_point &age, const int roll, const std::vector<std::string> &flags,
const std::vector<fault_id> &faults )
{
if( roll < 0 ) {
return;
}
//To see if it spawns a random additional CBM
if( check_butcher_cbm( roll ) ) {
//The CBM works
const auto spawned = g->m.put_items_from_loc( group, pos, age );
for( item *it : spawned ) {
for( const std::string &flg : flags ) {
it->set_flag( flg );
}
for( const fault_id &flt : faults ) {
it->faults.emplace( flt );
}
add_msg( m_good, _( "You discover a %s!" ), it->tname() );
}
} else {
//There is a burnt out CBM
item cbm( "burnt_out_bionic", age );
for( const std::string &flg : flags ) {
cbm.set_flag( flg );
}
for( const fault_id &flt : faults ) {
cbm.faults.emplace( flt );
}
add_msg( m_good, _( "You discover a %s!" ), cbm.tname() );
g->m.add_item( pos, cbm );
}
}
static void set_up_butchery( player_activity &act, player &u, butcher_type action )
{
const int factor = u.max_quality( action == DISSECT ? qual_CUT_FINE : qual_BUTCHER );
const item &corpse_item = *act.targets.back();
const mtype &corpse = *corpse_item.get_mtype();
if( action != DISSECT ) {
if( factor == INT_MIN ) {
u.add_msg_if_player( m_info,
_( "None of your cutting tools are suitable for butchering." ) );
act.set_to_null();
return;
} else if( factor < 0 && one_in( 3 ) ) {
u.add_msg_if_player( m_bad,
_( "You don't trust the quality of your tools, but carry on anyway." ) );
}
}
if( action == DISSECT ) {
switch( factor ) {
case INT_MIN:
u.add_msg_if_player( m_info, _( "None of your tools are sharp and precise enough to do that." ) );
act.set_to_null();
return;
case 1:
u.add_msg_if_player( m_info, _( "You could use a better tool, but this will do." ) );
break;
case 2:
u.add_msg_if_player( m_info, _( "This tool is great, but you still would like a scalpel." ) );
break;
case 3:
u.add_msg_if_player( m_info, _( "You dissect the corpse with a trusty scalpel." ) );
break;
case 5:
u.add_msg_if_player( m_info,
_( "You dissect the corpse with a sophisticated system of surgical grade scalpels." ) );
break;
}
}
bool has_tree_nearby = false;
for( const tripoint &pt : g->m.points_in_radius( u.pos(), 2 ) ) {
if( g->m.has_flag( flag_TREE, pt ) ) {
has_tree_nearby = true;
}
}
bool b_rack_present = false;
for( const tripoint &pt : g->m.points_in_radius( u.pos(), 2 ) ) {
if( g->m.has_flag_furn( flag_BUTCHER_EQ, pt ) ) {
b_rack_present = true;
}
}
// workshop butchery (full) prequisites
if( action == BUTCHER_FULL ) {
const bool has_rope = u.has_amount( "rope_30", 1 ) || u.has_amount( "rope_makeshift_30", 1 ) ||
u.has_amount( "vine_30", 1 ) || u.has_amount( "grapnel", 1 );
const bool big_corpse = corpse.size >= MS_MEDIUM;
if( big_corpse ) {
if( has_rope && !has_tree_nearby && !b_rack_present ) {
u.add_msg_if_player( m_info,
_( "You need to suspend this corpse to butcher it. While you have a rope to lift the corpse, there is no tree nearby to hang it from." ) );
act.targets.pop_back();
return;
}
if( !has_rope && !b_rack_present ) {
u.add_msg_if_player( m_info,
_( "To perform a full butchery on a corpse this big, you need either a butchering rack, a nearby hanging meathook, or both a long rope in your inventory and a nearby tree to hang the corpse from." ) );
act.targets.pop_back();
return;
}
if( !g->m.has_nearby_table( u.pos(), 2 ) ) {
u.add_msg_if_player( m_info,
_( "To perform a full butchery on a corpse this big, you need a table nearby or something else with a flat surface. A leather tarp spread out on the ground could suffice." ) );
act.targets.pop_back();
return;
}
if( !( u.has_quality( qual_SAW_W ) || u.has_quality( qual_SAW_M ) ) ) {
u.add_msg_if_player( m_info,
_( "For a corpse this big you need a saw to perform a full butchery." ) );
act.targets.pop_back();
return;
}
}
}
if( action == DISSECT && ( corpse_item.has_flag( flag_QUARTERED ) ||
corpse_item.has_flag( flag_FIELD_DRESS_FAILED ) ) ) {
u.add_msg_if_player( m_info,
_( "It would be futile to search for implants inside this badly damaged corpse." ) );
act.targets.pop_back();
return;
}
if( action == F_DRESS && ( corpse_item.has_flag( flag_FIELD_DRESS ) ||
corpse_item.has_flag( flag_FIELD_DRESS_FAILED ) ) ) {
u.add_msg_if_player( m_info, _( "This corpse is already field dressed." ) );
act.targets.pop_back();
return;
}
if( action == SKIN && corpse_item.has_flag( flag_SKINNED ) ) {
u.add_msg_if_player( m_info, _( "This corpse is already skinned." ) );
act.targets.pop_back();
return;
}
if( action == QUARTER ) {
if( corpse.size == MS_TINY ) {
u.add_msg_if_player( m_bad, _( "This corpse is too small to quarter without damaging." ),
corpse.nname() );
act.targets.pop_back();
return;
}
if( corpse_item.has_flag( flag_QUARTERED ) ) {
u.add_msg_if_player( m_bad, _( "This is already quartered." ), corpse.nname() );
act.targets.pop_back();
return;
}
if( !( corpse_item.has_flag( flag_FIELD_DRESS ) ||
corpse_item.has_flag( flag_FIELD_DRESS_FAILED ) ) ) {
u.add_msg_if_player( m_bad, _( "You need to perform field dressing before quartering." ),
corpse.nname() );
act.targets.pop_back();
return;
}
}
// applies to all butchery actions
const bool is_human = corpse.id == mtype_id::NULL_ID() || ( corpse.in_species( HUMAN ) &&
!corpse.in_species( ZOMBIE ) );
if( is_human && !( u.has_trait_flag( trait_flag_CANNIBAL ) ||
u.has_trait_flag( trait_flag_PSYCHOPATH ) ||
u.has_trait_flag( trait_flag_SAPIOVORE ) ) ) {
if( u.is_player() ) {
if( query_yn( _( "Would you dare desecrate the mortal remains of a fellow human being?" ) ) ) {
switch( rng( 1, 3 ) ) {
case 1:
u.add_msg_if_player( m_bad, _( "You clench your teeth at the prospect of this gruesome job." ) );
break;
case 2:
u.add_msg_if_player( m_bad, _( "This will haunt you in your dreams." ) );
break;
case 3:
u.add_msg_if_player( m_bad,
_( "You try to look away, but this gruesome image will stay on your mind for some time." ) );
break;
}
g->u.add_morale( MORALE_BUTCHER, -50, 0, 2_days, 3_hours );
} else {
u.add_msg_if_player( m_good, _( "It needs a coffin, not a knife." ) );
act.targets.pop_back();
return;
}
} else {
u.add_morale( MORALE_BUTCHER, -50, 0, 2_days, 3_hours );
}
}
act.moves_left = butcher_time_to_cut( u, corpse_item, action );
// We have a valid target, so preform the full finish function
// instead of just selecting the next valid target
act.index = false;
}
int butcher_time_to_cut( const player &u, const item &corpse_item, const butcher_type action )
{
const mtype &corpse = *corpse_item.get_mtype();
const int factor = u.max_quality( action == DISSECT ? qual_CUT_FINE : qual_BUTCHER );
int time_to_cut = 0;
switch( corpse.size ) {
// Time (roughly) in turns to cut up the corpse
case MS_TINY:
time_to_cut = 150;
break;
case MS_SMALL:
time_to_cut = 300;
break;
case MS_MEDIUM:
time_to_cut = 450;
break;
case MS_LARGE:
time_to_cut = 600;
break;
case MS_HUGE:
time_to_cut = 1800;
break;
}
// At factor 0, base 100 time_to_cut remains 100. At factor 50, it's 50 , at factor 75 it's 25
time_to_cut *= std::max( 25, 100 - factor );
if( time_to_cut < 3000 ) {
time_to_cut = 3000;
}
switch( action ) {
case BUTCHER:
break;
case BUTCHER_FULL:
if( !corpse_item.has_flag( flag_FIELD_DRESS ) || corpse_item.has_flag( flag_FIELD_DRESS_FAILED ) ) {
time_to_cut *= 6;
} else {
time_to_cut *= 4;
}
break;
case F_DRESS:
case SKIN:
time_to_cut *= 2;
break;
case QUARTER:
time_to_cut /= 4;
if( time_to_cut < 1200 ) {
time_to_cut = 1200;
}
break;
case DISMEMBER:
time_to_cut /= 10;
if( time_to_cut < 600 ) {
time_to_cut = 600;
}
break;
case DISSECT:
time_to_cut *= 6;
break;
}
if( corpse_item.has_flag( flag_QUARTERED ) ) {
time_to_cut /= 4;
}
time_to_cut = time_to_cut * ( 1 - ( g->u.get_num_crafting_helpers( 3 ) / 10 ) );
return time_to_cut;
}
// this function modifies the input weight by its damage level, depending on the bodypart
static int corpse_damage_effect( int weight, const std::string &entry_type, int damage_level )
{
const float slight_damage = 0.9;
const float damage = 0.75;
const float high_damage = 0.5;
const int destroyed = 0;
switch( damage_level ) {
case 2:
// "damaged"
if( entry_type == "offal" ) {
return round( weight * damage );
}
if( entry_type == "skin" ) {
return round( weight * damage );
}
if( entry_type == "flesh" ) {
return round( weight * slight_damage );
}
break;
case 3:
// "mangled"
if( entry_type == "offal" ) {
return destroyed;
}
if( entry_type == "skin" ) {
return round( weight * high_damage );
}
if( entry_type == "bone" ) {
return round( weight * slight_damage );
}
if( entry_type == "flesh" ) {
return round( weight * damage );
}
break;
case 4:
// "pulped"
if( entry_type == "offal" ) {
return destroyed;
}
if( entry_type == "skin" ) {
return destroyed;
}
if( entry_type == "bone" ) {
return round( weight * damage );
}
if( entry_type == "flesh" ) {
return round( weight * high_damage );
}
break;
default:
// "bruised" modifier is almost impossible to avoid; also includes no modifier (zero damage)
break;
}
return weight;
}
static void butchery_drops_harvest( item *corpse_item, const mtype &mt, player &p,
const std::function<int()> &roll_butchery, butcher_type action,
const std::function<double()> &roll_drops )
{
p.add_msg_if_player( m_neutral, mt.harvest->message() );
int monster_weight = to_gram( mt.weight );
monster_weight += round( monster_weight * rng_float( -0.1, 0.1 ) );
if( corpse_item->has_flag( flag_QUARTERED ) ) {
monster_weight /= 4;
}
if( corpse_item->has_flag( flag_GIBBED ) ) {
monster_weight = round( 0.85 * monster_weight );
if( action != F_DRESS ) {
p.add_msg_if_player( m_bad,
_( "You salvage what you can from the corpse, but it is badly damaged." ) );
}
}
if( corpse_item->has_flag( flag_SKINNED ) ) {
monster_weight = round( 0.85 * monster_weight );
}
int monster_weight_remaining = monster_weight;
int practice = 4 + roll_butchery();
if( mt.harvest.is_null() ) {
debugmsg( "ERROR: %s has no harvest entry.", mt.id.c_str() );
return;
}
for( const harvest_entry &entry : *mt.harvest ) {
const int butchery = roll_butchery();
const float min_num = entry.base_num.first + butchery * entry.scale_num.first;
const float max_num = entry.base_num.second + butchery * entry.scale_num.second;
int roll = 0;
// mass_ratio will override the use of base_num, scale_num, and max
if( entry.mass_ratio != 0.00f ) {
roll = static_cast<int>( round( entry.mass_ratio * monster_weight ) );
roll = corpse_damage_effect( roll, entry.type, corpse_item->damage_level( 4 ) );
} else if( entry.type != "bionic" && entry.type != "bionic_group" ) {
roll = std::min<int>( entry.max, round( rng_float( min_num, max_num ) ) );
// will not give less than min_num defined in the JSON
roll = std::max<int>( corpse_damage_effect( roll, entry.type, corpse_item->damage_level( 4 ) ),
entry.base_num.first );
}
const itype *drop = nullptr;
if( entry.type != "bionic_group" ) {
drop = item::find_type( entry.drop );
}
// BIONIC handling - no code for DISSECT to let the bionic drop fall through
if( entry.type == "bionic" || entry.type == "bionic_group" ) {
if( action == F_DRESS ) {
if( drop != nullptr && !drop->bionic ) {
if( one_in( 3 ) ) {
p.add_msg_if_player( m_bad,
_( "You notice some strange organs, perhaps harvestable via careful dissection." ) );
}
continue;
}
p.add_msg_if_player( m_bad,
_( "You suspect there might be bionics implanted in this corpse, that careful dissection might reveal." ) );
continue;
}
if( action == BUTCHER || action == BUTCHER_FULL || action == DISMEMBER ) {
if( drop != nullptr && !drop->bionic ) {
if( one_in( 3 ) ) {
p.add_msg_if_player( m_bad,
_( "Your butchering tool destroys a strange organ. Perhaps a more surgical approach would allow harvesting it." ) );
}
continue;
}
switch( rng( 1, 3 ) ) {
case 1:
p.add_msg_if_player( m_bad,
_( "Your butchering tool encounters something implanted in this corpse, but your rough cuts destroy it." ) );
break;
case 2:
p.add_msg_if_player( m_bad,
_( "You find traces of implants in the body, but you care only for the flesh." ) );
break;
case 3:
p.add_msg_if_player( m_bad,
_( "You found some bionics in the body, but harvesting them would require more surgical approach." ) );
break;
}
continue;
}
}
if( action == DISSECT ) {
int roll = roll_butchery() - corpse_item->damage_level( 4 );
roll = roll < 0 ? 0 : roll;
roll = std::min( entry.max, roll );
add_msg( m_debug, _( "Roll penalty for corpse damage = %s" ), 0 - corpse_item->damage_level( 4 ) );
if( entry.type == "bionic" ) {
butcher_cbm_item( entry.drop, p.pos(), calendar::turn, roll, entry.flags, entry.faults );
} else if( entry.type == "bionic_group" ) {
butcher_cbm_group( entry.drop, p.pos(), calendar::turn, roll, entry.flags, entry.faults );
}
continue;
}
// Check if monster was gibbed, and handle accordingly
if( corpse_item->has_flag( flag_GIBBED ) && ( entry.type == "flesh" || entry.type == "bone" ) ) {
roll /= 2;
}
if( corpse_item->has_flag( flag_SKINNED ) && entry.type == "skin" ) {
roll = 0;
}
// QUICK BUTCHERY
if( action == BUTCHER ) {
if( entry.type == "flesh" ) {
roll = roll / 4;
} else if( entry.type == "bone" ) {
roll /= 2;
} else if( corpse_item->get_mtype()->size >= MS_MEDIUM && ( entry.type == "skin" ) ) {
roll /= 2;
} else if( entry.type == "offal" ) {
roll /= 5;
} else {
continue;
}
}
// RIP AND TEAR
if( action == DISMEMBER ) {
if( entry.type == "flesh" ) {
roll /= 6;
} else {
continue;
}
}
// field dressing ignores everything outside below list
if( action == F_DRESS ) {
if( entry.type == "bone" ) {
roll = rng( 0, roll / 2 );
}
if( entry.type == "flesh" ) {
continue;
}
if( entry.type == "skin" ) {
continue;
}
}
// you only get the skin from skinning
if( action == SKIN ) {
if( entry.type != "skin" ) {
continue;
}
if( corpse_item->has_flag( flag_FIELD_DRESS_FAILED ) ) {
roll = rng( 0, roll );
}
}
// field dressing removed innards and bones from meatless limbs
if( ( action == BUTCHER_FULL || action == BUTCHER ) && corpse_item->has_flag( flag_FIELD_DRESS ) ) {
if( entry.type == "offal" ) {
continue;
}
if( entry.type == "bone" ) {
roll = ( roll / 2 ) + rng( roll / 2, roll );
}
}
// unskillfull field dressing may damage the skin, meat, and other parts
if( ( action == BUTCHER_FULL || action == BUTCHER ) &&
corpse_item->has_flag( flag_FIELD_DRESS_FAILED ) ) {
if( entry.type == "offal" ) {
continue;
}
if( entry.type == "bone" ) {
roll = ( roll / 2 ) + rng( roll / 2, roll );
}
if( entry.type == "flesh" || entry.type == "skin" ) {
roll = rng( 0, roll );
}
}
// quartering ruins skin
if( corpse_item->has_flag( flag_QUARTERED ) ) {
if( entry.type == "skin" ) {
//not continue to show fail effect
roll = 0;
} else {
roll /= 4;
}
}
if( entry.type != "bionic_group" ) {
// divide total dropped weight by drop's weight to get amount
if( entry.mass_ratio != 0.00f ) {
// apply skill before converting to items, but only if mass_ratio is defined
roll *= roll_drops();
monster_weight_remaining -= roll;
roll = ceil( static_cast<double>( roll ) /
to_gram( item::find_type( entry.drop )->weight ) );
} else {
monster_weight_remaining -= roll * to_gram( ( item::find_type( entry.drop ) )->weight );
}
if( roll <= 0 ) {
p.add_msg_if_player( m_bad, _( "You fail to harvest: %s" ), drop->nname( 1 ) );
continue;