forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisease.cpp
1793 lines (1635 loc) · 54.3 KB
/
disease.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 "rng.h"
#include "game.h"
#include "bodypart.h"
#include "disease.h"
#include "weather.h"
#include "translations.h"
#include <stdlib.h>
#include <sstream>
void dis_msg(game *g, dis_type type)
{
switch (type) {
case DI_GLARE:
g->add_msg(_("The sunlight's glare makes it hard to see."));
break;
case DI_WET:
g->add_msg(_("You're getting soaked!"));
break;
case DI_COMMON_COLD:
g->add_msg(_("You feel a cold coming on..."));
break;
case DI_FLU:
g->add_msg(_("You feel a flu coming on..."));
break;
case DI_ONFIRE:
g->add_msg(_("You're on fire!"));
break;
case DI_SMOKE:
g->add_msg(_("You inhale a lungful of thick smoke."));
break;
case DI_TEARGAS:
g->add_msg(_("You inhale a lungful of tear gas."));
break;
case DI_CRUSHED:
g->add_msg(_("The ceiling collapses on you!"));
break;
case DI_BOULDERING:
g->add_msg(_("You are slowed by the rubble."));
break;
case DI_BOOMERED:
g->add_msg(_("You're covered in bile!"));
break;
case DI_SAP:
g->add_msg(_("You're coated in sap!"));
break;
case DI_SPORES:
g->add_msg(_("You're covered in tiny spores!"));
break;
case DI_SLIMED:
g->add_msg(_("You're covered in thick goo!"));
break;
case DI_LYING_DOWN:
g->add_msg(_("You lie down to go to sleep..."));
break;
case DI_FORMICATION:
g->add_msg(_("There's bugs crawling under your skin!"));
break;
case DI_WEBBED:
g->add_msg(_("You're covered in webs!"));
break;
case DI_DRUNK:
case DI_HIGH:
g->add_msg(_("You feel lightheaded."));
break;
case DI_ADRENALINE:
g->add_msg(_("You feel a surge of adrenaline!"));
g->u.moves += 800; // FIXME this should not be here
break;
case DI_ASTHMA:
g->add_msg(_("You can't breathe... asthma attack!"));
break;
case DI_DEAF:
g->add_msg(_("You're deafened!"));
break;
case DI_BLIND:
g->add_msg(_("You're blinded!"));
break;
case DI_STUNNED:
g->add_msg(_("You're stunned!"));
break;
case DI_DOWNED:
g->add_msg(_("You're knocked to the floor!"));
break;
case DI_AMIGARA:
g->add_msg(_("You can't look away from the faultline..."));
break;
case DI_STEMCELL_TREATMENT:
g->add_msg(_("You receive a pureed bone & enamel injection into your eyeball."));
g->add_msg(_("It is excruciating."));
break;
case DI_BITE:
g->add_msg(_("The bite wound feels really deep..."));
break;
case DI_INFECTED:
g->add_msg(_("Your bite wound feels infected"));
break;
case DI_LIGHTSNARE:
g->add_msg(_("You are snared."));
break;
case DI_HEAVYSNARE:
g->add_msg(_("You are snared."));
break;
default:
break;
}
}
void dis_effect(game *g, player &p, disease &dis)
{
int bonus;
switch (dis.type) {
case DI_GLARE:
p.per_cur -= 1;
break;
case DI_WET:
p.add_morale(MORALE_WET, -1, -50, 60, 10);
break;
case DI_COLD_HEAD:
switch (dis.intensity) {
case 3 : p.int_cur -= 3; if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("Your thoughts are unclear."));
case 2 : p.int_cur--;
}
break;
case DI_COLD_MOUTH:
switch (dis.intensity) {
case 3 : p.per_cur -= 3; if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("Your face is stiff from the cold."));
case 2 : p.per_cur--;
}
break;
case DI_COLD_TORSO:
switch (dis.intensity) {
case 3 : p.dex_cur -= 2; if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("Your torso is burning up. You should remove some layers."));
// Speed -20
case 2 : p.dex_cur -= 1;
// Speed -5
// case1 : Speed -2
}
break;
case DI_COLD_ARMS:
switch (dis.intensity) {
case 3 : p.dex_cur -= 2;
case 2 : p.dex_cur--; if (!p.has_disease(DI_SLEEP) && one_in(800)) g->add_msg(_("Your arms are shivering."));
}
break;
case DI_COLD_HANDS:
switch (dis.intensity) {
case 3 : p.dex_cur -= 2;
case 2 : p.dex_cur -= 2; if (!p.has_disease(DI_SLEEP) && one_in(800)) g->add_msg(_("Your hands are shivering."));
}
break;
case DI_COLD_LEGS:
switch (dis.intensity) {
case 3 : p.str_cur--; if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("Your legs are seizing from the incredible cold."));
// Speed -20
case 2 : p.str_cur--;
// Speed -5
// case 1 : Speed -2
}
break;
case DI_COLD_FEET:
switch (dis.intensity) {
case 3 : p.str_cur--;
case 2 : p.str_cur--;
}
break;
case DI_FROSTBITE_HANDS:
switch (dis.intensity) {
case 2 : p.dex_cur -= 3;
case 1 :
if (p.temp_cur[bp_hands] > BODYTEMP_COLD && p.pain < 40) p.pain++;
if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("Your hands feel numb."));
}
break;
case DI_FROSTBITE_FEET:
switch (dis.intensity) {
case 2 : // -4 speed
case 1 :
if (p.temp_cur[bp_feet] > BODYTEMP_COLD && p.pain < 40) p.pain++;
if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("Your feet feel numb."));
}
break;
case DI_FROSTBITE_MOUTH:
switch (dis.intensity) {
case 2 : p.per_cur -= 3;
case 1 :
if (p.temp_cur[bp_mouth] > BODYTEMP_COLD && p.pain < 40) p.pain++;
if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("Your face feels numb."));
}
break;
case DI_BLISTERS_HANDS:
p.dex_cur--;
if (p.pain < 35) p.pain++;
if (one_in(2)) p.hp_cur[hp_arm_r]--;
else p.hp_cur[hp_arm_l]--;
break;
case DI_BLISTERS_FEET:
p.str_cur--;
if (p.pain < 35) p.pain++;
if (one_in(2)) p.hp_cur[hp_leg_r]--;
else p.hp_cur[hp_leg_l]--;
break;
case DI_BLISTERS_MOUTH:
p.per_cur--;
p.hp_cur[hp_head]--;
if (p.pain < 35) p.pain++;
break;
case DI_HOT_HEAD:
switch (dis.intensity) {
case 3 :
if (int(g->turn) % 150 == 0)
p.thirst++;
if (p.pain < 40) p.pain++;
if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("Your head is pounding from the heat."));
// Speed -20
case 2 :
if (int(g->turn) % 300 == 0)
p.thirst++;
// Hallucinations handled in game.cpp
if (one_in(std::min(14500,15000-p.temp_cur[bp_head]))) p.vomit(g);
if (p.pain < 20) p.pain++;
if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("The heat is making you see things."));
// Speed -5
// case 1 : Speed -2
}
break;
case DI_HOT_MOUTH:
switch (dis.intensity) {
case 3 : if (int(g->turn) % 150 == 0) p.thirst++;
if (p.pain < 30) p.pain++;
case 2 : if (int(g->turn) % 300 == 0) p.thirst++;
}
break;
case DI_HOT_TORSO:
switch (dis.intensity) {
case 3 :
if (int(g->turn) % 150 == 0) p.thirst++;
p.str_cur--;
if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("You are sweating profusely."));
// Speed -20
case 2 :
if (int(g->turn) % 300 == 0) p.thirst++;
p.str_cur--;
// Speed -5
// case 1 : Speed -2
}
break;
case DI_HOT_ARMS:
switch (dis.intensity) {
case 3 :
if (int(g->turn) % 150 == 0) p.thirst++;
if (p.pain < 30) p.pain++;
case 2 : if (int(g->turn) % 300 == 0) p.thirst++;
}
break;
case DI_HOT_HANDS:
switch (dis.intensity) {
case 3 : p.dex_cur--;
case 2 : p.dex_cur--;
}
break;
case DI_HOT_LEGS:
switch (dis.intensity) {
case 3 :
if (int(g->turn) % 150 == 0) p.thirst++;
if (p.pain < 30) p.pain++;
if (one_in(400)) g->add_msg(_("Your legs are cramping up."));
case 2 : if (int(g->turn) % 300 == 0) p.thirst++;
}
break;
case DI_HOT_FEET:
switch (dis.intensity) {
case 3 :
if (p.pain < 30) p.pain++;
if (!p.has_disease(DI_SLEEP) && one_in(400)) g->add_msg(_("Your feet are swelling in the heat."));
}
break;
case DI_COMMON_COLD:
if (int(g->turn) % 300 == 0)
p.thirst++;
if (int(g->turn) % 50 == 0)
p.fatigue++;
if (p.has_disease(DI_TOOK_FLUMED)) {
p.str_cur--;
p.int_cur--;
} else {
p.str_cur -= 3;
p.dex_cur--;
p.int_cur -= 2;
p.per_cur--;
}
if (one_in(300)) {
p.moves -= 80;
if (!p.is_npc()) {
g->add_msg(_("You cough noisily."));
g->sound(p.posx, p.posy, 12, "");
} else
g->sound(p.posx, p.posy, 12, "loud coughing");
}
break;
case DI_FLU:
if (int(g->turn) % 300 == 0)
p.thirst++;
if (p.has_disease(DI_TOOK_FLUMED)) {
p.str_cur -= 2;
p.int_cur--;
} else {
p.str_cur -= 4;
p.dex_cur -= 2;
p.int_cur -= 2;
p.per_cur--;
}
if (one_in(300)) {
p.moves -= 80;
if (!p.is_npc()) {
g->add_msg(_("You cough noisily."));
g->sound(p.posx, p.posy, 12, "");
} else
g->sound(p.posx, p.posy, 12, "loud coughing");
}
if (one_in(3600) || (p.has_trait(PF_WEAKSTOMACH) && one_in(3000)) ||
(p.has_trait(PF_NAUSEA) && one_in(2400))) {
if (!p.has_disease(DI_TOOK_FLUMED) || one_in(2))
p.vomit(g);
}
break;
case DI_SMOKE:
p.str_cur--;
p.dex_cur--;
if (one_in(5)) {
if (!p.is_npc()) {
g->add_msg(_("You cough heavily."));
g->sound(p.posx, p.posy, 12, "");
} else
g->sound(p.posx, p.posy, 12, "a hacking cough.");
p.moves -= 80;
p.hurt(g, bp_torso, 0, 1 - (rng(0, 1) * rng(0, 1)));
}
break;
case DI_TEARGAS:
p.str_cur -= 2;
p.dex_cur -= 2;
p.int_cur -= 1;
p.per_cur -= 4;
if (one_in(3)) {
if (!p.is_npc()) {
g->add_msg(_("You cough heavily."));
g->sound(p.posx, p.posy, 12, "");
} else
g->sound(p.posx, p.posy, 12, "a hacking cough");
p.moves -= 100;
p.hurt(g, bp_torso, 0, rng(0, 3) * rng(0, 1));
}
break;
// MATERIALS-TODO: this should be determined by materials properties
case DI_ONFIRE:
p.hurtall(3);
for (int i = 0; i < p.worn.size(); i++) {
if (p.worn[i].made_of("veggy") || p.worn[i].made_of("paper")) {
p.worn.erase(p.worn.begin() + i);
i--;
} else if ((p.worn[i].made_of("cotton") || p.worn[i].made_of("wool")) &&
one_in(10)) {
p.worn.erase(p.worn.begin() + i);
i--;
} else if (p.worn[i].made_of("plastic") && one_in(50)) {
p.worn.erase(p.worn.begin() + i);
i--;
}
}
break;
case DI_CRUSHED:
p.hurtall(10);
//This could be developed on later, for instance
//to deal different damage amounts to different body parts and
//to account for helmets and other armor
break;
case DI_BOULDERING:
switch(g->u.disease_intensity(DI_BOULDERING)){
case 1:
p.dex_cur -= 1;
break;
case 2:
p.dex_cur -= 3;
break;
case 3:
p.dex_cur -= 5;
break;
default:
debugmsg("Something went wrong with DI_BOULDERING.");
debugmsg("Check disease.cpp");
}
if (p.dex_cur < 1) {
p.dex_cur = 1;
}
case DI_BOOMERED:
p.per_cur -= 5;
break;
case DI_SAP:
p.dex_cur -= 3;
break;
case DI_SPORES:
if (one_in(30))
p.add_disease(DI_FUNGUS, -1, g);
break;
case DI_FUNGUS:
bonus = 0;
if (p.has_trait(PF_POISRESIST))
bonus = 100;
p.moves -= 10;
p.str_cur -= 1;
p.dex_cur -= 1;
if (dis.duration > -600) { // First hour symptoms
if (one_in(160 + bonus)) {
if (!p.is_npc()) {
g->add_msg(_("You cough heavily."));
g->sound(p.posx, p.posy, 12, "");
} else
g->sound(p.posx, p.posy, 12, "a hacking cough");
p.pain++;
}
if (one_in(100 + bonus)) {
if (!p.is_npc())
g->add_msg(_("You feel nauseous."));
}
if (one_in(100 + bonus)) {
if (!p.is_npc())
g->add_msg(_("You smell and taste mushrooms."));
}
} else if (dis.duration > -3600) { // One to six hours
if (one_in(600 + bonus * 3)) {
if (!p.is_npc())
g->add_msg(_("You spasm suddenly!"));
p.moves -= 100;
p.hurt(g, bp_torso, 0, 5);
}
if ((p.has_trait(PF_WEAKSTOMACH) && one_in(1600 + bonus * 8)) ||
(p.has_trait(PF_NAUSEA) && one_in(800 + bonus * 6)) ||
one_in(2000 + bonus * 10)) {
if (!p.is_npc())
g->add_msg(_("You vomit a thick, gray goop."));
else if (g->u_see(p.posx, p.posy))
g->add_msg(_("%s vomits a thick, gray goop."), p.name.c_str());
p.moves = -200;
p.hunger += 50;
p.thirst += 68;
}
} else { // Full symptoms
if (one_in(1000 + bonus * 8)) {
if (!p.is_npc())
g->add_msg(_("You double over, spewing live spores from your mouth!"));
else if (g->u_see(p.posx, p.posy))
g->add_msg(_("%s coughs up a stream of live spores!"), p.name.c_str());
p.moves = -500;
int sporex, sporey;
monster spore(g->mtypes[mon_spore]);
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
sporex = p.posx + i;
sporey = p.posy + j;
if (g->m.move_cost(sporex, sporey) > 0 && one_in(5)) {
if (g->mon_at(sporex, sporey) >= 0) { // Spores hit a monster
if (g->u_see(sporex, sporey))
g->add_msg(_("The %s is covered in tiny spores!"),
g->z[g->mon_at(sporex, sporey)].name().c_str());
if (!g->z[g->mon_at(sporex, sporey)].make_fungus(g))
g->kill_mon(g->mon_at(sporex, sporey));
} else {
spore.spawn(sporex, sporey);
g->z.push_back(spore);
}
}
}
}
} else if (one_in(6000 + bonus * 20)) {
if (!p.is_npc())
g->add_msg(_("Fungus stalks burst through your hands!"));
else if (g->u_see(p.posx, p.posy))
g->add_msg(_("Fungus stalks burst through %s's hands!"), p.name.c_str());
p.hurt(g, bp_arms, 0, 60);
p.hurt(g, bp_arms, 1, 60);
}
}
break;
case DI_SLIMED:
p.dex_cur -= 2;
break;
case DI_LYING_DOWN:
p.moves = 0;
if (p.can_sleep(g)) {
dis.duration = 1;
if (!p.is_npc())
g->add_msg(_("You fall asleep."));
p.add_disease(DI_SLEEP, 6000, g);
}
if (dis.duration == 1 && !p.has_disease(DI_SLEEP))
if (!p.is_npc())
g->add_msg(_("You try to sleep, but can't..."));
break;
case DI_SLEEP:
p.moves = 0;
if (int(g->turn) % 25 == 0) {
if (p.fatigue > 0)
p.fatigue -= 1 + rng(0, 1) * rng(0, 1);
if (p.has_trait(PF_FASTHEALER)) {
p.healall(rng(0, 1));
} else if (p.has_trait(PF_FASTHEALER2)) {
p.healall(rng(0, 2));
} else if (p.has_trait(PF_REGEN)) {
p.healall(rng(1, 2));
} else {
p.healall(rng(0, 1) * rng(0, 1) * rng(0, 1));
}
if (p.fatigue <= 0 && p.fatigue > -20) {
p.fatigue = -25;
g->add_msg(_("Fully rested."));
dis.duration = dice(3, 100);
}
}
if (int(g->turn) % 100 == 0 && !p.has_bionic("bio_recycler")) {
// Hunger and thirst advance more slowly while we sleep.
p.hunger--;
p.thirst--;
}
if (rng(5, 80) + rng(0, 120) + rng(0, abs(p.fatigue)) +
rng(0, abs(p.fatigue * 5)) < g->light_level() &&
(p.fatigue < 10 || one_in(p.fatigue / 2))) {
g->add_msg(_("The light wakes you up."));
dis.duration = 1;
}
// Cold or heat may wake you up.
// Player will sleep through cold or heat if fatigued enough
for (int i = 0 ; i < num_bp ; i++)
{
if (p.temp_cur[i] < BODYTEMP_VERY_COLD - p.fatigue/2)
{
if (one_in(5000)) { g->add_msg(_("You toss and turn trying to keep warm.")); }
if (p.temp_cur[i] < BODYTEMP_FREEZING - p.fatigue/2 || (one_in(p.temp_cur[i] + 5000)))
{
g->add_msg(_("The cold wakes you up."));
dis.duration = 1;
}
}
else if (p.temp_cur[i] > BODYTEMP_VERY_HOT + p.fatigue/2)
{
if (one_in(5000)) { g->add_msg(_("You toss and turn in the heat.")); }
if (p.temp_cur[i] > BODYTEMP_SCORCHING + p.fatigue/2 || (one_in(15000 - p.temp_cur[i])))
{
g->add_msg(_("The heat wakes you up."));
dis.duration = 1;
}
}
}
break;
case DI_STEMCELL_TREATMENT:
//slightly repair broken limbs. (also nonbroken limbs (unless they're too healthy))
for (int i = 0; i < num_hp_parts; i++) {
if(one_in(6)){
if (p.hp_cur[i] < rng(0,40)){
g->add_msg(_("You feel your skeleton melt and mend."));
p.hp_cur[i]+= rng(1,8);
}
else if (p.hp_cur[i] > rng(10,2000)){
g->add_msg(_("You feel your skeleton melt"));
p.hp_cur[i] -= rng(0,8);
}
}
}
break;
case DI_PKILL1:
if (dis.duration <= 70 && dis.duration % 7 == 0 && p.pkill < 15)
p.pkill++;
break;
case DI_PKILL2:
if (dis.duration % 7 == 0 &&
(one_in(p.addiction_level(ADD_PKILLER)) ||
one_in(p.addiction_level(ADD_PKILLER)) ))
p.pkill += 2;
break;
case DI_PKILL3:
if (dis.duration % 2 == 0 &&
(one_in(p.addiction_level(ADD_PKILLER)) ||
one_in(p.addiction_level(ADD_PKILLER)) ))
p.pkill++;
break;
case DI_PKILL_L:
if (dis.duration % 20 == 0 && p.pkill < 40 &&
(one_in(p.addiction_level(ADD_PKILLER)) ||
one_in(p.addiction_level(ADD_PKILLER)) ))
p.pkill++;
break;
case DI_IODINE:
if (p.radiation > 0 && one_in(16))
p.radiation--;
break;
case DI_TOOK_XANAX:
if (dis.duration % 25 == 0 && (p.stim > 0 || one_in(2)))
p.stim--;
break;
case DI_DRUNK:
// We get 600 turns, or one hour, of DI_DRUNK for each drink we have (on avg)
// So, the duration of DI_DRUNK is a good indicator of how much alcohol is in
// our system.
p.per_cur -= int(dis.duration / 1000);
p.dex_cur -= int(dis.duration / 1000);
p.int_cur -= int(dis.duration / 700);
p.str_cur -= int(dis.duration / 1500);
if (dis.duration <= 600)
p.str_cur += 1;
if (dis.duration > 2000 + 100 * dice(2, 100) &&
(p.has_trait(PF_WEAKSTOMACH) || p.has_trait(PF_NAUSEA) || one_in(20)))
p.vomit(g);
if (!p.has_disease(DI_SLEEP) && dis.duration >= 4500 &&
one_in(500 - int(dis.duration / 80))) {
if (!p.is_npc())
g->add_msg(_("You pass out."));
p.add_disease(DI_SLEEP, dis.duration / 2, g);
}
break;
case DI_CIG:
if (dis.duration >= 600) { // Smoked too much
p.str_cur--;
p.dex_cur--;
if (dis.duration >= 1200 && (one_in(50) ||
(p.has_trait(PF_WEAKSTOMACH) && one_in(30)) ||
(p.has_trait(PF_NAUSEA) && one_in(20))))
p.vomit(g);
} else {
p.dex_cur++;
p.int_cur++;
p.per_cur++;
}
break;
case DI_HIGH:
p.int_cur--;
p.per_cur--;
break;
case DI_POISON:
if ((!p.has_trait(PF_POISRESIST) && one_in(150)) ||
( p.has_trait(PF_POISRESIST) && one_in(900)) ) {
if (!p.is_npc())
g->add_msg(_("You're suddenly wracked with pain!"));
p.pain++;
p.hurt(g, bp_torso, 0, rng(0, 2) * rng(0, 1));
}
p.per_cur--;
p.dex_cur--;
if (!p.has_trait(PF_POISRESIST))
p.str_cur -= 2;
break;
case DI_BLEED:
if (!p.is_npc() && one_in(6)) {
g->add_msg(_("You lose some blood."));
p.pain++;
p.hurt(g, bp_torso, 0, 1);
p.per_cur--;
p.str_cur --;
g->m.add_field(g, p.posx, p.posy, fd_blood, 1);
}
break;
case DI_BADPOISON:
if ((!p.has_trait(PF_POISRESIST) && one_in(100)) ||
( p.has_trait(PF_POISRESIST) && one_in(500)) ) {
if (!p.is_npc())
g->add_msg(_("You're suddenly wracked with pain!"));
p.pain += 2;
p.hurt(g, bp_torso, 0, rng(0, 2));
}
p.per_cur -= 2;
p.dex_cur -= 2;
if (!p.has_trait(PF_POISRESIST))
p.str_cur -= 3;
else
p.str_cur--;
break;
case DI_FOODPOISON:
bonus = 0;
if (p.has_trait(PF_POISRESIST))
bonus = 600;
if (one_in(300 + bonus)) {
if (!p.is_npc())
g->add_msg(_("You're suddenly wracked with pain and nausea!"));
p.hurt(g, bp_torso, 0, 1);
}
if ((p.has_trait(PF_WEAKSTOMACH) && one_in(300 + bonus)) ||
(p.has_trait(PF_NAUSEA) && one_in(50 + bonus)) ||
one_in(600 + bonus))
p.vomit(g);
p.str_cur -= 3;
p.dex_cur--;
p.per_cur--;
if (p.has_trait(PF_POISRESIST))
p.str_cur += 2;
break;
case DI_SHAKES:
p.dex_cur -= 4;
p.str_cur--;
break;
case DI_DERMATIK: {
int formication_chance = 600;
if (dis.duration > -2400 && dis.duration < 0)
formication_chance = 2400 + dis.duration;
if (one_in(formication_chance))
p.add_disease(DI_FORMICATION, 1200, g);
if (dis.duration < -2400 && one_in(2400))
p.vomit(g);
if (dis.duration < -14400) { // Spawn some larvae!
// Choose how many insects; more for large characters
int num_insects = 1;
while (num_insects < 6 && rng(0, 10) < p.str_max)
num_insects++;
// Figure out where they may be placed
std::vector<point> valid_spawns;
for (int x = p.posx - 1; x <= p.posy + 1; x++) {
for (int y = p.posy - 1; y <= p.posy + 1; y++) {
if (g->is_empty(x, y))
valid_spawns.push_back(point(x, y));
}
}
if (valid_spawns.size() >= 1) {
p.rem_disease(DI_DERMATIK); // No more infection! yay.
if (!p.is_npc())
g->add_msg(_("Insects erupt from your skin!"));
else if (g->u_see(p.posx, p.posy))
g->add_msg(_("Insects erupt from %s's skin!"), p.name.c_str());
p.moves -= 600;
monster grub(g->mtypes[mon_dermatik_larva]);
while (valid_spawns.size() > 0 && num_insects > 0) {
num_insects--;
// Hurt the player
body_part burst = bp_torso;
if (one_in(3))
burst = bp_arms;
else if (one_in(3))
burst = bp_legs;
p.hurt(g, burst, rng(0, 1), rng(4, 8));
// Spawn a larva
int sel = rng(0, valid_spawns.size() - 1);
grub.spawn(valid_spawns[sel].x, valid_spawns[sel].y);
valid_spawns.erase(valid_spawns.begin() + sel);
// Sometimes it's a friendly larva!
if (one_in(3))
grub.friendly = -1;
else
grub.friendly = 0;
g->z.push_back(grub);
}
}
}
} break;
case DI_WEBBED:
p.str_cur -= 2;
p.dex_cur -= 4;
break;
case DI_RAT:
p.int_cur -= int(dis.duration / 20);
p.str_cur -= int(dis.duration / 50);
p.per_cur -= int(dis.duration / 25);
if (rng(30, 100) < rng(0, dis.duration) && one_in(3))
p.vomit(g);
if (rng(0, 100) < rng(0, dis.duration))
p.mutation_category_level[MUTCAT_RAT]++;
if (rng(50, 500) < rng(0, dis.duration))
p.mutate(g);
break;
case DI_FORMICATION:
p.int_cur -= 2;
p.str_cur -= 1;
if (one_in(10 + 40 * p.int_cur)) {
if (!p.is_npc()) {
g->add_msg(_("You start scratching yourself all over!"));
g->cancel_activity();
} else if (g->u_see(p.posx, p.posy)) {
if (p.male)
g->add_msg(_("%s starts scratching himself all over!"), p.name.c_str());
else
g->add_msg(_("%s starts scratching herself all over!"), p.name.c_str());
}
p.moves -= 150;
p.hurt(g, bp_torso, 0, 1);
}
break;
case DI_HALLU:
// This assumes that we were given DI_HALLU with a 3600 (6-hour) lifespan
if (dis.duration > 3000) { // First hour symptoms
if (one_in(300)) {
if (!p.is_npc())
g->add_msg(_("You feel a little strange."));
}
} else if (dis.duration > 2400) { // Coming up
if (one_in(100) || (p.has_trait(PF_WEAKSTOMACH) && one_in(100))) {
if (!p.is_npc())
g->add_msg(_("You feel nauseous."));
p.hunger -= 5;
}
if (!p.is_npc()) {
if (one_in(200))
g->add_msg(_("Huh? What was that?"));
else if (one_in(200))
g->add_msg(_("Oh god, what's happening?"));
else if (one_in(200))
g->add_msg(_("Of course... it's all fractals!"));
}
} else if (dis.duration == 2400) // Visuals start
p.add_disease(DI_VISUALS, 2400, g);
else { // Full symptoms
p.per_cur -= 2;
p.int_cur -= 1;
p.dex_cur -= 2;
p.str_cur -= 1;
if (one_in(50)) { // Generate phantasm
monster phantasm(g->mtypes[mon_hallu_zom + rng(0, 3)]);
phantasm.spawn(p.posx + rng(-10, 10), p.posy + rng(-10, 10));
g->z.push_back(phantasm);
}
}
break;
case DI_ADRENALINE:
if (dis.duration > 150) { // 5 minutes positive effects
p.str_cur += 5;
p.dex_cur += 3;
p.int_cur -= 8;
p.per_cur += 1;
} else if (dis.duration == 150) { // 15 minutes come-down
if (!p.is_npc())
g->add_msg(_("Your adrenaline rush wears off. You feel AWFUL!"));
p.moves -= 300;
} else {
p.str_cur -= 2;
p.dex_cur -= 1;
p.int_cur -= 1;
p.per_cur -= 1;
}
break;
case DI_ASTHMA:
if (dis.duration > 1200) {
if (!p.is_npc())
g->add_msg(_("Your asthma overcomes you. You stop breathing and die..."));
p.hurtall(500);
}
p.str_cur -= 2;
p.dex_cur -= 3;
break;
case DI_GRACK:
p.str_cur += 500;
p.dex_cur += 500;
p.int_cur += 500;
p.per_cur += 500;
break;
case DI_METH:
if (dis.duration > 600) {
p.str_cur += 2;
p.dex_cur += 2;
p.int_cur += 3;
p.per_cur += 3;
} else {
p.str_cur -= 3;
p.dex_cur -= 2;
p.int_cur -= 1;
}
break;
case DI_ATTACK_BOOST:
case DI_DAMAGE_BOOST:
case DI_DODGE_BOOST:
case DI_ARMOR_BOOST:
case DI_SPEED_BOOST:
if (dis.intensity > 1)
dis.intensity--;
break;
case DI_TELEGLOW:
// Default we get around 300 duration points per teleport (possibly more
// depending on the source).
// TODO: Include a chance to teleport to the nether realm.
if (dis.duration > 6000) { // 20 teles (no decay; in practice at least 21)
if (one_in(1000 - ((dis.duration - 6000) / 10))) {
if (!p.is_npc())
g->add_msg(_("Glowing lights surround you, and you teleport."));
g->teleport();
if (one_in(10))
p.rem_disease(DI_TELEGLOW);
}
if (one_in(1200 - ((dis.duration - 6000) / 5)) && one_in(20)) {
if (!p.is_npc())
g->add_msg(_("You pass out."));
p.add_disease(DI_SLEEP, 1200, g);
if (one_in(6))
p.rem_disease(DI_TELEGLOW);
}
}
if (dis.duration > 3600) { // 12 teles
if (one_in(4000 - int(.25 * (dis.duration - 3600)))) {
mon_id type = MonsterGroupManager::GetMonsterFromGroup("GROUP_NETHER", &g->mtypes);
monster beast(g->mtypes[type]);
int x, y, tries = 0;
do {
x = p.posx + rng(-4, 4);
y = p.posy + rng(-4, 4);
tries++;
} while (((x == p.posx && y == p.posy) || g->mon_at(x, y) != -1) &&
tries < 10);
if (tries < 10) {
if (g->m.move_cost(x, y) == 0)
g->m.ter_set(x, y, t_rubble);
beast.spawn(x, y);
g->z.push_back(beast);
if (g->u_see(x, y)) {
g->cancel_activity_query(_("A monster appears nearby!"));
g->add_msg(_("A portal opens nearby, and a monster crawls through!"));
}
if (one_in(2))
p.rem_disease(DI_TELEGLOW);
}
}
if (one_in(3500 - int(.25 * (dis.duration - 3600)))) {
if (!p.is_npc())
g->add_msg(_("You shudder suddenly."));
p.mutate(g);
if (one_in(4))
p.rem_disease(DI_TELEGLOW);
}
}
if (dis.duration > 2400) { // 8 teleports
if (one_in(10000 - dis.duration))
p.add_disease(DI_SHAKES, rng(40, 80), g);
if (one_in(12000 - dis.duration)) {
if (!p.is_npc())
g->add_msg(_("Your vision is filled with bright lights..."));
p.add_disease(DI_BLIND, rng(10, 20), g);
if (one_in(8))
p.rem_disease(DI_TELEGLOW);
}