forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iuse.cpp
3907 lines (3674 loc) · 116 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 "game.h"
#include "mapdata.h"
#include "keypress.h"
#include "output.h"
#include "rng.h"
#include "line.h"
#include "player.h"
#include <sstream>
#define RADIO_PER_TURN 25 // how many characters per turn of radio
// mfb(n) converts a flag to its appropriate position in covers's bitfield
#ifndef mfb
#define mfb(n) long(1 << (n))
#endif
static void add_or_drop_item(game *g, player *p, item *it)
{
item replacement(g->itypes[it->type->id], int(g->turn), g->nextinv);
bool drop = false;
int iter = 0;
// Should this vary based on how many charges get consumed by default?
replacement.charges = 1;
while (p->has_item(replacement.invlet)) {
replacement.invlet = g->nextinv;
g->advance_nextinv();
iter++;
}
if (!drop && (iter == inv_chars.size() || p->volume_carried() >= p->volume_capacity()))
drop = true;
if (drop)
g->m.add_item(p->posx, p->posy, replacement);
else
p->i_add(replacement, g);
}
/* To mark an item as "removed from inventory", set its invlet to 0
This is useful for traps (placed on ground), inactive bots, etc
*/
void iuse::sewage(game *g, player *p, item *it, bool t)
{
p->vomit(g);
if (one_in(4))
p->mutate(g);
}
void iuse::honeycomb(game *g, player *p, item *it, bool t)
{
g->m.spawn_item(p->posx, p->posy, g->itypes["wax"],0, 2);
}
void iuse::royal_jelly(game *g, player *p, item *it, bool t)
{
// TODO: Add other diseases here; royal jelly is a cure-all!
p->pkill += 5;
std::string message;
if (p->has_disease(DI_FUNGUS)) {
message = "You feel cleansed inside!";
p->rem_disease(DI_FUNGUS);
}
if (p->has_disease(DI_BLIND)) {
message = "Your sight returns!";
p->rem_disease(DI_BLIND);
}
if (p->has_disease(DI_POISON) || p->has_disease(DI_FOODPOISON) ||
p->has_disease(DI_BADPOISON)) {
message = "You feel much better!";
p->rem_disease(DI_POISON);
p->rem_disease(DI_BADPOISON);
p->rem_disease(DI_FOODPOISON);
}
if (p->has_disease(DI_ASTHMA)) {
message = "Your breathing clears up!";
p->rem_disease(DI_ASTHMA);
}
if (p->has_disease(DI_COMMON_COLD) || p->has_disease(DI_FLU)) {
message = "You feel healthier!";
p->rem_disease(DI_COMMON_COLD);
p->rem_disease(DI_FLU);
}
g->add_msg_if_player(p,message.c_str());
}
void iuse::bandage(game *g, player *p, item *it, bool t)
{
int bonus = p->skillLevel("firstaid");
hp_part healed;
if (p->is_npc()) { // NPCs heal whichever has sustained the most damage
int highest_damage = 0;
for (int i = 0; i < num_hp_parts; i++) {
int damage = p->hp_max[i] - p->hp_cur[i];
if (i == hp_head)
damage *= 1.5;
if (i == hp_torso)
damage *= 1.2;
if (damage > highest_damage) {
highest_damage = damage;
healed = hp_part(i);
}
}
} else { // Player--present a menu
WINDOW* hp_window = newwin(11, 22, (TERMY-10)/2, (TERMX-22)/2);
wborder(hp_window, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
mvwprintz(hp_window, 1, 1, c_ltred, "Use Bandage:");
if(p->hp_cur[hp_head] < p->hp_max[hp_head])
{
mvwprintz(hp_window, 2, 1, c_ltgray, "1: Head");
}
if(p->hp_cur[hp_torso] < p->hp_max[hp_torso])
{
mvwprintz(hp_window, 3, 1, c_ltgray, "2: Torso");
}
if(p->hp_cur[hp_arm_l] < p->hp_max[hp_arm_l])
{
mvwprintz(hp_window, 4, 1, c_ltgray, "3: Left Arm");
}
if(p->hp_cur[hp_arm_r] < p->hp_max[hp_arm_r])
{
mvwprintz(hp_window, 5, 1, c_ltgray, "4: Right Arm");
}
if(p->hp_cur[hp_leg_l] < p->hp_max[hp_leg_l])
{
mvwprintz(hp_window, 6, 1, c_ltgray, "5: Left Leg");
}
if(p->hp_cur[hp_leg_r] < p->hp_max[hp_leg_r])
{
mvwprintz(hp_window, 7, 1, c_ltgray, "6: Right Leg");
}
if(p->has_disease(DI_BLEED))
{
mvwprintz(hp_window, 8, 1, c_ltgray, "7: Stop Bleeding");
}
mvwprintz(hp_window, 9, 1, c_ltgray, "8: Exit");
nc_color color;
std::string asterisks = "";
int current_hp;
for (int i = 0; i < num_hp_parts; i++) {
current_hp = p->hp_cur[i];
int temporary_bonus = bonus;
if (current_hp != 0) {
switch (hp_part(i)) {
case hp_head:
current_hp += 1;
temporary_bonus *= .8;
break;
case hp_torso:
current_hp += 4;
temporary_bonus *= 1.5;
break;
default:
current_hp += 3;
break;
}
current_hp += temporary_bonus;
if (current_hp > p->hp_max[i]){
current_hp = p->hp_max[i];
}
if (current_hp == p->hp_max[i]){
color = c_green;
asterisks = "***";
} else if (current_hp > p->hp_max[i] * .8) {
color = c_ltgreen;
asterisks = "***";
} else if (current_hp > p->hp_max[i] * .5) {
color = c_yellow;
asterisks = "** ";
} else if (current_hp > p->hp_max[i] * .3) {
color = c_ltred;
asterisks = "** ";
} else {
color = c_red;
asterisks = "* ";
}
if (p->has_trait(PF_SELFAWARE)) {
if (current_hp >= 100){
mvwprintz(hp_window, i * 2 + 15, 0, color, "%d", current_hp);
} else if (current_hp >= 10) {
mvwprintz(hp_window, i * 2 + 16, 0, color, "%d", current_hp);
} else {
mvwprintz(hp_window, i * 2 + 17, 0, color, "%d", current_hp);
}
} else {
mvwprintz(hp_window, i * 2 + 15, 0, color, asterisks.c_str());
}
} else { // curhp is 0; requires surgical attention
mvwprintz(hp_window, i + 2, 15, c_dkgray, "---");
}
}
wrefresh(hp_window);
char ch;
do {
ch = getch();
if (ch == '1'){
healed = hp_head;
} else if (ch == '2'){
healed = hp_torso;
} else if (ch == '3') {
if (p->hp_cur[hp_arm_l] == 0) {
g->add_msg_if_player(p,"That arm is broken. It needs surgical attention.");
add_or_drop_item(g, p, it);
return;
} else {
healed = hp_arm_l;
}
} else if (ch == '4') {
if (p->hp_cur[hp_arm_r] == 0) {
g->add_msg_if_player(p,"That arm is broken. It needs surgical attention.");
add_or_drop_item(g, p, it);
return;
} else {
healed = hp_arm_r;
}
} else if (ch == '5') {
if (p->hp_cur[hp_leg_l] == 0) {
g->add_msg_if_player(p,"That leg is broken. It needs surgical attention.");
add_or_drop_item(g, p, it);
return;
} else {
healed = hp_leg_l;
}
} else if (ch == '6') {
if (p->hp_cur[hp_leg_r] == 0) {
g->add_msg_if_player(p,"That leg is broken. It needs surgical attention.");
add_or_drop_item(g, p, it);
return;
} else {
healed = hp_leg_r;
}
} else if (ch == '8') {
g->add_msg_if_player(p,"Never mind.");
add_or_drop_item(g, p, it);
return;
} else if (ch == '7') {
g->add_msg_if_player(p,"You stopped the bleeding.");
p->rem_disease(DI_BLEED);
return;
}
} while (ch < '1' || ch > '8');
werase(hp_window);
wrefresh(hp_window);
delwin(hp_window);
refresh();
}
p->practice("firstaid", 8);
int dam = 0;
if (healed == hp_head){
dam = 1 + bonus * .8;
} else if (healed == hp_torso){
dam = 4 + bonus * 1.5;
} else {
dam = 3 + bonus;
}
p->heal(healed, dam);
}
void iuse::firstaid(game *g, player *p, item *it, bool t)
{
int bonus = p->skillLevel("firstaid");
hp_part healed;
if (p->is_npc()) { // NPCs heal whichever has sustained the most damage
int highest_damage = 0;
for (int i = 0; i < num_hp_parts; i++) {
int damage = p->hp_max[i] - p->hp_cur[i];
if (i == hp_head)
damage *= 1.5;
if (i == hp_torso)
damage *= 1.2;
if (damage > highest_damage) {
highest_damage = damage;
healed = hp_part(i);
}
}
} else { // Player--present a menu
WINDOW* hp_window = newwin(11, 22, (TERMY-10)/2, (TERMX-22)/2);
wborder(hp_window, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
mvwprintz(hp_window, 1, 1, c_ltred, "Use First Aid:");
if(p->hp_cur[hp_head] < p->hp_max[hp_head])
{
mvwprintz(hp_window, 2, 1, c_ltgray, "1: Head");
}
if(p->hp_cur[hp_torso] < p->hp_max[hp_torso])
{
mvwprintz(hp_window, 3, 1, c_ltgray, "2: Torso");
}
if(p->hp_cur[hp_arm_l] < p->hp_max[hp_arm_l])
{
mvwprintz(hp_window, 4, 1, c_ltgray, "3: Left Arm");
}
if(p->hp_cur[hp_arm_r] < p->hp_max[hp_arm_r])
{
mvwprintz(hp_window, 5, 1, c_ltgray, "4: Right Arm");
}
if(p->hp_cur[hp_leg_l] < p->hp_max[hp_leg_l])
{
mvwprintz(hp_window, 6, 1, c_ltgray, "5: Left Leg");
}
if(p->hp_cur[hp_leg_r] < p->hp_max[hp_leg_r])
{
mvwprintz(hp_window, 7, 1, c_ltgray, "6: Right Leg");
}
if(p->has_disease(DI_BITE))
{
mvwprintz(hp_window, 8, 1, c_ltgray, "7: Clean Wound");
}
mvwprintz(hp_window, 9, 1, c_ltgray, "8: Exit");
nc_color color;
std::string asterisks = "";
int current_hp;
for (int i = 0; i < num_hp_parts; i++) {
current_hp = p->hp_cur[i];
int temporary_bonus = bonus;
if (current_hp != 0) {
switch (hp_part(i)) {
case hp_head:
current_hp += 10;
temporary_bonus *= .8;
break;
case hp_torso:
current_hp += 18;
temporary_bonus *= 1.5;
break;
default:
current_hp += 14;
break;
}
current_hp += temporary_bonus;
if (current_hp > p->hp_max[i]){
current_hp = p->hp_max[i];
}
if (current_hp == p->hp_max[i]){
color = c_green;
asterisks = "***";
} else if (current_hp > p->hp_max[i] * .8) {
color = c_ltgreen;
asterisks = "***";
} else if (current_hp > p->hp_max[i] * .5) {
color = c_yellow;
asterisks = "** ";
} else if (current_hp > p->hp_max[i] * .3) {
color = c_ltred;
asterisks = "** ";
} else {
color = c_red;
asterisks = "* ";
}
if (p->has_trait(PF_SELFAWARE)) {
if (current_hp >= 100){
mvwprintz(hp_window, i * 2 + 15, 0, color, "%d", current_hp);
} else if (current_hp >= 10) {
mvwprintz(hp_window, i * 2 + 16, 0, color, "%d", current_hp);
} else {
mvwprintz(hp_window, i * 2 + 17, 0, color, "%d", current_hp);
}
} else {
mvwprintz(hp_window, i * 2 + 15, 0, color, asterisks.c_str());
}
} else { // curhp is 0; requires surgical attention
mvwprintz(hp_window, i + 2, 15, c_dkgray, "---");
}
}
wrefresh(hp_window);
char ch;
do {
ch = getch();
if (ch == '1'){
healed = hp_head;
} else if (ch == '2'){
healed = hp_torso;
} else if (ch == '3') {
if (p->hp_cur[hp_arm_l] == 0) {
g->add_msg_if_player(p,"That arm is broken. It needs surgical attention.");
add_or_drop_item(g, p, it);
return;
} else {
healed = hp_arm_l;
}
} else if (ch == '4') {
if (p->hp_cur[hp_arm_r] == 0) {
g->add_msg_if_player(p,"That arm is broken. It needs surgical attention.");
add_or_drop_item(g, p, it);
return;
} else {
healed = hp_arm_r;
}
} else if (ch == '5') {
if (p->hp_cur[hp_leg_l] == 0) {
g->add_msg_if_player(p,"That leg is broken. It needs surgical attention.");
add_or_drop_item(g, p, it);
return;
} else {
healed = hp_leg_l;
}
} else if (ch == '6') {
if (p->hp_cur[hp_leg_r] == 0) {
g->add_msg_if_player(p,"That leg is broken. It needs surgical attention.");
add_or_drop_item(g, p, it);
return;
} else {
healed = hp_leg_r;
}
} else if (ch == '8') {
g->add_msg_if_player(p,"Never mind.");
add_or_drop_item(g, p, it);
return;
} else if (ch == '7') {
g->add_msg_if_player(p,"You clean the bite wound.");
p->rem_disease(DI_BITE);
return;
}
} while (ch < '1' || ch > '8');
werase(hp_window);
wrefresh(hp_window);
delwin(hp_window);
refresh();
}
p->practice("firstaid", 8);
int dam = 0;
if (healed == hp_head){
dam = 10 + bonus * .8;
} else if (healed == hp_torso){
dam = 18 + bonus * 1.5;
} else {
dam = 14 + bonus;
}
p->heal(healed, dam);
}
// Aspirin
void iuse::pkill_1(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"You take some %s.", it->tname().c_str());
if (!p->has_disease(DI_PKILL1))
p->add_disease(DI_PKILL1, 120, g);
else {
for (int i = 0; i < p->illness.size(); i++) {
if (p->illness[i].type == DI_PKILL1) {
p->illness[i].duration = 120;
i = p->illness.size();
}
}
}
}
// Codeine
void iuse::pkill_2(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"You take some %s.", it->tname().c_str());
p->add_disease(DI_PKILL2, 180, g);
}
void iuse::pkill_3(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"You take some %s.", it->tname().c_str());
p->add_disease(DI_PKILL3, 20, g);
p->add_disease(DI_PKILL2, 200, g);
}
void iuse::pkill_4(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"You shoot up.");
p->add_disease(DI_PKILL3, 80, g);
p->add_disease(DI_PKILL2, 200, g);
}
void iuse::pkill_l(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"You take some %s.", it->tname().c_str());
p->add_disease(DI_PKILL_L, rng(12, 18) * 300, g);
}
void iuse::xanax(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"You take some %s.", it->tname().c_str());
if (!p->has_disease(DI_TOOK_XANAX))
p->add_disease(DI_TOOK_XANAX, 900, g);
else
p->add_disease(DI_TOOK_XANAX, 200, g);
}
void iuse::caff(game *g, player *p, item *it, bool t)
{
it_comest *food = dynamic_cast<it_comest*> (it->type);
p->fatigue -= food->stim * 3;
}
void iuse::alcohol(game *g, player *p, item *it, bool t)
{
int duration = 680 - (10 * p->str_max); // Weaker characters are cheap drunks
if (p->has_trait(PF_LIGHTWEIGHT))
duration += 300;
p->pkill += 8;
p->add_disease(DI_DRUNK, duration, g);
}
void iuse::alcohol_weak(game *g, player *p, item *it, bool t)
{
int duration = 340 - (6 * p->str_max);
if (p->has_trait(PF_LIGHTWEIGHT))
duration += 120;
p->pkill += 4;
p->add_disease(DI_DRUNK, duration, g);
}
void iuse::cig(game *g, player *p, item *it, bool t)
{
if (it->type->id == "cig")
g->add_msg_if_player(p,"You light a cigarette and smoke it.");
else //cigar
g->add_msg_if_player(p,"You take a few puffs from your cigar.");
p->add_disease(DI_CIG, 200, g);
for (int i = 0; i < p->illness.size(); i++) {
if (p->illness[i].type == DI_CIG && p->illness[i].duration > 600 &&
!p->is_npc())
g->add_msg_if_player(p,"Ugh, too much smoke... you feel gross.");
}
}
void iuse::antibiotic(game *g, player *p, item *it, bool t)
{
if (p->has_disease(DI_INFECTED)){
g->add_msg_if_player(p,"You took some antibiotics.");
p->rem_disease(DI_INFECTED);
p->add_disease(DI_RECOVER, 1200, g);
}
else {
g->add_msg_if_player(p,"You took some antibiotics.");
}
}
void iuse::weed(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"Good stuff, man!");
int duration = 60;
if (p->has_trait(PF_LIGHTWEIGHT))
duration = 90;
p->hunger += 8;
if (p->pkill < 15)
p->pkill += 5;
p->add_disease(DI_HIGH, duration, g);
}
void iuse::coke(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"You snort a bump.");
int duration = 21 - p->str_cur;
if (p->has_trait(PF_LIGHTWEIGHT))
duration += 20;
p->hunger -= 8;
p->add_disease(DI_HIGH, duration, g);
}
void iuse::crack(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"You smoke some rocks.");
p->use_charges("lighter", 1);
int duration = 10;
if (p->has_trait(PF_LIGHTWEIGHT))
duration += 10;
p->hunger -= 8;
p->add_disease(DI_HIGH, duration, g);
}
void iuse::grack(game *g, player *p, item *it, bool t)
{
g->add_msg_if_player(p,"You smoke some Grack Cocaine, time seems to stop.");
p->use_charges("lighter", 1);
int duration = 1000;
if (p->has_trait(PF_LIGHTWEIGHT))
duration += 10;
p->hunger -= 8;
p->add_disease(DI_GRACK, duration, g);
}
void iuse::meth(game *g, player *p, item *it, bool t)
{
int duration = 10 * (40 - p->str_cur);
if (p->has_amount("apparatus", 1)) {
p->use_charges("lighter", 1);
g->add_msg_if_player(p,"You smoke some crystals.");
duration *= 1.5;
} else
g->add_msg_if_player(p,"You snort some crystals.");
if (!p->has_disease(DI_METH))
duration += 600;
int hungerpen = (p->str_cur < 10 ? 20 : 30 - p->str_cur);
p->hunger -= hungerpen;
p->add_disease(DI_METH, duration, g);
}
void iuse::poison(game *g, player *p, item *it, bool t)
{
p->add_disease(DI_POISON, 600, g);
p->add_disease(DI_FOODPOISON, 1800, g);
}
void iuse::hallu(game *g, player *p, item *it, bool t)
{
p->add_disease(DI_HALLU, 2400, g);
}
void iuse::thorazine(game *g, player *p, item *it, bool t)
{
p->fatigue += 15;
p->rem_disease(DI_HALLU);
p->rem_disease(DI_VISUALS);
p->rem_disease(DI_HIGH);
if (!p->has_disease(DI_DERMATIK))
p->rem_disease(DI_FORMICATION);
g->add_msg_if_player(p,"You feel somewhat sedated.");
}
void iuse::prozac(game *g, player *p, item *it, bool t)
{
if (!p->has_disease(DI_TOOK_PROZAC) && p->morale_level() < 0)
p->add_disease(DI_TOOK_PROZAC, 7200, g);
else
p->stim += 3;
}
void iuse::sleep(game *g, player *p, item *it, bool t)
{
p->fatigue += 40;
g->add_msg_if_player(p,"You feel very sleepy...");
}
void iuse::iodine(game *g, player *p, item *it, bool t)
{
p->add_disease(DI_IODINE, 1200, g);
g->add_msg_if_player(p,"You take an iodine tablet.");
}
void iuse::flumed(game *g, player *p, item *it, bool t)
{
p->add_disease(DI_TOOK_FLUMED, 6000, g);
g->add_msg_if_player(p,"You take some %s", it->tname().c_str());
}
void iuse::flusleep(game *g, player *p, item *it, bool t)
{
p->add_disease(DI_TOOK_FLUMED, 7200, g);
p->fatigue += 30;
g->add_msg_if_player(p,"You feel very sleepy...");
}
void iuse::inhaler(game *g, player *p, item *it, bool t)
{
p->rem_disease(DI_ASTHMA);
g->add_msg_if_player(p,"You take a puff from your inhaler.");
}
void iuse::blech(game *g, player *p, item *it, bool t)
{
// TODO: Add more effects?
g->add_msg_if_player(p,"Blech, that burns your throat!");
p->vomit(g);
}
void iuse::mutagen(game *g, player *p, item *it, bool t)
{
if (!one_in(3))
p->mutate(g);
}
void iuse::mutagen_3(game *g, player *p, item *it, bool t)
{
p->mutate(g);
if (!one_in(3))
p->mutate(g);
if (one_in(2))
p->mutate(g);
}
void iuse::purifier(game *g, player *p, item *it, bool t)
{
std::vector<int> valid; // Which flags the player has
for (int i = 1; i < PF_MAX2; i++) {
if (p->has_trait(pl_flag(i)) && p->has_mutation(pl_flag(i)))
valid.push_back(i);
}
if (valid.size() == 0) {
g->add_msg_if_player(p,"You feel cleansed.");
return;
}
int num_cured = rng(1, valid.size());
if (num_cured > 4)
num_cured = 4;
for (int i = 0; i < num_cured && valid.size() > 0; i++) {
int index = rng(0, valid.size() - 1);
p->remove_mutation(g, pl_flag(valid[index]) );
valid.erase(valid.begin() + index);
}
}
void iuse::marloss(game *g, player *p, item *it, bool t)
{
if (p->is_npc())
return;
// If we have the marloss in our veins, we are a "breeder" and will spread
// alien lifeforms.
if (p->has_trait(PF_MARLOSS)) {
g->add_msg_if_player(p,"As you eat the berry, you have a near-religious experience, feeling at one with your surroundings...");
p->add_morale(MORALE_MARLOSS, 100, 1000);
p->hunger = -100;
monster goo(g->mtypes[mon_blob]);
goo.friendly = -1;
int goo_spawned = 0;
for (int x = p->posx - 4; x <= p->posx + 4; x++) {
for (int y = p->posy - 4; y <= p->posy + 4; y++) {
if (rng(0, 10) > trig_dist(x, y, p->posx, p->posy) &&
rng(0, 10) > trig_dist(x, y, p->posx, p->posy) )
g->m.marlossify(x, y);
if (one_in(10 + 5 * trig_dist(x, y, p->posx, p->posy)) &&
(goo_spawned == 0 || one_in(goo_spawned * 2))) {
goo.spawn(x, y);
g->z.push_back(goo);
goo_spawned++;
}
}
}
return;
}
/* If we're not already carriers of Marloss, roll for a random effect:
* 1 - Mutate
* 2 - Mutate
* 3 - Mutate
* 4 - Purify
* 5 - Purify
* 6 - Cleanse radiation + Purify
* 7 - Fully satiate
* 8 - Vomit
* 9 - Give Marloss mutation
*/
int effect = rng(1, 9);
if (effect <= 3) {
g->add_msg_if_player(p,"This berry tastes extremely strange!");
p->mutate(g);
} else if (effect <= 6) { // Radiation cleanse is below
g->add_msg_if_player(p,"This berry makes you feel better all over.");
p->pkill += 30;
this->purifier(g, p, it, t);
} else if (effect == 7) {
g->add_msg_if_player(p,"This berry is delicious, and very filling!");
p->hunger = -100;
} else if (effect == 8) {
g->add_msg_if_player(p,"You take one bite, and immediately vomit!");
p->vomit(g);
} else if (!p->has_trait(PF_MARLOSS)) {
g->add_msg_if_player(p,"You feel a strange warmth spreading throughout your body...");
p->toggle_trait(PF_MARLOSS);
}
if (effect == 6)
p->radiation = 0;
}
void iuse::dogfood(game *g, player *p, item *it, bool t)
{
int dirx, diry;
g->draw();
mvprintw(0, 0, "Which direction?");
get_direction(g, dirx, diry, input());
if (dirx == -2) {
g->add_msg_if_player(p,"Invalid direction.");
return;
}
p->moves -= 15;
dirx += p->posx;
diry += p->posy;
int mon_dex = g->mon_at(dirx,diry);
if (mon_dex != -1) {
if (g->z[mon_dex].type->id == mon_dog) {
g->add_msg_if_player(p,"The dog seems to like you!");
g->z[mon_dex].friendly = -1;
} else
g->add_msg_if_player(p,"The %s seems quit unimpressed!",g->z[mon_dex].type->name.c_str());
} else
g->add_msg_if_player(p,"You spill the dogfood all over the ground.");
}
// TOOLS below this point!
void iuse::lighter(game *g, player *p, item *it, bool t)
{
int dirx, diry;
g->draw();
mvprintw(0, 0, "Light where?");
get_direction(g, dirx, diry, input());
if (dirx == -2) {
g->add_msg_if_player(p,"Invalid direction.");
it->charges++;
return;
}
if (dirx == 0 && diry == 0) {
g->add_msg_if_player(p, "You would set yourself on fire.");
g->add_msg_if_player(p, "But you're already smokin' hot.");
it->charges++;
return;
}
p->moves -= 15;
dirx += p->posx;
diry += p->posy;
if (g->m.flammable_items_at(dirx, diry)) {
if (g->m.add_field(g, dirx, diry, fd_fire, 1))
g->m.field_at(dirx, diry).age = 30;
} else {
g->add_msg_if_player(p,"There's nothing to light there.");
it->charges++;
}
}
void iuse::sew(game *g, player *p, item *it, bool t)
{
char ch = g->inv_type("Repair what?", IC_ARMOR);
item* fix = &(p->i_at(ch));
if (fix == NULL || fix->is_null()) {
g->add_msg_if_player(p,"You do not have that item!");
it->charges++;
return;
}
if (!fix->is_armor()) {
g->add_msg_if_player(p,"That isn't clothing!");
it->charges++;
return;
}
if (!fix->made_of(COTTON) && !fix->made_of(WOOL)) {
g->add_msg_if_player(p,"Your %s is not made of cotton or wool.", fix->tname().c_str());
it->charges++;
return;
}
if (fix->damage < 0) {
g->add_msg_if_player(p,"Your %s is already enhanced.", fix->tname().c_str());
it->charges++;
return;
} else if (fix->damage == 0) {
p->moves -= 500;
p->practice("tailor", 10);
int rn = dice(4, 2 + p->skillLevel("tailor"));
if (p->dex_cur < 8 && one_in(p->dex_cur))
rn -= rng(2, 6);
if (p->dex_cur >= 16 || (p->dex_cur > 8 && one_in(16 - p->dex_cur)))
rn += rng(2, 6);
if (p->dex_cur > 16)
rn += rng(0, p->dex_cur - 16);
if (rn <= 4) {
g->add_msg_if_player(p,"You damage your %s!", fix->tname().c_str());
fix->damage++;
} else if (rn >= 12 && p->i_at(ch).has_flag(IF_VARSIZE) && !p->i_at(ch).has_flag(IF_FIT)) {
g->add_msg_if_player(p,"You take your %s in, improving the fit.", fix->tname().c_str());
(p->i_at(ch).item_flags |= mfb(IF_FIT));
fix->damage--;
} else
g->add_msg_if_player(p,"You practice your sewing.");
} else {
p->moves -= 500;
p->practice("tailor", 8);
int rn = dice(4, 2 + p->skillLevel("tailor"));
rn -= rng(fix->damage, fix->damage * 2);
if (p->dex_cur < 8 && one_in(p->dex_cur))
rn -= rng(2, 6);
if (p->dex_cur >= 8 && (p->dex_cur >= 16 || one_in(16 - p->dex_cur)))
rn += rng(2, 6);
if (p->dex_cur > 16)
rn += rng(0, p->dex_cur - 16);
if (rn <= 4) {
g->add_msg_if_player(p,"You damage your %s further!", fix->tname().c_str());
fix->damage++;
if (fix->damage >= 5) {
g->add_msg_if_player(p,"You destroy it!");
p->i_rem(ch);
}
} else if (rn <= 6) {
g->add_msg_if_player(p,"You don't repair your %s, but you waste lots of thread.",
fix->tname().c_str());
int waste = rng(1, 8);
if (waste > it->charges)
it->charges = 0;
else
it->charges -= waste;
} else if (rn <= 8) {
g->add_msg_if_player(p,"You repair your %s, but waste lots of thread.",
fix->tname().c_str());
fix->damage--;
int waste = rng(1, 8);
if (waste > it->charges)
it->charges = 0;
else
it->charges -= waste;
} else if (rn <= 16) {
g->add_msg_if_player(p,"You repair your %s!", fix->tname().c_str());
fix->damage--;
} else {
g->add_msg_if_player(p,"You repair your %s completely!", fix->tname().c_str());
fix->damage = 0;
}
}
}
void iuse::scissors(game *g, player *p, item *it, bool t)
{
char ch = g->inv("Chop up what?");
item* cut = &(p->i_at(ch));
if (cut->type->id == "null")
{
g->add_msg_if_player(p,"You do not have that item!");
return;
}
if (cut->type->id == "string_6" || cut->type->id == "string_36" || cut->type->id == "rope_30" || cut->type->id == "rope_6")
{
g->add_msg("You cannot cut that, you must disassemble it using the disassemble key");
return;
}
if (cut->type->id == "rag" || cut->type->id == "rag_bloody")
{
g->add_msg_if_player(p,"There's no point in cutting a rag.");
return;
}
if (cut->made_of(COTTON))
{
p->moves -= 25 * cut->volume();
int count = cut->volume();
if (p->skillLevel("tailor") == 0)
count = rng(0, count);
else if (p->skillLevel("tailor") == 1 && count >= 2)
count -= rng(0, 2);
if (dice(3, 3) > p->dex_cur)
count -= rng(1, 3);
if (count <= 0)
{
g->add_msg_if_player(p,"You clumsily cut the %s into useless ribbons.",
cut->tname().c_str());
p->i_rem(ch);
return;
}
g->add_msg_if_player(p,"You slice the %s into %d rag%s.", cut->tname().c_str(), count,
(count == 1 ? "" : "s"));
item rag(g->itypes["rag"], int(g->turn), g->nextinv);
p->i_rem(ch);
bool drop = false;
for (int i = 0; i < count; i++)
{
int iter = 0;
while (p->has_item(rag.invlet) && iter < inv_chars.size())
{
rag.invlet = g->nextinv;
g->advance_nextinv();
iter++;
}
if (!drop && (iter == inv_chars.size() || p->volume_carried() >= p->volume_capacity()))
drop = true;
if (drop)
g->m.add_item(p->posx, p->posy, rag);
else
p->i_add(rag, g);
}
return;
}
if (cut->made_of(LEATHER))
{
p->moves -= 25 * cut->volume();
int count = cut->volume();
if (p->skillLevel("tailor") == 0)
count = rng(0, count);
else if (p->skillLevel("tailor") == 1 && count >= 2)
count -= rng(0, 2);
if (dice(3, 3) > p->dex_cur)
count -= rng(1, 3);
if (count <= 0)
{
g->add_msg_if_player(p,"You clumsily cut the %s into useless scraps.",
cut->tname().c_str());
p->i_rem(ch);
return;
}
g->add_msg_if_player(p,"You slice the %s into %d piece%s of leather.", cut->tname().c_str(), count,
(count == 1 ? "" : "s"));
item rag(g->itypes["leather"], int(g->turn), g->nextinv);
p->i_rem(ch);
bool drop = false;
for (int i = 0; i < count; i++)