-
Notifications
You must be signed in to change notification settings - Fork 243
/
iuse.cpp
9753 lines (8740 loc) · 374 KB
/
iuse.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 "iuse.h"
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <exception>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include "action.h"
#include "artifact.h"
#include "avatar.h"
#include "bodypart.h"
#include "calendar.h"
#include "cata_utility.h"
#include "character.h"
#include "character_martial_arts.h"
#include "colony.h"
#include "color.h"
#include "coordinate_conversions.h"
#include "creature.h"
#include "damage.h"
#include "debug.h"
#include "effect.h" // for weed_msg
#include "enums.h"
#include "event.h"
#include "event_bus.h"
#include "explosion.h"
#include "field.h"
#include "field_type.h"
#include "flat_set.h"
#include "fungal_effects.h"
#include "game.h"
#include "game_constants.h"
#include "game_inventory.h"
#include "handle_liquid.h"
#include "iexamine.h"
#include "int_id.h"
#include "inventory.h"
#include "inventory_ui.h"
#include "item.h"
#include "item_contents.h"
#include "item_location.h"
#include "iteminfo_query.h"
#include "itype.h"
#include "iuse_actor.h" // For firestarter
#include "json.h"
#include "line.h"
#include "map.h"
#include "map_iterator.h"
#include "mapdata.h"
#include "martialarts.h"
#include "memorial_logger.h"
#include "memory_fast.h"
#include "messages.h"
#include "monattack.h"
#include "mongroup.h"
#include "monster.h"
#include "morale_types.h"
#include "mtype.h"
#include "mutation.h"
#include "npc.h"
#include "omdata.h"
#include "optional.h"
#include "options.h"
#include "output.h"
#include "overmap.h"
#include "overmapbuffer.h"
#include "pimpl.h"
#include "player.h"
#include "player_activity.h"
#include "pldata.h"
#include "point.h"
#include "recipe.h"
#include "recipe_dictionary.h"
#include "requirements.h"
#include "ret_val.h"
#include "rng.h"
#include "sounds.h"
#include "speech.h"
#include "stomach.h"
#include "string_formatter.h"
#include "string_id.h"
#include "string_input_popup.h"
#include "teleport.h"
#include "text_snippets.h"
#include "timed_event.h"
#include "translations.h"
#include "trap.h"
#include "type_id.h"
#include "ui.h"
#include "value_ptr.h"
#include "veh_type.h"
#include "vehicle.h"
#include "vehicle_selector.h"
#include "visitable.h"
#include "vpart_position.h"
#include "vpart_range.h"
#include "weather.h"
#include "weather_gen.h"
static const activity_id ACT_BURROW( "ACT_BURROW" );
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_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_FILL_PIT( "ACT_FILL_PIT" );
static const activity_id ACT_FISH( "ACT_FISH" );
static const activity_id ACT_GAME( "ACT_GAME" );
static const activity_id ACT_GENERIC_GAME( "ACT_GENERIC_GAME" );
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_JACKHAMMER( "ACT_JACKHAMMER" );
static const activity_id ACT_MEDITATE( "ACT_MEDITATE" );
static const activity_id ACT_MIND_SPLICER( "ACT_MIND_SPLICER" );
static const activity_id ACT_OXYTORCH( "ACT_OXYTORCH" );
static const activity_id ACT_PICKAXE( "ACT_PICKAXE" );
static const activity_id ACT_PRY_NAILS( "ACT_PRY_NAILS" );
static const activity_id ACT_ROBOT_CONTROL( "ACT_ROBOT_CONTROL" );
static const activity_id ACT_SHAVE( "ACT_SHAVE" );
static const activity_id ACT_VIBE( "ACT_VIBE" );
static const activity_id ACT_WASH( "ACT_WASH" );
static const efftype_id effect_adrenaline( "adrenaline" );
static const efftype_id effect_antibiotic( "antibiotic" );
static const efftype_id effect_asthma( "asthma" );
static const efftype_id effect_attention( "attention" );
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_bloodworms( "bloodworms" );
static const efftype_id effect_boomered( "boomered" );
static const efftype_id effect_bouldering( "bouldering" );
static const efftype_id effect_brainworms( "brainworms" );
static const efftype_id effect_cig( "cig" );
static const efftype_id effect_contacts( "contacts" );
static const efftype_id effect_corroding( "corroding" );
static const efftype_id effect_crushed( "crushed" );
static const efftype_id effect_datura( "datura" );
static const efftype_id effect_dazed( "dazed" );
static const efftype_id effect_dermatik( "dermatik" );
static const efftype_id effect_docile( "docile" );
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_foodpoison( "foodpoison" );
static const efftype_id effect_formication( "formication" );
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_hallu( "hallu" );
static const efftype_id effect_happy( "happy" );
static const efftype_id effect_harnessed( "harnessed" );
static const efftype_id effect_has_bag( "has_bag" );
static const efftype_id effect_haslight( "haslight" );
static const efftype_id effect_high( "high" );
static const efftype_id effect_in_pit( "in_pit" );
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_laserlocked( "laserlocked" );
static const efftype_id effect_lying_down( "lying_down" );
static const efftype_id effect_melatonin_supplements( "melatonin" );
static const efftype_id effect_meth( "meth" );
static const efftype_id effect_monster_armor( "monster_armor" );
static const efftype_id effect_music( "music" );
static const efftype_id effect_onfire( "onfire" );
static const efftype_id effect_paincysts( "paincysts" );
static const efftype_id effect_pet( "pet" );
static const efftype_id effect_poison( "poison" );
static const efftype_id effect_ridden( "ridden" );
static const efftype_id effect_riding( "riding" );
static const efftype_id effect_run( "run" );
static const efftype_id effect_sad( "sad" );
static const efftype_id effect_saddled( "monster_saddled" );
static const efftype_id effect_sap( "sap" );
static const efftype_id effect_shakes( "shakes" );
static const efftype_id effect_sleep( "sleep" );
static const efftype_id effect_slimed( "slimed" );
static const efftype_id effect_smoke( "smoke" );
static const efftype_id effect_spores( "spores" );
static const efftype_id effect_stimpack( "stimpack" );
static const efftype_id effect_strong_antibiotic( "strong_antibiotic" );
static const efftype_id effect_stunned( "stunned" );
static const efftype_id effect_tapeworm( "tapeworm" );
static const efftype_id effect_teargas( "teargas" );
static const efftype_id effect_teleglow( "teleglow" );
static const efftype_id effect_tetanus( "tetanus" );
static const efftype_id effect_tied( "tied" );
static const efftype_id effect_took_antiasthmatic( "took_antiasthmatic" );
static const efftype_id effect_took_anticonvulsant_visible( "took_anticonvulsant_visible" );
static const efftype_id effect_took_flumed( "took_flumed" );
static const efftype_id effect_took_prozac( "took_prozac" );
static const efftype_id effect_took_prozac_bad( "took_prozac_bad" );
static const efftype_id effect_took_prozac_visible( "took_prozac_visible" );
static const efftype_id effect_took_thorazine( "took_thorazine" );
static const efftype_id effect_took_thorazine_bad( "took_thorazine_bad" );
static const efftype_id effect_took_xanax( "took_xanax" );
static const efftype_id effect_took_xanax_visible( "took_xanax_visible" );
static const efftype_id effect_valium( "valium" );
static const efftype_id effect_visuals( "visuals" );
static const efftype_id effect_weak_antibiotic( "weak_antibiotic" );
static const efftype_id effect_webbed( "webbed" );
static const efftype_id effect_weed_high( "weed_high" );
static const skill_id skill_computer( "computer" );
static const skill_id skill_cooking( "cooking" );
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_mechanics( "mechanics" );
static const skill_id skill_melee( "melee" );
static const skill_id skill_survival( "survival" );
static const trait_id trait_ACIDBLOOD( "ACIDBLOOD" );
static const trait_id trait_ACIDPROOF( "ACIDPROOF" );
static const trait_id trait_ALCMET( "ALCMET" );
static const trait_id trait_CENOBITE( "CENOBITE" );
static const trait_id trait_CHLOROMORPH( "CHLOROMORPH" );
static const trait_id trait_EATDEAD( "EATDEAD" );
static const trait_id trait_EATPOISON( "EATPOISON" );
static const trait_id trait_GILLS( "GILLS" );
static const trait_id trait_HYPEROPIC( "HYPEROPIC" );
static const trait_id trait_ILLITERATE( "ILLITERATE" );
static const trait_id trait_LIGHTWEIGHT( "LIGHTWEIGHT" );
static const trait_id trait_M_DEPENDENT( "M_DEPENDENT" );
static const trait_id trait_MARLOSS( "MARLOSS" );
static const trait_id trait_MARLOSS_AVOID( "MARLOSS_AVOID" );
static const trait_id trait_MARLOSS_BLUE( "MARLOSS_BLUE" );
static const trait_id trait_MARLOSS_YELLOW( "MARLOSS_YELLOW" );
static const trait_id trait_MASOCHIST( "MASOCHIST" );
static const trait_id trait_MASOCHIST_MED( "MASOCHIST_MED" );
static const trait_id trait_MYOPIC( "MYOPIC" );
static const trait_id trait_NOPAIN( "NOPAIN" );
static const trait_id trait_PSYCHOPATH( "PSYCHOPATH" );
static const trait_id trait_SAPROVORE( "SAPROVORE" );
static const trait_id trait_SPIRITUAL( "SPIRITUAL" );
static const trait_id trait_THRESH_MARLOSS( "THRESH_MARLOSS" );
static const trait_id trait_THRESH_MYCUS( "THRESH_MYCUS" );
static const trait_id trait_THRESH_PLANT( "THRESH_PLANT" );
static const trait_id trait_TOLERANCE( "TOLERANCE" );
static const trait_id trait_URSINE_EYE( "URSINE_EYE" );
static const trait_id trait_WAYFARER( "WAYFARER" );
static const quality_id qual_AXE( "AXE" );
static const quality_id qual_DIG( "DIG" );
static const species_id FUNGUS( "FUNGUS" );
static const species_id HALLUCINATION( "HALLUCINATION" );
static const species_id INSECT( "INSECT" );
static const species_id ROBOT( "ROBOT" );
static const species_id ZOMBIE( "ZOMBIE" );
static const mongroup_id GROUP_FISH( "GROUP_FISH" );
static const mtype_id mon_bee( "mon_bee" );
static const mtype_id mon_blob( "mon_blob" );
static const mtype_id mon_dog_thing( "mon_dog_thing" );
static const mtype_id mon_fly( "mon_fly" );
static const mtype_id mon_hallu_multicooker( "mon_hallu_multicooker" );
static const mtype_id mon_hologram( "mon_hologram" );
static const mtype_id mon_shadow( "mon_shadow" );
static const mtype_id mon_spore( "mon_spore" );
static const mtype_id mon_vortex( "mon_vortex" );
static const mtype_id mon_wasp( "mon_wasp" );
static const bionic_id bio_eye_optic( "bio_eye_optic" );
static const bionic_id bio_shock( "bio_shock" );
static const bionic_id bio_tools( "bio_tools" );
static const std::string flag_EATEN_COLD( "EATEN_COLD" );
static const std::string flag_ACID( "ACID" );
static const std::string flag_CURRENT( "CURRENT" );
static const std::string flag_DIGGABLE( "DIGGABLE" );
static const std::string flag_FISHABLE( "FISHABLE" );
static const std::string flag_FIX_FARSIGHT( "FIX_FARSIGHT" );
static const std::string flag_PLANT( "PLANT" );
static const std::string flag_PLOWABLE( "PLOWABLE" );
#define RADIO_PER_TURN 25 // how many characters per turn of radio
#include "iuse_software.h"
struct extended_photo_def;
struct object_names_collection;
static void item_save_monsters( player &p, item &it, const std::vector<monster *> &monster_vec,
int photo_quality );
static bool show_photo_selection( player &p, item &it, const std::string &var_name );
static bool item_read_extended_photos( item &, std::vector<extended_photo_def> &,
const std::string &,
bool = false );
static void item_write_extended_photos( item &, const std::vector<extended_photo_def> &,
const std::string & );
static std::string format_object_pair( const std::pair<std::string, int> &pair,
const std::string &article );
static std::string format_object_pair_article( const std::pair<std::string, int> &pair );
static std::string format_object_pair_no_article( const std::pair<std::string, int> &pair );
static std::string colorized_field_description_at( const tripoint &point );
static std::string colorized_trap_name_at( const tripoint &point );
static std::string colorized_ter_name_flags_at( const tripoint &point,
const std::vector<std::string> &flags = {}, const std::vector<ter_str_id> &ter_whitelist = {} );
static std::string colorized_feature_description_at( const tripoint ¢er_point, bool &item_found,
const units::volume &min_visible_volume );
static std::string colorized_item_name( const item &item );
static std::string colorized_item_description( const item &item );
static item get_top_item_at_point( const tripoint &point,
const units::volume &min_visible_volume );
static std::string effects_description_for_creature( Creature *creature, std::string &pose,
const std::string &pronoun_sex );
static object_names_collection enumerate_objects_around_point( const tripoint &point,
int radius, const tripoint &bounds_center_point, int bounds_radius,
const tripoint &camera_pos, const units::volume &min_visible_volume, bool create_figure_desc,
std::unordered_set<tripoint> &ignored_points,
std::unordered_set<const vehicle *> &vehicles_recorded );
static extended_photo_def photo_def_for_camera_point( const tripoint &aim_point,
const tripoint &camera_pos,
std::vector<monster *> &monster_vec, std::vector<player *> &player_vec );
static const std::vector<std::string> camera_ter_whitelist_flags = {
"HIDE_PLACE", "FUNGUS", "TREE", "PERMEABLE", "SHRUB",
"PLACE_ITEM", "GROWTH_HARVEST", "GROWTH_MATURE", "GOES_UP",
"GOES_DOWN", "RAMP", "SHARP", "SIGN", "CLIMBABLE"
};
static const std::vector<ter_str_id> camera_ter_whitelist_types = {
ter_str_id( "t_pit_covered" ), ter_str_id( "t_grave_new" ), ter_str_id( "t_grave" ), ter_str_id( "t_pit" ),
ter_str_id( "t_pit_shallow" ), ter_str_id( "t_pit_corpsed" ), ter_str_id( "t_pit_spiked" ),
ter_str_id( "t_pit_spiked_covered" ), ter_str_id( "t_pit_glass" ), ter_str_id( "t_pit_glass" ), ter_str_id( "t_utility_light" )
};
void remove_radio_mod( item &it, player &p )
{
if( !it.has_flag( "RADIO_MOD" ) ) {
return;
}
p.add_msg_if_player( _( "You remove the radio modification from your %s!" ), it.tname() );
item mod( "radio_mod" );
p.i_add_or_drop( mod, 1 );
it.item_tags.erase( "RADIO_ACTIVATION" );
it.item_tags.erase( "RADIO_MOD" );
it.item_tags.erase( "RADIOSIGNAL_1" );
it.item_tags.erase( "RADIOSIGNAL_2" );
it.item_tags.erase( "RADIOSIGNAL_3" );
it.item_tags.erase( "RADIOCARITEM" );
}
// Checks that the player does not have an active item with LITCIG flag.
static bool check_litcig( player &u )
{
auto cigs = u.items_with( []( const item & it ) {
return it.active && it.has_flag( "LITCIG" );
} );
if( cigs.empty() ) {
return true;
}
u.add_msg_if_player( m_info, _( "You're already smoking a %s!" ), cigs[0]->tname() );
return false;
}
/* iuse methods return the number of charges expended, which is usually it->charges_to_use().
* Some items that don't normally use charges return 1 to indicate they're used up.
* Regardless, returning 0 indicates the item has not been used up,
* though it may have been successfully activated.
*/
int iuse::sewage( player *p, item *it, bool, const tripoint & )
{
if( !p->query_yn( _( "Are you sure you want to drink… this?" ) ) ) {
return 0;
}
g->events().send<event_type::eats_sewage>();
p->vomit();
if( one_in( 4 ) ) {
p->mutate();
}
return it->type->charges_to_use();
}
int iuse::honeycomb( player *p, item *it, bool, const tripoint & )
{
g->m.spawn_item( p->pos(), "wax", 2 );
return it->type->charges_to_use();
}
int iuse::xanax( player *p, item *it, bool, const tripoint & )
{
p->add_msg_if_player( _( "You take some %s." ), it->tname() );
p->add_effect( effect_took_xanax, 90_minutes );
p->add_effect( effect_took_xanax_visible, rng( 70_minutes, 110_minutes ) );
return it->type->charges_to_use();
}
static constexpr time_duration alc_strength( const int strength, const time_duration &weak,
const time_duration &medium, const time_duration &strong )
{
return strength == 0 ? weak : strength == 1 ? medium : strong;
}
static int alcohol( player &p, const item &it, const int strength )
{
// Weaker characters are cheap drunks
/** @EFFECT_STR_MAX reduces drunkenness duration */
time_duration duration = alc_strength( strength, 22_minutes, 34_minutes,
45_minutes ) - ( alc_strength( strength, 36_seconds, 1_minutes, 72_seconds ) * p.str_max );
if( p.has_trait( trait_ALCMET ) ) {
duration = alc_strength( strength, 6_minutes, 14_minutes, 18_minutes ) - ( alc_strength( strength,
36_seconds, 1_minutes, 1_minutes ) * p.str_max );
// Metabolizing the booze improves the nutritional value;
// might not be healthy, and still causes Thirst problems, though
p.mod_hunger( -( std::abs( it.get_comestible() ? it.type->comestible->stim : 0 ) ) );
// Metabolizing it cancels out the depressant
p.mod_stim( std::abs( it.get_comestible() ? it.get_comestible()->stim : 0 ) );
} else if( p.has_trait( trait_TOLERANCE ) ) {
duration -= alc_strength( strength, 9_minutes, 16_minutes, 24_minutes );
} else if( p.has_trait( trait_LIGHTWEIGHT ) ) {
duration += alc_strength( strength, 9_minutes, 16_minutes, 24_minutes );
}
p.add_effect( effect_drunk, duration );
return it.type->charges_to_use();
}
int iuse::alcohol_weak( player *p, item *it, bool, const tripoint & )
{
return alcohol( *p, *it, 0 );
}
int iuse::alcohol_medium( player *p, item *it, bool, const tripoint & )
{
return alcohol( *p, *it, 1 );
}
int iuse::alcohol_strong( player *p, item *it, bool, const tripoint & )
{
return alcohol( *p, *it, 2 );
}
/**
* Entry point for intentional bodily intake of smoke via paper wrapped one
* time use items: cigars, cigarettes, etc.
*
* @param p Player doing the smoking
* @param it the item to be smoked.
* @return Charges used in item smoked
*/
int iuse::smoking( player *p, item *it, bool, const tripoint & )
{
bool hasFire = ( p->has_charges( "fire", 1 ) );
// make sure we're not already smoking something
if( !check_litcig( *p ) ) {
return 0;
}
if( !hasFire ) {
p->add_msg_if_player( m_info, _( "You don't have anything to light it with!" ) );
return 0;
}
item cig;
if( it->typeId() == "cig" ) {
cig = item( "cig_lit", calendar::turn );
cig.item_counter = to_turns<int>( 4_minutes );
p->mod_hunger( -3 );
p->mod_thirst( 2 );
} else if( it->typeId() == "handrolled_cig" ) {
// This transforms the hand-rolled into a normal cig, which isn't exactly
// what I want, but leaving it for now.
cig = item( "cig_lit", calendar::turn );
cig.item_counter = to_turns<int>( 4_minutes );
p->mod_thirst( 2 );
p->mod_hunger( -3 );
} else if( it->typeId() == "cigar" ) {
cig = item( "cigar_lit", calendar::turn );
cig.item_counter = to_turns<int>( 12_minutes );
p->mod_thirst( 3 );
p->mod_hunger( -4 );
} else if( it->typeId() == "joint" ) {
cig = item( "joint_lit", calendar::turn );
cig.item_counter = to_turns<int>( 4_minutes );
p->mod_hunger( 4 );
p->mod_thirst( 6 );
if( p->get_painkiller() < 5 ) {
p->set_painkiller( ( p->get_painkiller() + 3 ) * 2 );
}
} else {
p->add_msg_if_player( m_bad,
_( "Please let the devs know you should be able to smoke a %s but the smoking code does not know how." ),
it->tname() );
return 0;
}
// If we're here, we better have a cig to light.
p->use_charges_if_avail( "fire", 1 );
cig.active = true;
p->inv.add_item( cig, false, true );
p->add_msg_if_player( m_neutral, _( "You light a %s." ), cig.tname() );
// Parting messages
if( it->typeId() == "joint" ) {
// Would group with the joint, but awkward to mutter before lighting up.
if( one_in( 5 ) ) {
weed_msg( *p );
}
}
if( p->get_effect_dur( effect_cig ) > 10_minutes * ( p->addiction_level(
add_type::CIG ) + 1 ) ) {
p->add_msg_if_player( m_bad, _( "Ugh, too much smoke… you feel nasty." ) );
}
return it->type->charges_to_use();
}
int iuse::ecig( player *p, item *it, bool, const tripoint & )
{
if( it->typeId() == "ecig" ) {
p->add_msg_if_player( m_neutral, _( "You take a puff from your electronic cigarette." ) );
} else if( it->typeId() == "advanced_ecig" ) {
if( p->has_charges( "nicotine_liquid", 1 ) ) {
p->add_msg_if_player( m_neutral,
_( "You inhale some vapor from your advanced electronic cigarette." ) );
p->use_charges( "nicotine_liquid", 1 );
item dummy_ecig = item( "ecig", calendar::turn );
p->consume_effects( dummy_ecig );
} else {
p->add_msg_if_player( m_info, _( "You don't have any nicotine liquid!" ) );
return 0;
}
}
p->mod_thirst( 1 );
p->mod_hunger( -1 );
p->add_effect( effect_cig, 10_minutes );
if( p->get_effect_dur( effect_cig ) > 10_minutes * ( p->addiction_level(
add_type::CIG ) + 1 ) ) {
p->add_msg_if_player( m_bad, _( "Ugh, too much nicotine… you feel nasty." ) );
}
return it->type->charges_to_use();
}
int iuse::antibiotic( player *p, item *it, bool, const tripoint & )
{
p->add_msg_player_or_npc( m_neutral,
_( "You take some antibiotics." ),
_( "<npcname> takes some antibiotics." ) );
if( p->has_effect( effect_tetanus ) ) {
if( one_in( 3 ) ) {
p->remove_effect( effect_tetanus );
p->add_msg_if_player( m_good, _( "The muscle spasms start to go away." ) );
} else {
p->add_msg_if_player( m_warning, _( "The medication does nothing to help the spasms." ) );
}
}
if( p->has_effect( effect_infected ) && !p->has_effect( effect_antibiotic ) ) {
p->add_msg_if_player( m_good,
_( "Maybe just placebo effect, but you feel a little better as the dose settles in." ) );
}
p->add_effect( effect_antibiotic, 12_hours );
return it->type->charges_to_use();
}
int iuse::eyedrops( player *p, item *it, bool, const tripoint & )
{
if( p->is_underwater() ) {
p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) );
return 0;
}
if( it->charges < it->type->charges_to_use() ) {
p->add_msg_if_player( _( "You're out of %s." ), it->tname() );
return 0;
}
p->add_msg_if_player( _( "You use your %s." ), it->tname() );
p->moves -= to_moves<int>( 10_seconds );
if( p->has_effect( effect_boomered ) ) {
p->remove_effect( effect_boomered );
p->add_msg_if_player( m_good, _( "You wash the slime from your eyes." ) );
}
return it->type->charges_to_use();
}
int iuse::fungicide( player *p, item *it, bool, const tripoint & )
{
if( p->is_underwater() ) {
p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) );
return 0;
}
const bool has_fungus = p->has_effect( effect_fungus );
const bool has_spores = p->has_effect( effect_spores );
if( p->is_npc() && !has_fungus && !has_spores ) {
return 0;
}
p->add_msg_player_or_npc( _( "You use your fungicide." ), _( "<npcname> uses some fungicide" ) );
if( has_fungus && ( one_in( 3 ) ) ) {
p->remove_effect( effect_fungus );
p->add_msg_if_player( m_warning,
_( "You feel a burning sensation under your skin that quickly fades away." ) );
}
if( has_spores && ( one_in( 2 ) ) ) {
if( !p->has_effect( effect_fungus ) ) {
p->add_msg_if_player( m_warning, _( "Your skin grows warm for a moment." ) );
}
p->remove_effect( effect_spores );
int spore_count = rng( 1, 6 );
for( const tripoint &dest : g->m.points_in_radius( p->pos(), 1 ) ) {
if( spore_count == 0 ) {
break;
}
if( dest == p->pos() ) {
continue;
}
if( g->m.passable( dest ) && x_in_y( spore_count, 8 ) ) {
if( monster *const mon_ptr = g->critter_at<monster>( dest ) ) {
monster &critter = *mon_ptr;
if( g->u.sees( dest ) &&
!critter.type->in_species( FUNGUS ) ) {
add_msg( m_warning, _( "The %s is covered in tiny spores!" ),
critter.name() );
}
if( !critter.make_fungus() ) {
critter.die( p ); // counts as kill by player
}
} else {
g->place_critter_at( mon_spore, dest );
}
spore_count--;
}
}
}
return it->type->charges_to_use();
}
int iuse::antifungal( player *p, item *it, bool, const tripoint & )
{
if( p->is_underwater() ) {
p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) );
return 0;
}
p->add_msg_if_player( _( "You take some antifungal medication." ) );
if( p->has_effect( effect_fungus ) ) {
p->remove_effect( effect_fungus );
p->add_msg_if_player( m_warning,
_( "You feel a burning sensation under your skin that quickly fades away." ) );
}
if( p->has_effect( effect_spores ) ) {
if( !p->has_effect( effect_fungus ) ) {
p->add_msg_if_player( m_warning, _( "Your skin grows warm for a moment." ) );
}
}
return it->type->charges_to_use();
}
int iuse::antiparasitic( player *p, item *it, bool, const tripoint & )
{
if( p->is_underwater() ) {
p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) );
return 0;
}
p->add_msg_if_player( _( "You take some antiparasitic medication." ) );
if( p->has_effect( effect_dermatik ) ) {
p->remove_effect( effect_dermatik );
p->add_msg_if_player( m_good, _( "The itching sensation under your skin fades away." ) );
}
if( p->has_effect( effect_tapeworm ) ) {
p->remove_effect( effect_tapeworm );
if( p->has_trait( trait_NOPAIN ) ) {
p->add_msg_if_player( m_good, _( "Your bowels clench as something inside them dies." ) );
} else {
p->add_msg_if_player( m_mixed, _( "Your bowels spasm painfully as something inside them dies." ) );
p->mod_pain( rng( 8, 24 ) );
}
}
if( p->has_effect( effect_bloodworms ) ) {
p->remove_effect( effect_bloodworms );
p->add_msg_if_player( _( "Your skin prickles and your veins itch for a few moments." ) );
}
if( p->has_effect( effect_brainworms ) ) {
p->remove_effect( effect_brainworms );
if( p->has_trait( trait_NOPAIN ) ) {
p->add_msg_if_player( m_good, _( "The pressure inside your head feels better already." ) );
} else {
p->add_msg_if_player( m_mixed,
_( "Your head pounds like a sore tooth as something inside of it dies." ) );
p->mod_pain( rng( 8, 24 ) );
}
}
if( p->has_effect( effect_paincysts ) ) {
p->remove_effect( effect_paincysts );
if( p->has_trait( trait_NOPAIN ) ) {
p->add_msg_if_player( m_good, _( "The stiffness in your joints goes away." ) );
} else {
p->add_msg_if_player( m_good, _( "The pain in your joints goes away." ) );
}
}
return it->type->charges_to_use();
}
int iuse::anticonvulsant( player *p, item *it, bool, const tripoint & )
{
p->add_msg_if_player( _( "You take some anticonvulsant medication." ) );
/** @EFFECT_STR reduces duration of anticonvulsant medication */
time_duration duration = 8_hours - p->str_cur * rng( 0_turns, 10_minutes );
if( p->has_trait( trait_TOLERANCE ) ) {
duration -= 1_hours;
}
if( p->has_trait( trait_LIGHTWEIGHT ) ) {
duration += 2_hours;
}
p->add_effect( effect_valium, duration );
p->add_effect( effect_took_anticonvulsant_visible, duration );
p->add_effect( effect_high, duration );
if( p->has_effect( effect_shakes ) ) {
p->remove_effect( effect_shakes );
p->add_msg_if_player( m_good, _( "You stop shaking." ) );
}
return it->type->charges_to_use();
}
int iuse::weed_cake( player *p, item *it, bool, const tripoint & )
{
p->add_msg_if_player(
_( "You start scarfing down the delicious cake. It tastes a little funny though…" ) );
time_duration duration = 12_minutes;
if( p->has_trait( trait_TOLERANCE ) ) {
duration = 9_minutes;
}
if( p->has_trait( trait_LIGHTWEIGHT ) ) {
duration = 15_minutes;
}
p->mod_hunger( 2 );
p->mod_thirst( 6 );
if( p->get_painkiller() < 5 ) {
p->set_painkiller( ( p->get_painkiller() + 3 ) * 2 );
}
p->add_effect( effect_weed_high, duration );
p->moves -= 100;
if( one_in( 5 ) ) {
weed_msg( *p );
}
return it->type->charges_to_use();
}
int iuse::coke( player *p, item *it, bool, const tripoint & )
{
p->add_msg_if_player( _( "You snort a bump of coke." ) );
/** @EFFECT_STR reduces duration of coke */
time_duration duration = 20_minutes - 1_seconds * p->str_cur + rng( 0_minutes, 1_minutes );
if( p->has_trait( trait_TOLERANCE ) ) {
duration -= 1_minutes; // Symmetry would cause problems :-/
}
if( p->has_trait( trait_LIGHTWEIGHT ) ) {
duration += 2_minutes;
}
p->mod_hunger( -8 );
p->add_effect( effect_high, duration );
return it->type->charges_to_use();
}
int iuse::meth( player *p, item *it, bool, const tripoint & )
{
/** @EFFECT_STR reduces duration of meth */
time_duration duration = 1_minutes * ( 60 - p->str_cur );
if( p->has_amount( "apparatus", 1 ) && p->use_charges_if_avail( "fire", 1 ) ) {
p->add_msg_if_player( m_neutral, _( "You smoke your meth." ) );
p->add_msg_if_player( m_good, _( "The world seems to sharpen." ) );
p->mod_fatigue( -375 );
if( p->has_trait( trait_TOLERANCE ) ) {
duration *= 1.2;
} else {
duration *= ( p->has_trait( trait_LIGHTWEIGHT ) ? 1.8 : 1.5 );
}
// breathe out some smoke
for( int i = 0; i < 3; i++ ) {
g->m.add_field( {p->posx() + static_cast<int>( rng( -2, 2 ) ), p->posy() + static_cast<int>( rng( -2, 2 ) ), p->posz()},
fd_methsmoke, 2 );
}
} else {
p->add_msg_if_player( _( "You snort some crystal meth." ) );
p->mod_fatigue( -300 );
}
if( !p->has_effect( effect_meth ) ) {
duration += 1_hours;
}
if( duration > 0_turns ) {
// meth actually inhibits hunger, weaker characters benefit more
/** @EFFECT_STR_MAX >4 experiences less hunger benefit from meth */
int hungerpen = ( p->str_max < 5 ? 35 : 40 - ( 2 * p->str_max ) );
if( hungerpen > 0 ) {
p->mod_hunger( -hungerpen );
}
p->add_effect( effect_meth, duration );
}
return it->type->charges_to_use();
}
int iuse::vaccine( player *p, item *it, bool, const tripoint & )
{
p->add_msg_if_player( _( "You inject the vaccine." ) );
p->add_msg_if_player( m_good, _( "You feel tough." ) );
p->mod_healthy_mod( 200, 200 );
p->mod_pain( 3 );
item syringe( "syringe", it->birthday() );
p->i_add( syringe );
return it->type->charges_to_use();
}
int iuse::flu_vaccine( player *p, item *it, bool, const tripoint & )
{
p->add_msg_if_player( _( "You empty." ) );
item syringe( "syringe", it->birthday() );
return it->type->charges_to_use();
}
int iuse::antiasthmatic( player *p, item *it, bool, const tripoint & )
{
p->add_msg_if_player( m_good,
_( "You no longer need to worry about asthma attacks, at least for a while." ) );
p->add_effect( effect_took_antiasthmatic, 1_days, num_bp, true );
return it->type->charges_to_use();
}
int iuse::poison( player *p, item *it, bool, const tripoint & )
{
if( ( p->has_trait( trait_EATDEAD ) ) ) {
return it->type->charges_to_use();
}
// NPCs have a magical sense of what is inedible
// Players can abuse the crafting menu instead...
if( !it->has_flag( "HIDDEN_POISON" ) &&
( p->is_npc() ||
!p->query_yn( _( "Are you sure you want to eat this? It looks poisonous…" ) ) ) ) {
return 0;
}
/** @EFFECT_STR increases EATPOISON trait effectiveness (50-90%) */
if( ( p->has_trait( trait_EATPOISON ) ) && ( !( one_in( p->str_cur / 2 ) ) ) ) {
return it->type->charges_to_use();
}
p->add_effect( effect_poison, 1_hours );
p->add_effect( effect_foodpoison, 3_hours );
return it->type->charges_to_use();
}
int iuse::meditate( player *p, item *it, bool t, const tripoint & )
{
if( !p || t ) {
return 0;
}
if( p->is_mounted() ) {
p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) );
return 0;
}
if( p->has_trait( trait_SPIRITUAL ) ) {
const int moves = to_moves<int>( 20_minutes );
p->assign_activity( ACT_MEDITATE, moves );
} else {
p->add_msg_if_player( _( "This %s probably meant a lot to someone at one time." ),
it->tname() );
}
return it->type->charges_to_use();
}
int iuse::thorazine( player *p, item *it, bool, const tripoint & )
{
if( p->has_effect( effect_took_thorazine ) ) {
p->remove_effect( effect_took_thorazine );
p->mod_fatigue( 15 );
}
p->add_effect( effect_took_thorazine, 12_hours );
p->mod_fatigue( 5 );
p->remove_effect( effect_hallu );
p->remove_effect( effect_visuals );
p->remove_effect( effect_high );
if( !p->has_effect( effect_dermatik ) ) {
p->remove_effect( effect_formication );
}
if( one_in( 50 ) ) { // adverse reaction
p->add_msg_if_player( m_bad, _( "You feel completely exhausted." ) );
p->mod_fatigue( 15 );
p->add_effect( effect_took_thorazine_bad, p->get_effect_dur( effect_took_thorazine ) );
} else {
p->add_msg_if_player( m_warning, _( "You feel a bit wobbly." ) );
}
p->add_effect( effect_took_prozac_visible, rng( 9_hours, 15_hours ) );
return it->type->charges_to_use();
}
int iuse::prozac( player *p, item *it, bool, const tripoint & )
{
if( !p->has_effect( effect_took_prozac ) ) {
p->add_effect( effect_took_prozac, 12_hours );
} else {
p->mod_stim( 3 );
}
if( one_in( 50 ) ) { // adverse reaction, same duration as prozac effect.
p->add_msg_if_player( m_warning, _( "You suddenly feel hollow inside." ) );
p->add_effect( effect_took_prozac_bad, p->get_effect_dur( effect_took_prozac ) );
}
p->add_effect( effect_took_prozac_visible, rng( 9_hours, 15_hours ) );
return it->type->charges_to_use();
}
int iuse::sleep( player *p, item *it, bool, const tripoint & )
{
p->mod_fatigue( 40 );
p->add_msg_if_player( m_warning, _( "You feel very sleepy…" ) );
return it->type->charges_to_use();
}
int iuse::datura( player *p, item *it, bool, const tripoint & )
{
if( p->is_npc() ) {
return 0;
}
p->add_effect( effect_datura, rng( 3_hours, 13_hours ) );
p->add_msg_if_player( _( "You eat the datura seed." ) );
if( p->has_trait( trait_SPIRITUAL ) ) {
p->add_morale( MORALE_FOOD_GOOD, 36, 72, 2_hours, 1_hours, false, it->type );
}
return it->type->charges_to_use();
}
int iuse::flumed( player *p, item *it, bool, const tripoint & )
{
p->add_effect( effect_took_flumed, 10_hours );
p->add_msg_if_player( _( "You take some %s" ), it->tname() );
return it->type->charges_to_use();
}
int iuse::flusleep( player *p, item *it, bool, const tripoint & )
{
p->add_effect( effect_took_flumed, 12_hours );
p->mod_fatigue( 30 );
p->add_msg_if_player( _( "You take some %s" ), it->tname() );
p->add_msg_if_player( m_warning, _( "You feel very sleepy…" ) );
return it->type->charges_to_use();
}
int iuse::inhaler( player *p, item *it, bool, const tripoint & )
{
p->add_msg_player_or_npc( m_neutral, _( "You take a puff from your inhaler." ),
_( "<npcname> takes a puff from their inhaler." ) );
if( !p->remove_effect( effect_asthma ) ) {
p->mod_fatigue( -3 ); // if we don't have asthma can be used as stimulant
if( one_in( 20 ) ) { // with a small but significant risk of adverse reaction
p->add_effect( effect_shakes, rng( 2_minutes, 5_minutes ) );
}
}
p->remove_effect( effect_smoke );
return it->type->charges_to_use();
}
int iuse::oxygen_bottle( player *p, item *it, bool, const tripoint & )
{
p->moves -= to_moves<int>( 10_seconds );
p->add_msg_player_or_npc( m_neutral, string_format( _( "You breathe deeply from the %s" ),
it->tname() ),
string_format( _( "<npcname> breathes from the %s" ),
it->tname() ) );
if( p->has_effect( effect_smoke ) ) {
p->remove_effect( effect_smoke );
} else if( p->has_effect( effect_teargas ) ) {
p->remove_effect( effect_teargas );
} else if( p->has_effect( effect_asthma ) ) {
p->remove_effect( effect_asthma );
} else if( p->get_stim() < 16 ) {
p->mod_stim( 8 );
p->mod_painkiller( 2 );
}
p->mod_painkiller( 2 );
return it->type->charges_to_use();
}
int iuse::blech( player *p, item *it, bool, const tripoint & )
{
// TODO: Add more effects?