/
potion.cc
1328 lines (1187 loc) · 34.9 KB
/
potion.cc
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
/**
* @file
* @brief Potion and potion-like effects.
**/
#include "AppHdr.h"
#include "potion.h"
#include <cstdio>
#include <cstring>
#include "cloud.h"
#include "food.h"
#include "godconduct.h"
#include "hints.h"
#include "itemname.h"
#include "itemprop.h"
#include "item_use.h"
#include "message.h"
#include "misc.h"
#include "mutation.h"
#include "player-stats.h"
#include "prompt.h"
#include "religion.h"
#include "skill_menu.h"
#include "spl-goditem.h"
#include "stringutil.h"
#include "transform.h"
#include "xom.h"
int _xom_factor(bool was_known);
PotionEffect::PotionEffect(const potion_type pot)
: potion_name(potion_type_name(pot)), kind(pot)
{ }
bool PotionEffect::can_quaff(string *reason) const
{
return true;
}
bool PotionEffect::quaff(bool was_known) const
{
if (was_known && !check_known_quaff())
return false;
effect();
return true;
}
bool PotionEffect::check_known_quaff() const
{
string reason;
if (!can_quaff(&reason))
{
mpr(reason);
return false;
}
return true;
}
class PotionCuring : public PotionEffect
{
private:
PotionCuring() : PotionEffect(POT_CURING) { }
DISALLOW_COPY_AND_ASSIGN(PotionCuring);
public:
static const PotionCuring &instance()
{
static PotionCuring inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
// cure status effects
if (you.duration[DUR_CONF]
|| you.duration[DUR_POISONING]
|| you.disease
|| player_rotted())
{
return true;
}
// heal
if (you.duration[DUR_DEATHS_DOOR])
{
if (reason)
*reason = "You can't heal while in Death's door.";
return false;
}
if (!you.can_device_heal()
|| you.hp == you.hp_max && player_rotted() == 0)
{
if (reason)
*reason = "You have no ailments to cure.";
return false;
}
return true;
}
bool effect(bool=true, int=40, bool is_device = true) const override
{
const bool ddoor = you.duration[DUR_DEATHS_DOOR];
bool unrotted = false;
if ((you.can_device_heal() || !is_device) && !ddoor || player_rotted())
{
int amount = 5 + random2(7);
if (is_device && !you.can_device_heal() && player_rotted())
{
// Treat the effectiveness of rot removal as if the player
// had two levels of MUT_NO_DEVICE_HEAL
unrot_hp(div_rand_round(amount,3));
unrotted = true;
}
else
{
if (is_device)
amount = you.scale_device_healing(amount);
if (player_rotted())
unrotted = true;
// Pay for rot right off the top.
amount = unrot_hp(amount);
inc_hp(amount);
}
}
if (ddoor)
mpr("You feel queasy.");
else if (you.can_device_heal() || you.duration[DUR_POISONING]
|| you.duration[DUR_CONF] || unrotted)
canned_msg(MSG_GAIN_HEALTH);
else
mpr("That felt strangely inert.");
// need to redraw from yellow to green even if no hp was gained
if (you.duration[DUR_POISONING])
you.redraw_hit_points = true;
you.duration[DUR_POISONING] = 0;
you.disease = 0;
you.duration[DUR_CONF] = 0;
return true;
}
};
class PotionHealWounds : public PotionEffect
{
private:
PotionHealWounds() : PotionEffect(POT_HEAL_WOUNDS) { }
DISALLOW_COPY_AND_ASSIGN(PotionHealWounds);
public:
static const PotionHealWounds &instance()
{
static PotionHealWounds inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
if (!you.can_device_heal())
{
if (reason)
*reason = "That would not heal you.";
return false;
}
if (you.duration[DUR_DEATHS_DOOR])
{
if (reason)
*reason = "You cannot heal while in Death's door!";
return false;
}
if (you.hp == you.hp_max && player_rotted() == 0)
{
if (reason)
*reason = "Your health is already full!";
return false;
}
return true;
}
bool effect(bool=true, int=40, bool is_device = true) const override
{
if (you.duration[DUR_DEATHS_DOOR])
{
mpr("You feel queasy.");
return false;
}
if (!you.can_device_heal() && is_device)
{
mpr("That seemed strangely inert.");
return false;
}
int amount = 10 + random2avg(28, 3);
if (is_device)
amount = you.scale_device_healing(amount);
// Pay for rot right off the top.
amount = unrot_hp(amount);
inc_hp(amount);
mpr("You feel much better.");
return true;
}
};
/**
* Return a message for the player drinking blood when a non-vampire.
*/
static string _blood_flavour_message()
{
if (player_mutation_level(MUT_HERBIVOROUS) < 3 && player_likes_chunks())
return "This tastes like blood.";
return "Yuck - this tastes like blood.";
}
static bool _prompt_quaff_blood()
{
if (is_good_god(you.religion)
&& !yesno("Really drink that potion of blood?", false, 'n'))
{
canned_msg(MSG_OK);
return false;
}
return true;
}
class PotionBlood : public PotionEffect
{
private:
PotionBlood() : PotionEffect(POT_BLOOD) { }
DISALLOW_COPY_AND_ASSIGN(PotionBlood);
public:
static const PotionBlood &instance()
{
static PotionBlood inst; return inst;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
if (you.species == SP_VAMPIRE)
{
mpr("Yummy - fresh blood!");
lessen_hunger(pow, true);
}
else
mpr(_blood_flavour_message());
// no actual effect, just 'flavour' ha ha ha
return true;
}
bool can_quaff(string *reason = nullptr) const override
{
if (you.hunger_state == HS_ENGORGED)
{
if (reason)
*reason = "You are much too full right now.";
return false;
}
return true;
}
bool quaff(bool was_known) const override
{
if (was_known && (!check_known_quaff() || !_prompt_quaff_blood()))
return false;
effect(was_known, 1040);
did_god_conduct(DID_DRINK_BLOOD, 1 + random2(3), was_known);
return true;
}
};
class PotionHaste : public PotionEffect
{
private:
PotionHaste() : PotionEffect(POT_HASTE) { }
DISALLOW_COPY_AND_ASSIGN(PotionHaste);
public:
static const PotionHaste &instance()
{
static PotionHaste inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
if (you.stasis(false))
{
if (reason)
*reason = NO_HASTE_MSG;
return false;
}
return true;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
return haste_player(40 + random2(pow));
}
bool quaff(bool was_known) const override
{
if (was_known && !check_known_quaff())
return false;
if (effect())
did_god_conduct(DID_HASTY, 10, was_known);
return true;
}
};
class PotionMight : public PotionEffect
{
private:
PotionMight() : PotionEffect(POT_MIGHT) { }
DISALLOW_COPY_AND_ASSIGN(PotionMight);
public:
static const PotionMight &instance()
{
static PotionMight inst; return inst;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
const bool were_mighty = you.duration[DUR_MIGHT] > 0;
mprf(MSGCH_DURATION, "You feel %s all of a sudden.",
were_mighty ? "mightier" : "very mighty");
you.increase_duration(DUR_MIGHT, 35 + random2(pow), 80);
if (!were_mighty)
notify_stat_change(STAT_STR, 5, true);
return true;
}
};
class PotionBrilliance : public PotionEffect
{
private:
PotionBrilliance() : PotionEffect(POT_BRILLIANCE) { }
DISALLOW_COPY_AND_ASSIGN(PotionBrilliance);
public:
static const PotionBrilliance &instance()
{
static PotionBrilliance inst; return inst;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
const bool were_brilliant = you.duration[DUR_BRILLIANCE] > 0;
mprf(MSGCH_DURATION, "You feel %s all of a sudden.",
were_brilliant ? "more clever" : "clever");
you.increase_duration(DUR_BRILLIANCE, 35 + random2(pow), 80);
if (!were_brilliant)
notify_stat_change(STAT_INT, 5, true);
return true;
}
};
class PotionAgility : public PotionEffect
{
private:
PotionAgility() : PotionEffect(POT_AGILITY) { }
DISALLOW_COPY_AND_ASSIGN(PotionAgility);
public:
static const PotionAgility &instance()
{
static PotionAgility inst; return inst;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
const bool were_agile = you.duration[DUR_AGILITY] > 0;
mprf(MSGCH_DURATION, "You feel %s all of a sudden.",
were_agile ? "more agile" : "agile");
you.increase_duration(DUR_AGILITY, 35 + random2(pow), 80);
if (!were_agile)
notify_stat_change(STAT_DEX, 5, true);
return true;
}
};
class PotionFlight : public PotionEffect
{
private:
PotionFlight() : PotionEffect(POT_FLIGHT) { }
DISALLOW_COPY_AND_ASSIGN(PotionFlight);
public:
static const PotionFlight &instance()
{
static PotionFlight inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
if (!flight_allowed(true, reason))
{
if (reason)
*reason = "You cannot fly right now.";
return false;
}
return true;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
you.attribute[ATTR_FLIGHT_UNCANCELLABLE] = 1;
fly_player(pow);
return you.airborne();
}
};
#if TAG_MAJOR_VERSION == 34
class PotionPoison : public PotionEffect
{
private:
PotionPoison() : PotionEffect(POT_POISON) { }
DISALLOW_COPY_AND_ASSIGN(PotionPoison);
public:
static const PotionPoison &instance()
{
static PotionPoison inst; return inst;
}
bool effect(bool=true, int=40, bool=true) const override
{
mprf(MSGCH_WARN, "That liquid tasted very nasty...");
return poison_player(10 + random2avg(15, 2), "", "a potion of poison");
}
bool quaff(bool was_known) const override
{
if (player_res_poison() >= 1)
mpr("You feel slightly nauseous.");
else if (effect(was_known))
xom_is_stimulated(100 / _xom_factor(was_known));
return true;
}
};
#endif
class PotionCancellation : public PotionEffect
{
private:
PotionCancellation() : PotionEffect(POT_CANCELLATION) { }
DISALLOW_COPY_AND_ASSIGN(PotionCancellation);
public:
static const PotionCancellation &instance()
{
static PotionCancellation inst; return inst;
}
bool effect(bool=true, int=40, bool=true) const override
{
debuff_player();
mpr("You feel magically purged.");
return true;
}
};
class PotionAmbrosia : public PotionEffect
{
private:
PotionAmbrosia() : PotionEffect(POT_AMBROSIA) { }
DISALLOW_COPY_AND_ASSIGN(PotionAmbrosia);
public:
static const PotionAmbrosia &instance()
{
static PotionAmbrosia inst; return inst;
}
bool effect(bool=true, int=40, bool=true) const override
{
const int ambrosia_turns = 3 + random2(8);
if (confuse_player(ambrosia_turns, false, true))
{
mprf("You feel%s invigorated.",
you.duration[DUR_AMBROSIA] ? " more" : "");
you.increase_duration(DUR_AMBROSIA, ambrosia_turns);
return true;
}
mpr("You feel briefly invigorated.");
return false;
}
};
class PotionInvisibility : public PotionEffect
{
private:
PotionInvisibility() : PotionEffect(POT_INVISIBILITY) { }
DISALLOW_COPY_AND_ASSIGN(PotionInvisibility);
public:
static const PotionInvisibility &instance()
{
static PotionInvisibility inst; return inst;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
if (you.backlit())
{
vector<const char *> afflictions;
if (you.haloed() && !you.umbraed())
afflictions.push_back("halo");
if (get_contamination_level() > 1)
afflictions.push_back("magical contamination");
if (you.duration[DUR_CORONA])
afflictions.push_back("corona");
if (you.duration[DUR_LIQUID_FLAMES])
afflictions.push_back("liquid flames");
if (you.duration[DUR_QUAD_DAMAGE])
afflictions.push_back("!!!QUAD DAMAGE!!!");
mprf(MSGCH_DURATION,
"You become %stransparent, but the glow from %s "
"%s prevents you from becoming completely invisible.",
you.duration[DUR_INVIS] ? "more " : "",
you.haloed() && you.halo_radius() == -1 ? "the" : "your",
comma_separated_line(afflictions.begin(),
afflictions.end()).c_str());
}
else
{
mprf(MSGCH_DURATION, !you.duration[DUR_INVIS]
? "You fade into invisibility!"
: "You fade further into invisibility.");
}
// Now multiple invisiblity casts aren't as good. -- bwr
if (!you.duration[DUR_INVIS])
you.set_duration(DUR_INVIS, 15 + random2(pow), 100);
else
you.increase_duration(DUR_INVIS, random2(pow), 100);
return true;
}
bool can_quaff(string *reason = nullptr) const override
{
return invis_allowed(true, reason);
}
bool quaff(bool was_known) const override
{
// Let invis_allowed print the messages and possibly do a prompt.
if (was_known && !invis_allowed())
return false;
effect();
you.attribute[ATTR_INVIS_UNCANCELLABLE] = 1;
return true;
}
};
class PotionExperience : public PotionEffect
{
private:
PotionExperience() : PotionEffect(POT_EXPERIENCE) { }
DISALLOW_COPY_AND_ASSIGN(PotionExperience);
public:
static const PotionExperience &instance()
{
static PotionExperience inst; return inst;
}
bool effect(bool=true, int=40, bool=true) const override
{
if (you.experience_level < you.get_max_xl())
{
mpr("You feel more experienced!");
// Defer calling level_change() until later in drink() to prevent
// SIGHUP abuse.
adjust_level(1, true);
}
else
mpr("A flood of memories washes over you.");
// these are included in default force_more_message
skill_menu(SKMF_EXPERIENCE, 750 * you.experience_level);
return true;
}
};
class PotionMagic : public PotionEffect
{
private:
PotionMagic() : PotionEffect(POT_MAGIC) { }
DISALLOW_COPY_AND_ASSIGN(PotionMagic);
public:
static const PotionMagic &instance()
{
static PotionMagic inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
#if TAG_MAJOR_VERSION == 34
if (you.species == SP_DJINNI)
return PotionHealWounds::instance().can_quaff(reason);
#endif
if (you.magic_points == you.max_magic_points)
{
if (reason)
*reason = "Your magic is already full.";
return false;
}
return true;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
#if TAG_MAJOR_VERSION == 34
// Allow repairing rot, disallow going through Death's Door.
if (you.species == SP_DJINNI
&& PotionHealWounds::instance().can_quaff())
{
return PotionHealWounds::instance().effect(pow);
}
#endif
inc_mp(10 + random2avg(28, 3));
mpr("Magic courses through your body.");
return true;
}
};
class PotionBerserk : public PotionEffect
{
private:
PotionBerserk() : PotionEffect(POT_BERSERK_RAGE) { }
DISALLOW_COPY_AND_ASSIGN(PotionBerserk);
public:
static const PotionBerserk &instance()
{
static PotionBerserk inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
return you.can_go_berserk(true, true, true, reason);
}
bool effect(bool was_known = true, int pow = 40, bool=true) const override
{
if (you.species == SP_VAMPIRE && you.hunger_state <= HS_SATIATED)
{
mpr("You feel slightly irritated.");
return false;
}
you.go_berserk(was_known, true);
return true;
}
bool quaff(bool was_known) const override
{
if (was_known
&& (!check_known_quaff() || !berserk_check_wielded_weapon()))
{
return false;
}
if (effect(was_known))
xom_is_stimulated(50);
return true;
}
};
/**
* Is the player unable to mutate (temporarily or permanently) & thus unable
* to drink a mutation-causing potion?
* @param reason Pointer to a string where the reason will be stored if unable
* to mutate
* @returns True if the player is able to mutate now.
*/
static bool _disallow_mutate(string *reason)
{
if (!undead_mutation_rot())
return false;
if (reason)
{
*reason = make_stringf("You cannot mutate%s.",
!you.undead_state(false) ? " at present" : "");
}
return true;
}
class PotionCureMutation : public PotionEffect
{
private:
PotionCureMutation() : PotionEffect(POT_CURE_MUTATION) { }
DISALLOW_COPY_AND_ASSIGN(PotionCureMutation);
public:
static const PotionCureMutation &instance()
{
static PotionCureMutation inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
if (_disallow_mutate(reason))
return false;
if (!how_mutated(false, false, false))
{
if (reason)
{
*reason = make_stringf("You have no %smutations to cure!",
how_mutated(false, false, true)
? "permanent " : "");
}
return false;
}
return true;
}
bool effect(bool=true, int=40, bool=true) const override
{
mpr("It has a very clean taste.");
bool mutated = false;
for (int i = 0; i < 7; i++)
{
if (random2(9) >= i)
{
mutated |= delete_mutation(RANDOM_MUTATION,
"potion of cure mutation", false);
}
}
return mutated;
}
};
class PotionMutation : public PotionEffect
{
private:
PotionMutation() : PotionEffect(POT_MUTATION) { }
DISALLOW_COPY_AND_ASSIGN(PotionMutation);
public:
static const PotionMutation &instance()
{
static PotionMutation inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
if (_disallow_mutate(reason))
return false;
return true;
}
bool effect(bool=true, int=40, bool=true) const override
{
mpr("You feel extremely strange.");
bool mutated = false;
for (int i = 0; i < 3; i++)
mutated |= mutate(RANDOM_MUTATION, "potion of mutation", false);
learned_something_new(HINT_YOU_MUTATED);
return mutated;
}
bool quaff(bool was_known) const override
{
if (was_known && !check_known_quaff())
return false;
string msg = "Really drink that potion of mutation";
msg += you.rmut_from_item() ? " while resistant to mutation?" : "?";
if (was_known && (you_worship(GOD_ZIN) || you.rmut_from_item())
&& !yesno(msg.c_str(), false, 'n'))
{
canned_msg(MSG_OK);
return false;
}
effect();
// Zin conduct is violated even if you get lucky and don't mutate
did_god_conduct(DID_DELIBERATE_MUTATING, 10, was_known);
return true;
}
};
class PotionBeneficialMutation : public PotionEffect
{
private:
PotionBeneficialMutation() : PotionEffect(POT_BENEFICIAL_MUTATION) { }
DISALLOW_COPY_AND_ASSIGN(PotionBeneficialMutation);
public:
static const PotionBeneficialMutation &instance()
{
static PotionBeneficialMutation inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
if (_disallow_mutate(reason))
return false;
return true;
}
bool effect(bool = true, int = 40, bool=true) const override
{
const bool mutated = mutate(RANDOM_GOOD_MUTATION,
"potion of beneficial mutation",
true, false, false, true);
if (undead_mutation_rot())
{
mpr("You feel dead inside.");
return mutated;
}
if (mutated)
mpr("You feel fantastic!");
else
mpr("You feel fantastic for a moment.");
learned_something_new(HINT_YOU_MUTATED);
return mutated;
}
bool quaff(bool was_known) const override
{
if (was_known && !check_known_quaff())
return false;
// Beneficial mutations go rMut, so don't prompt in this case.
if (was_known && you_worship(GOD_ZIN)
&& !yesno("Really drink that potion of beneficial mutation?",
false, 'n'))
{
canned_msg(MSG_OK);
return false;
}
effect(was_known);
// Zin conduct is violated even if you get lucky and don't mutate
did_god_conduct(DID_DELIBERATE_MUTATING, 10, was_known);
return true;
}
};
class PotionResistance : public PotionEffect
{
private:
PotionResistance() : PotionEffect(POT_RESISTANCE) { }
DISALLOW_COPY_AND_ASSIGN(PotionResistance);
public:
static const PotionResistance &instance()
{
static PotionResistance inst; return inst;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
mprf(MSGCH_DURATION, "You feel protected.");
you.increase_duration(DUR_RESISTANCE, random2(pow) + 35);
return true;
}
};
class PotionLignify : public PotionEffect
{
private:
PotionLignify() : PotionEffect(POT_LIGNIFY) { }
DISALLOW_COPY_AND_ASSIGN(PotionLignify);
public:
static const PotionLignify &instance()
{
static PotionLignify inst; return inst;
}
bool can_quaff(string *reason = nullptr) const override
{
return transform(0, TRAN_TREE, false, true, reason);
}
bool effect(bool was_known = true, int=40, bool=true) const override
{
return transform(30, TRAN_TREE, !was_known);
}
bool quaff(bool was_known) const override
{
if (was_known)
{
if (!check_known_quaff() || !check_form_stat_safety(TRAN_TREE))
return false;
const cloud_type cloud = cloud_type_at(you.pos());
if (is_damaging_cloud(cloud, false)
// Tree form is immune to these two.
&& cloud != CLOUD_MEPHITIC && cloud != CLOUD_POISON
&& !yesno(make_stringf("Really become a tree while standing in "
"a cloud of %s?",
cloud_type_name(cloud).c_str()).c_str(),
false, 'n'))
{
canned_msg(MSG_OK);
return false;
}
}
if (effect(was_known))
{
you.transform_uncancellable = true;
did_god_conduct(DID_CHAOS, 10, was_known);
}
else
mpr("You feel woody for a moment.");
return true;
}
};
// Removed potions
#if TAG_MAJOR_VERSION == 34
class PotionDecay : public PotionEffect
{
private:
PotionDecay() : PotionEffect(POT_DECAY) { }
DISALLOW_COPY_AND_ASSIGN(PotionDecay);
public:
static const PotionDecay &instance()
{
static PotionDecay inst; return inst;
}
bool effect(bool=true, int=40, bool=true) const override
{
return you.rot(&you, 3 + random2(3));;
}
bool quaff(bool was_known) const override
{
if (effect())
xom_is_stimulated( 50 / _xom_factor(was_known));
return true;
}
};
class PotionBloodCoagulated : public PotionEffect
{
private:
PotionBloodCoagulated() : PotionEffect(POT_BLOOD_COAGULATED) { }
DISALLOW_COPY_AND_ASSIGN(PotionBloodCoagulated);
public:
static const PotionBloodCoagulated &instance()
{
static PotionBloodCoagulated inst; return inst;
}
bool effect(bool=true, int pow = 40, bool=true) const override
{
if (you.species == SP_VAMPIRE)
{
mpr("This tastes delicious.");
lessen_hunger(pow, true);
}
else
mpr(_blood_flavour_message());
// no actual effect, just 'flavour' ha ha ha
return true;
}
bool can_quaff(string *reason = nullptr) const override
{
if (you.hunger_state == HS_ENGORGED)
{
*reason = "You are much too full right now.";
return false;
}
return true;
}
bool quaff(bool was_known) const override
{
if (was_known && (!check_known_quaff() || !_prompt_quaff_blood()))
return false;
effect(was_known, 840);
did_god_conduct(DID_DRINK_BLOOD, 1 + random2(3), was_known);
return true;
}
};
class PotionGainStrength : public PotionEffect
{
private:
PotionGainStrength() : PotionEffect(POT_GAIN_STRENGTH) { }
DISALLOW_COPY_AND_ASSIGN(PotionGainStrength);
public:
static const PotionGainStrength &instance()
{
static PotionGainStrength inst; return inst;
}
bool effect(bool=true, int=40, bool=true) const override
{
return mutate(MUT_STRONG, "potion of gain strength",
true, false, false, true);
}
bool quaff(bool was_known) const override