forked from crawl/crawl
/
mutation.cc
2955 lines (2568 loc) · 93.2 KB
/
mutation.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 Functions for handling player mutations.
**/
#include "AppHdr.h"
#include "mutation.h"
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include "ability.h"
#include "act-iter.h"
#include "art-enum.h"
#include "butcher.h"
#include "cio.h"
#include "coordit.h"
#include "dactions.h"
#include "delay.h"
#include "english.h"
#include "env.h"
#include "god-abil.h"
#include "god-passive.h"
#include "hints.h"
#include "item-prop.h"
#include "items.h"
#include "libutil.h"
#include "menu.h"
#include "message.h"
#include "mon-death.h"
#include "mon-place.h"
#include "notes.h"
#include "output.h"
#include "player-equip.h" // lose_permafly_source
#include "player-stats.h"
#include "religion.h"
#include "skills.h"
#include "state.h"
#include "stringutil.h"
#include "transform.h"
#include "unicode.h"
#include "viewchar.h"
#include "xom.h"
static bool _delete_single_mutation_level(mutation_type mutat, const string &reason, bool transient);
struct body_facet_def
{
equipment_type eq;
mutation_type mut;
};
struct facet_def
{
int tier;
mutation_type muts[3];
int when[3];
};
struct demon_mutation_info
{
mutation_type mut;
int when;
int facet;
demon_mutation_info(mutation_type m, int w, int f)
: mut(m), when(w), facet(f) { }
};
enum class mutflag
{
good = 1 << 0, // used by benemut etc
bad = 1 << 1, // used by malmut etc
jiyva = 1 << 2, // jiyva-only muts
qazlal = 1 << 3, // qazlal wrath
xom = 1 << 4, // xom being xom
last = xom
};
DEF_BITFIELD(mutflags, mutflag, 4);
COMPILE_CHECK(mutflags::exponent(mutflags::last_exponent) == mutflag::last);
#include "mutation-data.h"
static const body_facet_def _body_facets[] =
{
//{ EQ_NONE, MUT_FANGS },
{ EQ_HELMET, MUT_HORNS },
{ EQ_HELMET, MUT_ANTENNAE },
//{ EQ_HELMET, MUT_BEAK },
{ EQ_GLOVES, MUT_CLAWS },
{ EQ_BOOTS, MUT_HOOVES },
{ EQ_BOOTS, MUT_TALONS }
};
/**
* Conflicting mutation pairs. Entries are symmetric (so if A conflicts
* with B, B conflicts with A in the same way).
*
* The third value in each entry means:
* 0: If the new mutation is forced, remove all levels of the old
* mutation. Either way, keep scanning for more conflicts and
* do what they say (accepting the mutation if there are no
* further conflicts).
*
* -1: If the new mutation is forced, remove all levels of the old
* mutation and scan for more conflicts. If it is not forced,
* fail at giving the new mutation.
*
* 1: If the new mutation is temporary, just allow the conflict.
* Otherwise, trade off: delete one level of the old mutation,
* don't give the new mutation, and consider it a success.
*
* It makes sense to have two entries for the same pair, one with value 0
* and one with 1: that would replace all levels of the old mutation if
* forced, or a single level if not forced. However, the 0 entry must
* precede the 1 entry; so if you re-order this list, keep all the 0s
* before all the 1s.
*/
static const int conflict[][3] =
{
{ MUT_REGENERATION, MUT_SLOW_METABOLISM, 0},
{ MUT_REGENERATION, MUT_INHIBITED_REGENERATION, 0},
{ MUT_ACUTE_VISION, MUT_BLURRY_VISION, 0},
{ MUT_FAST, MUT_SLOW, 0},
#if TAG_MAJOR_VERSION == 34
{ MUT_STRONG_STIFF, MUT_FLEXIBLE_WEAK, 1},
#endif
{ MUT_STRONG, MUT_WEAK, 1},
{ MUT_CLEVER, MUT_DOPEY, 1},
{ MUT_AGILE, MUT_CLUMSY, 1},
{ MUT_ROBUST, MUT_FRAIL, 1},
{ MUT_HIGH_MAGIC, MUT_LOW_MAGIC, 1},
{ MUT_WILD_MAGIC, MUT_SUBDUED_MAGIC, 1},
{ MUT_CARNIVOROUS, MUT_HERBIVOROUS, 1},
{ MUT_SLOW_METABOLISM, MUT_FAST_METABOLISM, 1},
{ MUT_REGENERATION, MUT_INHIBITED_REGENERATION, 1},
{ MUT_ACUTE_VISION, MUT_BLURRY_VISION, 1},
{ MUT_BERSERK, MUT_CLARITY, 1},
{ MUT_FAST, MUT_SLOW, 1},
{ MUT_FANGS, MUT_BEAK, -1},
{ MUT_ANTENNAE, MUT_HORNS, -1}, // currently overridden by physiology_mutation_conflict
{ MUT_HOOVES, MUT_TALONS, -1}, // currently overridden by physiology_mutation_conflict
{ MUT_TRANSLUCENT_SKIN, MUT_CAMOUFLAGE, -1},
{ MUT_MUTATION_RESISTANCE, MUT_EVOLUTION, -1},
{ MUT_ANTIMAGIC_BITE, MUT_ACIDIC_BITE, -1},
{ MUT_HEAT_RESISTANCE, MUT_HEAT_VULNERABILITY, -1},
{ MUT_COLD_RESISTANCE, MUT_COLD_VULNERABILITY, -1},
{ MUT_SHOCK_RESISTANCE, MUT_SHOCK_VULNERABILITY, -1},
{ MUT_MAGIC_RESISTANCE, MUT_MAGICAL_VULNERABILITY, -1},
{ MUT_NO_REGENERATION, MUT_INHIBITED_REGENERATION, -1},
{ MUT_NO_REGENERATION, MUT_REGENERATION, -1},
};
equipment_type beastly_slot(int mut)
{
switch (mut)
{
case MUT_HORNS:
case MUT_ANTENNAE:
// Not putting MUT_BEAK here because it doesn't conflict with the other two.
return EQ_HELMET;
case MUT_CLAWS:
return EQ_GLOVES;
case MUT_HOOVES:
case MUT_TALONS:
case MUT_TENTACLE_SPIKE:
return EQ_BOOTS;
default:
return EQ_NONE;
}
}
static bool _mut_has_use(const mutation_def &mut, mutflag use)
{
return bool(mut.uses & use);
}
#define MUT_BAD(mut) _mut_has_use((mut), mutflag::bad)
#define MUT_GOOD(mut) _mut_has_use((mut), mutflag::good)
static int _mut_weight(const mutation_def &mut, mutflag use)
{
switch (use)
{
case mutflag::jiyva:
case mutflag::qazlal:
case mutflag::xom:
return 1;
case mutflag::good:
case mutflag::bad:
default:
return mut.weight;
}
}
static int mut_index[NUM_MUTATIONS];
static int category_mut_index[MUT_NON_MUTATION - CATEGORY_MUTATIONS];
static map<mutflag, int> total_weight;
void init_mut_index()
{
total_weight.clear();
for (int i = 0; i < NUM_MUTATIONS; ++i)
mut_index[i] = -1;
for (unsigned int i = 0; i < ARRAYSZ(mut_data); ++i)
{
const mutation_type mut = mut_data[i].mutation;
ASSERT_RANGE(mut, 0, NUM_MUTATIONS);
ASSERT(mut_index[mut] == -1);
mut_index[mut] = i;
for (const auto flag : mutflags::range())
{
if (_mut_has_use(mut_data[i], flag))
total_weight[flag] += _mut_weight(mut_data[i], flag);
}
}
// this is all a bit silly but ok
for (int i = 0; i < MUT_NON_MUTATION - CATEGORY_MUTATIONS; ++i)
category_mut_index[i] = -1;
for (unsigned int i = 0; i < ARRAYSZ(category_mut_data); ++i)
{
const mutation_type mut = category_mut_data[i].mutation;
ASSERT_RANGE(mut, CATEGORY_MUTATIONS, MUT_NON_MUTATION);
ASSERT(category_mut_index[mut-CATEGORY_MUTATIONS] == -1);
category_mut_index[mut-CATEGORY_MUTATIONS] = i;
}
}
static const mutation_def& _get_mutation_def(mutation_type mut)
{
ASSERT_RANGE(mut, 0, NUM_MUTATIONS);
ASSERT(mut_index[mut] != -1);
return mut_data[mut_index[mut]];
}
/*
* Get the max number of possible levels for mutation `mut`. This is typically 1 or 3.
*
* @return the mutation cap.
*/
int get_mutation_cap(mutation_type mut)
{
return _get_mutation_def(mut).levels;
}
static const mutation_category_def& _get_category_mutation_def(mutation_type mut)
{
ASSERT_RANGE(mut, CATEGORY_MUTATIONS, MUT_NON_MUTATION);
ASSERT(category_mut_index[mut-CATEGORY_MUTATIONS] != -1);
return category_mut_data[category_mut_index[mut-CATEGORY_MUTATIONS]];
}
static bool _is_valid_mutation(mutation_type mut)
{
return mut >= 0 && mut < NUM_MUTATIONS && mut_index[mut] != -1;
}
static const mutation_type _all_scales[] =
{
MUT_DISTORTION_FIELD, MUT_ICY_BLUE_SCALES,
MUT_IRIDESCENT_SCALES, MUT_LARGE_BONE_PLATES,
MUT_MOLTEN_SCALES,
#if TAG_MAJOR_VERSION == 34
MUT_ROUGH_BLACK_SCALES,
#endif
MUT_RUGGED_BROWN_SCALES, MUT_SLIMY_GREEN_SCALES,
MUT_THIN_METALLIC_SCALES, MUT_THIN_SKELETAL_STRUCTURE,
MUT_YELLOW_SCALES, MUT_STURDY_FRAME,
MUT_SANGUINE_ARMOUR, MUT_SHIMMERING_SCALES,
};
// Permabuffs go here
static const mutation_type _all_permabuffs[] =
{
MUT_TRANSFORMATION, MUT_RING_OF_FLAMES,
MUT_REGEN_SPELL, MUT_SPECTRAL_WEAPON,
MUT_INFUSION, MUT_EXCRUCIATING_WOUNDS,
MUT_OZOCUBUS_ARMOUR, MUT_BATTLESPHERE,
MUT_SONG_OF_SLAYING, MUT_DEFLECT_MISSILES,
MUT_REPEL_MISSILES, MUT_CHILL_THREAD,
};
static bool _is_covering(mutation_type mut)
{
return find(begin(_all_scales), end(_all_scales), mut) != end(_all_scales);
}
bool is_body_facet(mutation_type mut)
{
return any_of(begin(_body_facets), end(_body_facets),
[=](const body_facet_def &facet)
{ return facet.mut == mut; });
}
bool is_permabuff(mutation_type mut)
{
return any_of(begin(_all_permabuffs), end(_all_permabuffs),
[=](const mutation_type &i){return i == mut;});
}
/*
* The degree to which `mut` is suppressed by the current form.
*
* @param mut the mutation to check.
*
* @return mutation_activity_type::FULL: completely available.
* mutation_activity_type::PARTIAL: partially suppressed.
* mutation_activity_type::INACTIVE: completely suppressed.
*/
mutation_activity_type mutation_activity_level(mutation_type mut)
{
// First make sure the player's form permits the mutation.
if (!form_keeps_mutations())
{
if (you.form == transformation::dragon)
{
monster_type drag = dragon_form_dragon_type();
if (mut == MUT_SHOCK_RESISTANCE && drag == MONS_STORM_DRAGON)
return mutation_activity_type::FULL;
if (mut == MUT_UNBREATHING && drag == MONS_IRON_DRAGON)
return mutation_activity_type::FULL;
if (mut == MUT_ACIDIC_BITE && drag == MONS_GOLDEN_DRAGON)
return mutation_activity_type::FULL;
if (mut == MUT_STINGER && drag == MONS_SWAMP_DRAGON)
return mutation_activity_type::FULL;
}
// Vampire bats keep their fangs.
if (you.form == transformation::bat
&& you.species == SP_VAMPIRE
&& mut == MUT_FANGS)
{
return mutation_activity_type::FULL;
}
// Dex and HP changes are kept in all forms.
#if TAG_MAJOR_VERSION == 34
if (mut == MUT_ROUGH_BLACK_SCALES)
return mutation_activity_type::PARTIAL;
#endif
if (mut == MUT_RUGGED_BROWN_SCALES)
return mutation_activity_type::PARTIAL;
else if (_get_mutation_def(mut).form_based)
return mutation_activity_type::INACTIVE;
}
if (you.form == transformation::statue)
{
// Statues get all but the AC benefit from scales, but are not affected
// by other changes in body material or speed.
switch (mut)
{
case MUT_GELATINOUS_BODY:
case MUT_TOUGH_SKIN:
case MUT_SHAGGY_FUR:
case MUT_FAST:
case MUT_SLOW:
case MUT_IRIDESCENT_SCALES:
return mutation_activity_type::INACTIVE;
#if TAG_MAJOR_VERSION == 34
case MUT_ROUGH_BLACK_SCALES:
#endif
case MUT_RUGGED_BROWN_SCALES:
case MUT_SHIMMERING_SCALES:
return mutation_activity_type::PARTIAL;
case MUT_YELLOW_SCALES:
case MUT_ICY_BLUE_SCALES:
case MUT_MOLTEN_SCALES:
case MUT_SLIMY_GREEN_SCALES:
case MUT_THIN_METALLIC_SCALES:
return you.get_base_mutation_level(mut) > 2 ? mutation_activity_type::PARTIAL :
mutation_activity_type::INACTIVE;
default:
break;
}
}
//XXX: Should this make claws inactive too?
if (you.form == transformation::blade_hands && mut == MUT_PAWS)
return mutation_activity_type::INACTIVE;
if (you.form == transformation::tree
&& (mut == MUT_BLINK || mut == MUT_TELEPORT))
{
return mutation_activity_type::INACTIVE;
}
if ((you_worship(GOD_PAKELLAS) || player_under_penance(GOD_PAKELLAS))
&& (mut == MUT_MANA_LINK || mut == MUT_MANA_REGENERATION))
{
return mutation_activity_type::INACTIVE;
}
if (!form_can_bleed(you.form) && mut == MUT_SANGUINE_ARMOUR)
return mutation_activity_type::INACTIVE;
if (mut == MUT_DEMONIC_GUARDIAN && you.get_mutation_level(MUT_NO_LOVE))
return mutation_activity_type::INACTIVE;
return mutation_activity_type::FULL;
}
// Counts of various statuses/types of mutations from the current/most
// recent call to describe_mutations. TODO: eliminate
static int _num_full_suppressed = 0;
static int _num_part_suppressed = 0;
static int _num_transient = 0;
static string _annotate_form_based(string desc, bool suppressed)
{
if (suppressed)
{
desc = "<darkgrey>((" + desc + "))</darkgrey>";
++_num_full_suppressed;
}
return desc + "\n";
}
static string _dragon_abil(string desc)
{
const bool supp = form_changed_physiology() && you.form != transformation::dragon;
return _annotate_form_based(desc, supp);
}
/*
* Does the player have mutation `mut` with at least one temporary level?
*
* Reminder: temporary mutations can coexist with innate or normal mutations.
*/
bool player::has_temporary_mutation(mutation_type mut) const
{
return you.temp_mutation[mut] > 0;
}
/*
* Does the player have mutation `mut` with at least one innate level?
*
* Reminder: innate mutations can coexist with temporary or normal mutations.
*/
bool player::has_innate_mutation(mutation_type mut) const
{
return you.innate_mutation[mut] > 0;
}
/*
* Does the player have mutation `mut` that is a permabuff?
*/
bool player::has_permabuffs(mutation_type mut) const
{
return you.permabuffs[mut] > 0;
}
/*
* How much of mutation `mut` does the player have? This ignores form changes.
* If all three bool arguments are false, this should always return 0.
*
* @param temp include temporary mutation levels. defaults to true.
* @param innate include innate mutation levels. defaults to true.
* @param normal include normal (non-temp, non-innate) mutation levels. defaults to true.
*
* @return the total levels of the mutation.
*/
int player::get_base_mutation_level(mutation_type mut, bool innate, bool temp, bool normal) const
{
ASSERT_RANGE(mut, 0, NUM_MUTATIONS);
// you.mutation stores the total levels of all mutations
int level = you.mutation[mut];
if (!temp)
level -= you.temp_mutation[mut];
if (!innate)
level -= you.innate_mutation[mut];
if (!normal)
level -= (you.mutation[mut] - (you.temp_mutation[mut] + you.innate_mutation[mut]));
ASSERT(level >= 0);
return level;
}
/*
* How much of mutation `mut` does the player have innately?
*
*/
int player::get_innate_mutation_level(mutation_type mut) const
{
ASSERT_RANGE(mut, 0, NUM_MUTATIONS);
return you.innate_mutation[mut];
}
/*
* How much of mutation `mut` does the player have temporarily?
*
*/
int player::get_temp_mutation_level(mutation_type mut) const
{
ASSERT_RANGE(mut, 0, NUM_MUTATIONS);
return you.temp_mutation[mut];
}
/*
* Get the current player mutation level for `mut`, possibly incorporating information about forms.
* See the other version of this function for the canonical usage of `minact`; some forms such as scale mutations
* have different thresholds depending on the purpose and form and so will call this directly (e.g. ac
* but not resistances are suppressed in statueform.)
*
* @param mut the mutation to check
* @param minact the minimum activity level needed for the mutation to count as non-suppressed.
*
* @return a mutation level, 0 if the mutation doesn't exist or is suppressed.
*/
int player::get_mutation_level(mutation_type mut, mutation_activity_type minact) const
{
ASSERT_RANGE(mut, 0, NUM_MUTATIONS);
if (mutation_activity_level(mut) < minact)
return 0;
return get_base_mutation_level(mut, true, true);
}
/*
* Get the current player mutation level for `mut`, possibly incorporating information about forms.
*
* @param mut the mutation to check
* @param check_form whether to incorporate suppression from forms. Defaults to true.
*
* @return a mutation level, 0 if the mutation doesn't exist or is suppressed.
*/
int player::get_mutation_level(mutation_type mut, bool check_form) const
{
return get_mutation_level(mut, check_form ? mutation_activity_type::PARTIAL :
mutation_activity_type::INACTIVE);
}
/*
* Does the player have mutation `mut` in some form?
*/
bool player::has_mutation(mutation_type mut, bool check_form) const
{
return get_mutation_level(mut, check_form) > 0;
}
/*
* Test the validity of the player mutation structures, using ASSERTs.
* Will crash on a failure.
*
* @debug_msg whether to output diagnostic `dprf`s in the process.
*/
void validate_mutations(bool debug_msg)
{
if (debug_msg)
dprf("Validating player mutations");
int total_temp = 0;
for (int i = 0; i < NUM_MUTATIONS; i++)
{
mutation_type mut = static_cast<mutation_type>(i);
if (debug_msg && you.mutation[mut] > 0)
{
dprf("mutation %s: total %d innate %d temp %d perma %d",
mutation_name(mut), you.mutation[mut],
you.innate_mutation[mut], you.temp_mutation[mut],
you.permabuffs[mut]);
}
ASSERT(you.mutation[mut] >= 0);
ASSERT(you.innate_mutation[mut] >= 0);
ASSERT(you.temp_mutation[mut] >= 0);
ASSERT(you.permabuffs[mut] >= 0);
ASSERT(you.get_base_mutation_level(mut) == you.mutation[mut]);
ASSERT(you.mutation[i] >= you.innate_mutation[mut] + you.temp_mutation[mut]);
total_temp += you.temp_mutation[mut];
const mutation_def& mdef = _get_mutation_def(mut);
ASSERT(you.mutation[mut] <= mdef.levels);
// reconstruct what the innate mutations should be based on Ds mutation schedule
// TODO generalize to all innate muts
if (you.species == SP_DEMONSPAWN)
{
bool is_trait = false;
int trait_level = 0;
// If the player has sacrificed xp, use the pre-sac xl; sac xp
// doesn't remove Ds mutations.
// You can still trick wizmode into crashing here.
const int check_xl = (you.get_mutation_level(MUT_INEXPERIENCED)
&& you.max_level <= you.get_experience_level() + 2)
? you.max_level
: you.get_experience_level();
for (player::demon_trait trait : you.demonic_traits)
{
if (trait.mutation == mut)
{
is_trait = true;
if (check_xl >= trait.level_gained)
trait_level += 1;
}
}
if (debug_msg && is_trait)
{
dprf("scheduled innate for %s: %d, actual %d", mutation_name(mut),
trait_level, you.innate_mutation[mut]);
}
if (is_trait)
ASSERT(you.innate_mutation[mut] == trait_level);
}
}
ASSERT(total_temp == you.attribute[ATTR_TEMP_MUTATIONS]);
ASSERT(you.attribute[ATTR_TEMP_MUT_XP] >=0);
if (total_temp > 0)
ASSERT(you.attribute[ATTR_TEMP_MUT_XP] > 0);
}
string describe_mutations(bool center_title)
{
#ifdef DEBUG
validate_mutations(true);
#endif
string result;
const char *mut_title = "Innate Abilities, Weirdness & Mutations";
_num_full_suppressed = _num_part_suppressed = 0;
_num_transient = 0;
if (center_title)
{
int offset = 39 - strwidth(mut_title) / 2;
if (offset < 0) offset = 0;
result += string(offset, ' ');
}
result += "<white>";
result += mut_title;
result += "</white>\n\n";
result += "<lightblue>";
const string old_result = result;
// Innate abilities which haven't been implemented as mutations yet.
// TODO: clean these up with respect to transformations. Currently
// we handle only Naga/Draconian AC and Yellow Draconian rAcid.
for (const string& str : fake_mutations(you.species, false))
{
if (species_is_draconian(you.species))
result += _dragon_abil(str);
else if (you.species == SP_MERFOLK)
result += _annotate_form_based(str, form_changed_physiology());
else if (you.species == SP_MINOTAUR)
result += _annotate_form_based(str, !form_keeps_mutations());
else
result += str + "\n";
}
if (you.racial_ac(false) > 0)
{
const string scale_clause = string(scale_type(you.species))
+ " scales are "
+ (you.species == SP_GREY_DRACONIAN ? "very " : "") + "hard";
result += _annotate_form_based(
make_stringf("Your %s. (AC +%d)",
you.species == SP_NAGA ? "serpentine skin is tough" :
you.species == SP_GARGOYLE ? "stone body is resilient" :
scale_clause.c_str(),
you.racial_ac(false) / 100),
player_is_shapechanged()
&& !(species_is_draconian(you.species)
&& you.form == transformation::dragon));
}
if (you.species == SP_VAMPIRE)
{
if (you.hunger_state <= HS_STARVING)
result += "<green>You do not heal naturally.</green>\n";
else if (you.hunger_state < HS_SATIATED)
result += "<green>You heal slowly.</green>\n";
else if (you.hunger_state >= HS_FULL)
result += "<green>Your natural rate of healing is unusually fast.</green>\n";
}
if (you.species == SP_OCTOPODE)
{
result += _annotate_form_based("You are amphibious.",
!form_likes_water());
const string num_tentacles =
number_in_words(you.has_usable_tentacles(false));
result += _annotate_form_based(
make_stringf("You can wear up to %s rings at the same time.",
num_tentacles.c_str()),
!get_form()->slot_available(EQ_RING_EIGHT));
result += _annotate_form_based(
make_stringf("You can use your tentacles to constrict %s enemies at once.",
num_tentacles.c_str()),
!form_keeps_mutations());
}
if (you.species == SP_ABOMINATION)
{
result += _annotate_form_based("You have gills and webbed feet.",
!form_likes_water());
const string num_tentacles =
number_in_words(you.has_usable_tentacles(false));
result += _annotate_form_based(
make_stringf("You can wear up to %s rings at the same time.",
num_tentacles.c_str()),
!get_form()->slot_available(EQ_RING_EIGHT));
}
if (you.species != SP_FELID)
{
switch (you.body_size(PSIZE_TORSO, true))
{
case SIZE_LITTLE:
result += "You are very small and have problems with some larger weapons.\n"
"You are too small for most types of armour.\n";
break;
case SIZE_SMALL:
result += "You are small and have problems with some larger weapons.\n";
break;
case SIZE_LARGE:
result += "You are too large for most types of armour.\n";
break;
default:
break;
}
}
// Could move this into species-data, but then the hack that assumes
// _dragon_abil should get called on all draconian fake muts would break.
if (species_is_draconian(you.species))
result += "You cannot fit into any form of body armour.\n";
if (player_res_poison(false, false, false) == 3)
result += "You are immune to poison.\n";
// Permabuffs are magical, so include them with innate abilities color
for (int i = 0; i < NUM_MUTATIONS; i++)
{
mutation_type mut_type = static_cast<mutation_type>(i);
if (you.has_permabuffs(mut_type))
{
result += mutation_desc(mut_type, 1);
result += "\n";
}
}
result += "</lightblue>";
// First add (non-removable) inborn abilities and demon powers.
for (int i = 0; i < NUM_MUTATIONS; i++)
{
mutation_type mut_type = static_cast<mutation_type>(i);
if (you.has_innate_mutation(mut_type))
{
result += mutation_desc(mut_type, -1, true,
((you.sacrifices[i] != 0) ? true : false));
result += "\n";
}
}
if (have_passive(passive_t::water_walk))
result += "<green>You can walk on water.</green>\n";
else if (you.can_water_walk())
{
result += "<lightgreen>You can walk on water until reaching land."
"</lightgreen>";
}
if (have_passive(passive_t::frail)
|| player_under_penance(GOD_HEPLIAKLQANA))
{
result += "<lightred>Your life essence is reduced to manifest your ancestor. (-10% HP)"
"</lightred>\n";
}
// Now add removable mutations.
for (int i = 0; i < NUM_MUTATIONS; i++)
{
mutation_type mut_type = static_cast<mutation_type>(i);
if (you.get_base_mutation_level(mut_type, false, false, true) > 0
&& !you.has_innate_mutation(mut_type) && !you.has_temporary_mutation(mut_type))
{
result += mutation_desc(mut_type, -1, true);
result += "\n";
}
}
//Finally, temporary mutations.
for (int i = 0; i < NUM_MUTATIONS; i++)
{
mutation_type mut_type = static_cast<mutation_type>(i);
if (you.has_temporary_mutation(mut_type))
{
result += mutation_desc(mut_type, -1, true);
result += "\n";
}
}
if (result == old_result + "</lightblue>") // Nothing was added
result += "You are rather mundane.\n";
return result;
}
static const string _vampire_Ascreen_footer = (
#ifdef USE_TILE_LOCAL
"<w>Right-click</w> or press '<w>!</w>'"
#else
"Press '<w>!</w>'"
#endif
" to toggle between mutations and properties depending on your blood\n"
"level.\n");
static const string _lava_orc_Ascreen_footer = (
#ifndef USE_TILE_LOCAL
"Press '<w>!</w>'"
#else
"<w>Right-click</w>"
#endif
" to toggle between mutations and properties depending on your\n"
"temperature.\n");
static void _display_vampire_attributes()
{
ASSERT(you.species == SP_VAMPIRE);
string result;
const int lines = 12;
string column[lines][5] =
{
{" ", "<green>Full</green> ", "Satiated ", "<yellow>Thirsty</yellow> ", "<lightred>Bloodless</lightred>"},
//Full Satiated Thirsty Bloodless
{"Metabolism ", "fast ", "normal ", "slow ", "none "},
{"Regeneration ", "fast ", "normal ", "slow ", "none "},
{"Stealth boost ", "none ", "none ", "minor ", "major "},
{"Hunger costs ", "full ", "full ", "halved ", "none "},
{"\n<w>Resistances</w>\n"
"Poison resistance ", " ", " ", "+ ", "immune"},
{"Cold resistance ", " ", " ", "+ ", "++ "},
{"Negative resistance ", " ", " + ", "++ ", "+++ "},
{"Rotting resistance ", " ", " ", "+ ", "+ "},
{"Torment resistance ", " ", " ", " ", "+ "},
{"\n<w>Transformations</w>\n"
"Bat form ", "no ", "yes ", "yes ", "yes "},
{"Other forms and \n"
"berserk ", "yes ", "yes ", "no ", "no "}
};
int current = 0;
switch (you.hunger_state)
{
case HS_ENGORGED:
case HS_VERY_FULL:
case HS_FULL:
current = 1;
break;
case HS_SATIATED:
current = 2;
break;
case HS_HUNGRY:
case HS_VERY_HUNGRY:
case HS_NEAR_STARVING:
current = 3;
break;
case HS_STARVING:
case HS_FAINTING:
current = 4;
}
for (int y = 0; y < lines; y++) // lines (properties)
{
for (int x = 0; x < 5; x++) // columns (hunger states)
{
if (y > 0 && x == current)
result += "<w>";
result += column[y][x];
if (y > 0 && x == current)
result += "</w>";
}
result += "\n";
}
result += "\n";
result += _vampire_Ascreen_footer;
formatted_scroller attrib_menu;
attrib_menu.add_text(result);
attrib_menu.show();
if (attrib_menu.getkey() == '!'
|| attrib_menu.getkey() == CK_MOUSE_CMD)
{
display_mutations();
}
}
static void _display_temperature()
{
ASSERT(you.species == SP_LAVA_ORC);
clrscr();
cgotoxy(1,1);
string result;
string title = "Temperature Effects";
// center title
int offset = 39 - strwidth(title) / 2;
if (offset < 0) offset = 0;
result += string(offset, ' ');
result += "<white>";
result += title;
result += "</white>\n\n";
const int lines = TEMP_MAX + 1; // 15 lines plus one for off-by-one.
string column[lines];
for (int t = 1; t <= TEMP_MAX; t++) // lines
{
string text;
ostringstream ostr;
string colourname = temperature_string(t);
#define F(x) stringize_glyph(dchar_glyph(DCHAR_FRAME_##x))
if (t == TEMP_MAX)
text = " " + F(TL) + F(HORIZ) + "MAX" + F(HORIZ) + F(HORIZ) + F(TR);
else if (t == TEMP_MIN)
text = " " + F(BL) + F(HORIZ) + F(HORIZ) + "MIN" + F(HORIZ) + F(BR);
else if (temperature() < t)
text = " " + F(VERT) + " " + F(VERT);
else if (temperature() == t)
text = " " + F(VERT) + "~~~~~~" + F(VERT);
else
text = " " + F(VERT) + "######" + F(VERT);
text += " ";
#undef F
ostr << '<' << colourname << '>' << text
<< "</" << colourname << '>';
colourname = (temperature() >= t) ? "lightred" : "darkgrey";
text = temperature_text(t);
ostr << '<' << colourname << '>' << text
<< "</" << colourname << '>';
column[t] = ostr.str();
}
for (int y = TEMP_MAX; y >= TEMP_MIN; y--) // lines
{
result += column[y];
result += "\n";
}
result += "\n";
result += "You get hot in tense situations, when berserking, or when you enter lava. You \ncool down when your rage ends or when you enter water.";
result += "\n";
result += "\n";
result += _lava_orc_Ascreen_footer;
formatted_scroller temp_menu;
temp_menu.add_text(result);
temp_menu.show();
if (temp_menu.getkey() == '!'
|| temp_menu.getkey() == CK_MOUSE_CMD)
{
display_mutations();
}
}
void display_mutations()
{
string mutation_s = describe_mutations(true);
string extra = "";
if (_num_part_suppressed)
extra += "<brown>()</brown> : Partially suppressed.\n";
if (_num_full_suppressed)
extra += "<darkgrey>(())</darkgrey>: Completely suppressed.\n";
if (_num_transient)
extra += "<magenta>[]</magenta> : Transient mutations.";
if (you.species == SP_VAMPIRE)
{
if (!extra.empty())
extra += "\n";
extra += _vampire_Ascreen_footer;
}
if (you.species == SP_LAVA_ORC)
{
if (!extra.empty())
extra += "\n";
extra += _lava_orc_Ascreen_footer;