forked from crawl/crawl
/
religion.cc
4696 lines (4077 loc) · 139 KB
/
religion.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 Misc religion related functions.
**/
#include "AppHdr.h"
#include "religion.h"
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <sstream>
#include "ability.h"
#include "acquire.h"
#include "act-iter.h"
#include "areas.h"
#include "attitude-change.h"
#include "branch.h"
#include "chardump.h"
#include "coordit.h"
#include "dactions.h"
#include "database.h"
#include "decks.h"
#include "delay.h"
#include "describe-god.h"
#include "dgn-event.h"
#include "dlua.h"
#include "english.h"
#include "env.h"
#include "exercise.h"
#include "god-abil.h"
#include "god-companions.h"
#include "god-conduct.h"
#include "god-item.h"
#include "god-passive.h"
#include "god-prayer.h"
#include "god-wrath.h"
#include "hints.h"
#include "hiscores.h"
#include "invent.h"
#include "item-name.h"
#include "item-prop.h"
#include "item-status-flag-type.h"
#include "items.h"
#include "level-state-type.h"
#include "libutil.h"
#include "makeitem.h"
#include "message.h"
#include "mon-gear.h" // give_shield
#include "mon-place.h"
#include "mutation.h"
#include "nearby-danger.h"
#include "notes.h"
#include "output.h"
#include "player-stats.h"
#include "prompt.h"
#include "randbook.h"
#include "shopping.h"
#include "skills.h"
#include "spl-book.h"
#include "spl-miscast.h"
#include "sprint.h"
#include "state.h"
#include "stringutil.h"
#include "terrain.h"
#include "transform.h"
#include "view.h"
#ifdef DEBUG_RELIGION
# define DEBUG_DIAGNOSTICS
# define DEBUG_GIFTS
# define DEBUG_SACRIFICE
# define DEBUG_PIETY
#endif
#define PIETY_HYSTERESIS_LIMIT 1
static weapon_type _hepliaklqana_weapon_type(monster_type mc, int HD);
static brand_type _hepliaklqana_weapon_brand(monster_type mc, int HD);
static armour_type _hepliaklqana_shield_type(monster_type mc, int HD);
static special_armour_type _hepliaklqana_shield_ego(int HD);
const vector<god_power> god_powers[NUM_GODS] =
{
// no god
{ },
// Zin
{ { 1, ABIL_ZIN_RECITE, "recite Zin's Axioms of Law" },
{ 2, ABIL_ZIN_VITALISATION, "call upon Zin for vitalisation" },
{ 3, ABIL_ZIN_IMPRISON, "call upon Zin to imprison the lawless" },
{ 5, ABIL_ZIN_SANCTUARY, "call upon Zin to create a sanctuary" },
{ 6, "Zin will cleanse your potions of mutation.",
"Zin will no longer cleanse your potions of mutation." },
{-1, ABIL_ZIN_DONATE_GOLD, "donate money to Zin" },
},
// TSO
{ { 1, "You and your allies can gain power from killing the unholy and evil.",
"You and your allies can no longer gain power from killing the unholy and evil." },
{ 2, ABIL_TSO_DIVINE_SHIELD, "call upon the Shining One for a divine shield" },
{ 4, ABIL_TSO_CLEANSING_FLAME, "channel blasts of cleansing flame", },
{ 5, ABIL_TSO_SUMMON_DIVINE_WARRIOR, "summon a divine warrior" },
{ 7, ABIL_TSO_BLESS_WEAPON,
"The Shining One will bless your weapon with holy wrath... once.",
"The Shining One is no longer ready to bless your weapon." },
},
// Kikubaaqudgha
{ { 1, ABIL_KIKU_RECEIVE_CORPSES, "receive cadavers from Kikubaaqudgha" },
{ 2, "Kikubaaqudgha is protecting you from necromantic miscasts and death curses.",
"Kikubaaqudgha no longer protects you from necromantic miscasts or death curses." },
{ 4, "Kikubaaqudgha is protecting you from unholy torment.",
"Kikubaaqudgha will no longer protect you from unholy torment." },
{ 5, ABIL_KIKU_TORMENT, "invoke torment by sacrificing a corpse" },
{ 7, ABIL_KIKU_BLESS_WEAPON,
"Kikubaaqudgha will grant you a Necronomicon or bloody your weapon with pain... once.",
"Kikubaaqudgha is no longer ready to enhance your necromancy." },
{ 7, ABIL_KIKU_GIFT_NECRONOMICON,
"Kikubaaqudgha will grant you a Necronomicon.",
"Kikubaaqudgha is no longer ready to enhance your necromancy." },
},
// Yredelemnul
{ { 1, ABIL_YRED_ANIMATE_REMAINS, "animate remains" },
{ 2, ABIL_YRED_RECALL_UNDEAD_SLAVES, "recall your undead slaves" },
{ 2, ABIL_YRED_INJURY_MIRROR, "mirror injuries on your foes" },
{ 3, ABIL_YRED_ANIMATE_DEAD, "animate legions of the dead" },
{ 3, "Yredelemnul will gift you servants as you gain piety.",
"Yredelemnul will no longer gift you servants." },
{ 4, ABIL_YRED_DRAIN_LIFE, "drain ambient life force" },
{ 5, ABIL_YRED_ENSLAVE_SOUL, "enslave living souls" },
},
// Xom
{ },
// Vehumet
{ { 1, "gain magical power from killing" },
{ 3, "Vehumet is aiding your destructive magics.",
"Vehumet will no longer aid your destructive magics." },
{ 4, "Vehumet is extending the range of your destructive magics.",
"Vehumet will no longer extend the range of your destructive magics." },
},
// Okawaru
{ { 1, ABIL_OKAWARU_HEROISM, "gain great but temporary skills" },
{ 3, "Okawaru will protect your ammunition and always make it return.",
"Okawaru will no protect your ammunition or make it return." },
{ 5, ABIL_OKAWARU_FINESSE, "speed up your combat" },
{ 5, "Okawaru will gift you equipment as you gain piety.",
"Okawaru will no longer gift you equipment." },
},
// Makhleb
{ { 1, "gain health from killing" },
{ 2, ABIL_MAKHLEB_MINOR_DESTRUCTION, "harness Makhleb's destructive might" },
{ 3, ABIL_MAKHLEB_LESSER_SERVANT_OF_MAKHLEB, "summon a lesser servant of Makhleb" },
{ 4, ABIL_MAKHLEB_MAJOR_DESTRUCTION, "hurl Makhleb's greater destruction" },
{ 5, ABIL_MAKHLEB_GREATER_SERVANT_OF_MAKHLEB, "summon a greater servant of Makhleb" },
},
// Sif Muna
{ { 1, ABIL_SIF_MUNA_DIVINE_ENERGY, "request divine energy to cast spells "
"with insufficient magic",
"request divine energy" },
{ 2, "Sif Muna is protecting you from the effects of miscast magic.",
"Sif Muna no longer protects you from the effects of miscast magic." },
{ 3, ABIL_SIF_MUNA_CHANNEL_ENERGY, "call upon Sif Muna for magical energy"},
{ 4, ABIL_SIF_MUNA_FORGET_SPELL, "freely open your mind to new spells",
"forget spells at will" },
{ 5, "Sif Muna will gift you books as you gain piety.",
"Sif Muna will no longer gift you books." },
},
// Trog
{
{ 1, ABIL_TROG_BERSERK, "go berserk at will" },
{ 2, ABIL_TROG_REGEN_MR, "call upon Trog for regeneration and protection "
"from hostile enchantments" },
{ 4, ABIL_TROG_BROTHERS_IN_ARMS, "call in reinforcements" },
{ 5, "Trog will gift you weapons as you gain piety.",
"Trog will no longer gift you weapons." },
},
// Nemelex
{ { 3, ABIL_NEMELEX_TRIPLE_DRAW, "choose one out of three cards" },
{ 4, ABIL_NEMELEX_DEAL_FOUR, "deal four cards at a time" },
{ 5, ABIL_NEMELEX_STACK_FIVE, "order the top five cards of a deck, losing the rest",
"stack decks" },
},
// Elyvilon
{ { 1, ABIL_ELYVILON_LESSER_HEALING, "provide lesser healing for yourself" },
{ 2, ABIL_ELYVILON_HEAL_OTHER, "heal and attempt to pacify others" },
{ 3, ABIL_ELYVILON_PURIFICATION, "purify yourself" },
{ 4, ABIL_ELYVILON_GREATER_HEALING, "provide greater healing for yourself" },
{ 5, ABIL_ELYVILON_DIVINE_VIGOUR, "call upon Elyvilon for divine vigour" },
{ 1, ABIL_ELYVILON_LIFESAVING, "call on Elyvilon to save your life" },
},
// Lugonu
{ { 1, ABIL_LUGONU_ABYSS_EXIT, "depart the Abyss", "depart the Abyss at will" },
{ 2, ABIL_LUGONU_BEND_SPACE, "bend space around yourself" },
{ 3, ABIL_LUGONU_BANISH, "banish your foes" },
{ 4, ABIL_LUGONU_CORRUPT, "corrupt the fabric of space" },
{ 5, ABIL_LUGONU_ABYSS_ENTER, "gate yourself to the Abyss" },
{ 7, ABIL_LUGONU_BLESS_WEAPON, "Lugonu will corrupt your weapon with distortion... once.",
"Lugonu is no longer ready to corrupt your weapon." },
},
// Beogh
{ { 2, ABIL_BEOGH_SMITING, "smite your foes" },
{ 3, "gain orcish followers" },
{ 4, ABIL_BEOGH_RECALL_ORCISH_FOLLOWERS, "recall your orcish followers" },
{ 5, "walk on water" },
{ 5, ABIL_BEOGH_GIFT_ITEM, "give items to your followers" },
{ 6, ABIL_BEOGH_RESURRECTION, "revive fallen orcs" },
},
// Jiyva
{ { 1, ABIL_JIYVA_CALL_JELLY, "request a jelly" },
{ 3, "Jiyva will mutate your body as you gain piety.",
"Jiyva will no longer mutate your body." },
{ 4, ABIL_JIYVA_SLIMIFY, "turn your foes to slime" },
{ 5, "You may now expel jellies when seriously injured.",
"You will no longer expel jellies when injured." },
{ 5, ABIL_JIYVA_CURE_BAD_MUTATION, "call upon Jiyva to remove your harmful mutations" },
},
// Fedhas
{
{ 0, ABIL_FEDHAS_FUNGAL_BLOOM, "turn corpses into toadstools" },
{ 1, ABIL_FEDHAS_EVOLUTION, "induce evolution" },
{ 2, ABIL_FEDHAS_SUNLIGHT, "call sunshine" },
{ 3, ABIL_FEDHAS_PLANT_RING, "cause a ring of plants to grow" },
{ 4, ABIL_FEDHAS_SPAWN_SPORES, "spawn explosive spores" },
{ 5, ABIL_FEDHAS_RAIN, "control the weather" },
},
// Cheibriados
{ { 0, ABIL_CHEIBRIADOS_TIME_BEND, "bend time to slow others" },
{ 1, "Cheibriados slows and strengthens your metabolism.",
"Cheibriados no longer slows and strengthens your metabolism." },
{ 3, ABIL_CHEIBRIADOS_DISTORTION, "warp the flow of time around you" },
{ 4, ABIL_CHEIBRIADOS_SLOUCH, "inflict damage on those overly hasty" },
{ 5, ABIL_CHEIBRIADOS_TIME_STEP, "step out of the time flow" },
},
// Ashenzari
{ { 0, ABIL_ASHENZARI_CURSE, "curse your items" },
{ 1, ABIL_ASHENZARI_SCRYING, "scry through walls" },
{ 2, "The more cursed you are, the more Ashenzari supports your skills.",
"Ashenzari no longer supports your skills." },
{ 3, "Ashenzari reveals the unseen.",
"Ashenzari no longer reveals the unseen." },
{ 4, "Ashenzari keeps your mind clear.",
"Ashenzari no longer keeps your mind clear." },
{ 5, ABIL_ASHENZARI_TRANSFER_KNOWLEDGE,
"Ashenzari helps you to reconsider your skills.",
"Ashenzari no longer helps you to reconsider your skills." },
},
// Dithmenos
{ { 2, ABIL_DITHMENOS_SHADOW_STEP, "step into the shadows of nearby creatures" },
{ 3, "You now sometimes bleed smoke when heavily injured by enemies.",
"You no longer bleed smoke." },
{ 4, "Your shadow now sometimes tangibly mimics your actions.",
"Your shadow no longer tangibly mimics your actions." },
{ 5, ABIL_DITHMENOS_SHADOW_FORM, "transform into a swirling mass of shadows" },
},
// Gozag
{ { 0, ABIL_GOZAG_POTION_PETITION, "petition Gozag for potion effects" },
{ 0, ABIL_GOZAG_CALL_MERCHANT, "fund merchants seeking to open stores in the dungeon" },
{ 0, ABIL_GOZAG_BRIBE_BRANCH, "bribe branches to halt enemies' attacks and recruit allies" },
},
// Qazlal
{
{ 0, "Qazlal grants you immunity to clouds." },
{ 1, "You are surrounded by a storm.", "Your storm dissipates completely." },
{ 2, ABIL_QAZLAL_UPHEAVAL, "call upon nature to destroy your foes" },
{ 3, ABIL_QAZLAL_ELEMENTAL_FORCE, "give life to nearby clouds" },
{ 4, "The storm surrounding you is powerful enough to repel missiles.",
"The storm surrounding you is now too weak to repel missiles." },
{ 4, "You adapt resistances upon receiving elemental damage.",
"You no longer adapt resistances upon receiving elemental damage." },
{ 5, ABIL_QAZLAL_DISASTER_AREA, "call upon nature's wrath in a wide area around you" },
},
// Ru
{ { 1, "You exude an aura of power that intimidates your foes.",
"You no longer exude an aura of power that intimidates your foes." },
{ 2, "Your aura of power can strike those that harm you.",
"Your aura of power no longer strikes those that harm you." },
{ 3, ABIL_RU_DRAW_OUT_POWER, "heal your body and restore your magic" },
{ 4, ABIL_RU_POWER_LEAP, "gather your power into a mighty leap" },
{ 5, ABIL_RU_APOCALYPSE, "wreak a terrible wrath on your foes" },
},
// Pakellas
{
{ 0, "gain magical power from killing" },
{ 3, ABIL_PAKELLAS_DEVICE_SURGE,
"spend magic to empower your devices" },
},
// Uskayaw
{
{ 1, ABIL_USKAYAW_STOMP, "stomp with the beat" },
{ 2, ABIL_USKAYAW_LINE_PASS, "pass through a line of other dancers" },
{ 3, "Uskayaw will force your foes to helplessly watch your dance.",
"Uskayaw will no longer force your foes to helplessly watch your dance."},
{ 4, "Uskayaw will force your foes to share their pain.",
"Uskayaw will no longer force your foes to share their pain."},
{ 5, ABIL_USKAYAW_GRAND_FINALE, "merge with and destroy a victim" },
},
// Hepliaklqana
{ { 0, ABIL_HEPLIAKLQANA_RECALL, "recall your ancestor" },
{ 0, ABIL_HEPLIAKLQANA_IDENTITY, "remember your ancestor's identity" },
{ 3, ABIL_HEPLIAKLQANA_TRANSFERENCE, "swap creatures with your ancestor" },
{ 4, ABIL_HEPLIAKLQANA_IDEALISE, "heal and protect your ancestor" },
{ 5, "drain nearby creatures when transferring your ancestor"},
},
// Wu Jian
{ { 0, "perform damaging attacks by moving towards foes",
"perform lunging strikes" },
{ 1, "lightly attack and pin monsters in place by moving around them",
"perform spinning attacks" },
{ 2, ABIL_WU_JIAN_WALLJUMP,
"perform airborne attacks" },
{ 3, ABIL_WU_JIAN_SERPENTS_LASH, "briefly move at supernatural speeds",
"move at supernatural speeds" },
{ 5, ABIL_WU_JIAN_HEAVENLY_STORM, "summon a storm of heavenly clouds to empower your attacks",
"summon a storm of heavenly clouds" },
},
};
vector<god_power> get_god_powers(god_type god)
{
vector<god_power> ret;
for (const auto& power : god_powers[god])
{
if (!(power.abil != ABIL_NON_ABILITY
&& fixup_ability(power.abil) == ABIL_NON_ABILITY))
{
ret.push_back(power);
}
}
return ret;
}
/**
* Print a description of getting/losing this power.
*
* @param gaining If true, use this->gain; otherwise, use this->loss.
* @param fmt A string containing "%s" that will be used as a format
* string with our string as parameter; it is not used if
* our string begins with a capital letter. IF THIS DOES
* NOT CONTAIN "%s", OR CONTAINS OTHER FORMAT SPECIFIERS,
* BEHAVIOUR IS UNDEFINED.
* @return a string suitable for being read by the user.
*/
void god_power::display(bool gaining, const char* fmt) const
{
// hack: don't mention the necronomicon alone unless it wasn't
// already mentioned by the other message
if (abil == ABIL_KIKU_GIFT_NECRONOMICON
&& you.species != SP_FELID)
{
return;
}
const char* str = gaining ? gain : loss;
if (isupper(str[0]))
god_speaks(you.religion, str);
else
god_speaks(you.religion, make_stringf(fmt, str).c_str());
}
static void _place_delayed_monsters();
bool is_evil_god(god_type god)
{
return god == GOD_KIKUBAAQUDGHA
|| god == GOD_MAKHLEB
|| god == GOD_YREDELEMNUL
|| god == GOD_BEOGH
|| god == GOD_LUGONU
|| god == GOD_DITHMENOS;
}
bool is_good_god(god_type god)
{
return god == GOD_ZIN
|| god == GOD_SHINING_ONE
|| god == GOD_ELYVILON;
}
bool is_chaotic_god(god_type god)
{
return god == GOD_XOM
|| god == GOD_MAKHLEB
|| god == GOD_LUGONU
|| god == GOD_JIYVA;
}
bool is_unknown_god(god_type god)
{
return god == GOD_NAMELESS;
}
// Not appearing in new games, but still extant.
static bool _is_disabled_god(god_type god)
{
switch (god)
{
// Disabled, pending a rework.
case GOD_PAKELLAS:
return true;
default:
return false;
}
}
bool is_unavailable_god(god_type god)
{
if (_is_disabled_god(god))
return true;
if (god == GOD_JIYVA && jiyva_is_dead())
return true;
return false;
}
bool god_has_name(god_type god)
{
return god != GOD_NO_GOD && god != GOD_NAMELESS;
}
god_type random_god()
{
god_type god;
do
{
god = static_cast<god_type>(random2(NUM_GODS - 1) + 1);
}
while (is_unavailable_god(god));
return god;
}
god_iterator::god_iterator() :
i(0) { } // might be ok to start with GOD_ZIN instead?
god_iterator::operator bool() const
{
return i < NUM_GODS;
}
const god_type god_iterator::operator*() const
{
if (i < NUM_GODS)
return (god_type)i;
else
return GOD_NO_GOD;
}
const god_type god_iterator::operator->() const
{
return **this;
}
god_iterator& god_iterator::operator++()
{
++i;
return *this;
}
god_iterator god_iterator::operator++(int)
{
god_iterator copy = *this;
++(*this);
return copy;
}
bool active_penance(god_type god)
{
// Good gods only have active wrath when they hate your current god.
return player_under_penance(god)
&& !is_unavailable_god(god)
&& god != GOD_ASHENZARI
&& god != GOD_GOZAG
&& god != GOD_RU
&& god != GOD_HEPLIAKLQANA
&& god != GOD_PAKELLAS
&& god != GOD_ELYVILON
&& (god == you.religion && !is_good_god(god)
|| god_hates_your_god(god, you.religion));
}
// True for gods whose wrath is passive and expires with XP gain.
bool xp_penance(god_type god)
{
return player_under_penance(god)
&& !is_unavailable_god(god)
&& (god == GOD_ASHENZARI
|| god == GOD_GOZAG
|| god == GOD_HEPLIAKLQANA
|| god == GOD_PAKELLAS
|| god == GOD_ELYVILON)
&& god_hates_your_god(god, you.religion);
}
void dec_penance(god_type god, int val)
{
if (val <= 0 || you.penance[god] <= 0)
return;
#ifdef DEBUG_PIETY
mprf(MSGCH_DIAGNOSTICS, "Decreasing penance by %d", val);
#endif
if (you.penance[god] <= val)
{
const bool had_halo = have_passive(passive_t::halo);
const bool had_umbra = have_passive(passive_t::umbra);
you.penance[god] = 0;
mark_milestone("god.mollify",
"mollified " + god_name(god) + ".");
const bool dead_jiyva = (god == GOD_JIYVA && jiyva_is_dead());
simple_god_message(
make_stringf(" seems mollified%s.",
dead_jiyva ? ", and vanishes" : "").c_str(),
god);
if (dead_jiyva)
add_daction(DACT_REMOVE_JIYVA_ALTARS);
take_note(Note(NOTE_MOLLIFY_GOD, god));
if (you_worship(god))
{
// Redraw piety display and, in case the best skill is Invocations,
// redraw the god title.
you.redraw_title = true;
// TSO's halo is once more available.
if (!had_halo && have_passive(passive_t::halo))
{
mprf(MSGCH_GOD, "Your divine halo returns!");
invalidate_agrid(true);
}
if (!had_umbra && have_passive(passive_t::umbra))
{
mprf(MSGCH_GOD, "Your aura of darkness returns!");
invalidate_agrid(true);
}
if (have_passive(passive_t::sinv))
{
mprf(MSGCH_GOD, "Your vision regains its divine sight.");
autotoggle_autopickup(false);
}
if (have_passive(passive_t::stat_boost))
{
simple_god_message(" restores the support of your attributes.");
redraw_screen();
notify_stat_change();
}
if (have_passive(passive_t::storm_shield))
{
mprf(MSGCH_GOD, "A storm instantly forms around you!");
you.redraw_armour_class = true; // also handles shields
}
// When you've worked through all your penance, you get
// another chance to make hostile slimes strict neutral.
if (have_passive(passive_t::neutral_slimes))
add_daction(DACT_SLIME_NEW_ATTEMPT);
if (have_passive(passive_t::friendly_plants)
&& env.forest_awoken_until)
{
// XXX: add a dact here & on-join to handle offlevel
// awakened forests?
for (monster_iterator mi; mi; ++mi)
mi->del_ench(ENCH_AWAKEN_FOREST);
}
}
else
{
if (god == GOD_PAKELLAS)
{
// Penance just ended w/o worshipping Pakellas;
// notify the player that MP regeneration will start again.
mprf(MSGCH_GOD, god, "You begin regenerating magic.");
}
else if (god == GOD_HEPLIAKLQANA)
{
calc_hp(); // frailty ends
mprf(MSGCH_GOD, god, "Your full life essence returns.");
}
}
}
else
{
you.penance[god] -= val;
return;
}
// We only get this far if we just mollified a god.
// If we just mollified a god, see if we have any angry gods left.
// If we don't, clear the stored wrath / XP counter.
god_iterator it;
for (; it; ++it)
{
if (active_penance(*it))
break;
}
if (it)
return;
you.attribute[ATTR_GOD_WRATH_COUNT] = 0;
you.attribute[ATTR_GOD_WRATH_XP] = 0;
}
void dec_penance(int val)
{
dec_penance(you.religion, val);
}
// TODO: find out what this is duplicating & deduplicate it
static bool _need_water_walking()
{
return you.ground_level() && you.species != SP_MERFOLK
&& grd(you.pos()) == DNGN_DEEP_WATER;
}
static void _grant_temporary_waterwalk()
{
mprf("Your water-walking will last only until you reach solid ground.");
you.props[TEMP_WATERWALK_KEY] = true;
}
bool jiyva_is_dead()
{
return you.royal_jelly_dead
&& !you_worship(GOD_JIYVA) && !you.penance[GOD_JIYVA];
}
void set_penance_xp_timeout()
{
if (you.attribute[ATTR_GOD_WRATH_XP] > 0)
return;
// TODO: make this more random?
you.attribute[ATTR_GOD_WRATH_XP] +=
max(div_rand_round(exp_needed(you.experience_level + 1)
- exp_needed(you.experience_level),
200),
1);
}
static void _inc_penance(god_type god, int val)
{
if (val <= 0)
return;
if (!player_under_penance(god))
{
god_acting gdact(god, true);
take_note(Note(NOTE_PENANCE, god));
const bool had_halo = have_passive(passive_t::halo);
const bool had_umbra = have_passive(passive_t::umbra);
you.penance[god] += val;
you.penance[god] = min((uint8_t)MAX_PENANCE, you.penance[god]);
if (had_halo && !have_passive(passive_t::halo))
{
mprf(MSGCH_GOD, god, "Your divine halo fades away.");
invalidate_agrid();
}
if (had_umbra && !have_passive(passive_t::umbra))
{
mprf(MSGCH_GOD, god, "Your aura of darkness fades away.");
invalidate_agrid();
}
if (will_have_passive(passive_t::water_walk)
&& _need_water_walking() && !have_passive(passive_t::water_walk))
{
_grant_temporary_waterwalk();
}
if (will_have_passive(passive_t::stat_boost))
{
redraw_screen();
notify_stat_change();
}
if (god == GOD_TROG)
{
if (you.duration[DUR_TROGS_HAND])
trog_remove_trogs_hand();
make_god_gifts_disappear();
}
else if (god == GOD_ZIN)
{
if (you.duration[DUR_DIVINE_STAMINA])
zin_remove_divine_stamina();
if (env.sanctuary_time)
remove_sanctuary();
}
else if (god == GOD_SHINING_ONE)
{
if (you.duration[DUR_DIVINE_SHIELD])
tso_remove_divine_shield();
make_god_gifts_disappear();
}
else if (god == GOD_ELYVILON)
{
if (you.duration[DUR_DIVINE_VIGOUR])
elyvilon_remove_divine_vigour();
}
else if (god == GOD_JIYVA)
{
if (you.duration[DUR_SLIMIFY])
you.duration[DUR_SLIMIFY] = 0;
}
else if (god == GOD_QAZLAL)
{
// Can't use have_passive(passive_t::storm_shield) because we
// just gained penance.
if (you.piety >= piety_breakpoint(0))
{
mprf(MSGCH_GOD, god, "The storm surrounding you dissipates.");
you.redraw_armour_class = true;
}
if (you.duration[DUR_QAZLAL_FIRE_RES])
{
mprf(MSGCH_DURATION, "Your resistance to fire fades away.");
you.duration[DUR_QAZLAL_FIRE_RES] = 0;
}
if (you.duration[DUR_QAZLAL_COLD_RES])
{
mprf(MSGCH_DURATION, "Your resistance to cold fades away.");
you.duration[DUR_QAZLAL_COLD_RES] = 0;
}
if (you.duration[DUR_QAZLAL_ELEC_RES])
{
mprf(MSGCH_DURATION,
"Your resistance to electricity fades away.");
you.duration[DUR_QAZLAL_ELEC_RES] = 0;
}
if (you.duration[DUR_QAZLAL_AC])
{
mprf(MSGCH_DURATION,
"Your resistance to physical damage fades away.");
you.duration[DUR_QAZLAL_AC] = 0;
you.redraw_armour_class = true;
}
}
else if (god == GOD_PAKELLAS)
{
if (you.duration[DUR_DEVICE_SURGE])
you.duration[DUR_DEVICE_SURGE] = 0;
}
else if (god == GOD_SIF_MUNA)
{
if (you.duration[DUR_CHANNEL_ENERGY])
you.duration[DUR_CHANNEL_ENERGY] = 0;
if (you.attribute[ATTR_DIVINE_ENERGY])
you.attribute[ATTR_DIVINE_ENERGY] = 0;
}
if (you_worship(god))
{
// Redraw piety display and, in case the best skill is Invocations,
// redraw the god title.
you.redraw_title = true;
}
}
else
{
you.penance[god] += val;
you.penance[god] = min((uint8_t)MAX_PENANCE, you.penance[god]);
}
set_penance_xp_timeout();
}
static void _inc_penance(int val)
{
_inc_penance(you.religion, val);
}
static void _set_penance(god_type god, int val)
{
you.penance[god] = val;
}
static void _set_wrath_penance(god_type god)
{
_set_penance(god, initial_wrath_penance_for(god));
}
static void _inc_gift_timeout(int val)
{
if (200 - you.gift_timeout < val)
you.gift_timeout = 200;
else
you.gift_timeout += val;
}
// These are sorted in order of power.
static monster_type _yred_servants[] =
{
MONS_MUMMY, MONS_WIGHT, MONS_FLYING_SKULL, MONS_WRAITH,
MONS_VAMPIRE, MONS_PHANTASMAL_WARRIOR, MONS_SKELETAL_WARRIOR,
MONS_FLAYED_GHOST, MONS_VAMPIRE_KNIGHT, MONS_GHOUL, MONS_BONE_DRAGON,
MONS_PROFANE_SERVITOR
};
#define MIN_YRED_SERVANT_THRESHOLD 3
#define MAX_YRED_SERVANT_THRESHOLD ARRAYSZ(_yred_servants)
static bool _yred_high_level_servant(monster_type type)
{
return type == MONS_BONE_DRAGON
|| type == MONS_PROFANE_SERVITOR;
}
int yred_random_servants(unsigned int threshold, bool force_hostile)
{
if (threshold == 0)
{
if (force_hostile)
{
// This implies wrath - scale the threshold with XL.
threshold =
MIN_YRED_SERVANT_THRESHOLD
+ (MAX_YRED_SERVANT_THRESHOLD - MIN_YRED_SERVANT_THRESHOLD)
* you.experience_level / 27;
}
else
threshold = ARRAYSZ(_yred_servants);
}
else
{
threshold = min(static_cast<unsigned int>(ARRAYSZ(_yred_servants)),
threshold);
}
const unsigned int servant = random2(threshold);
// Skip some of the weakest servants, once the threshold is high.
if ((servant + 2) * 2 < threshold)
return -1;
monster_type mon_type = _yred_servants[servant];
// Cap some of the strongest servants.
if (!force_hostile && _yred_high_level_servant(mon_type))
{
int current_high_level = 0;
for (auto &entry : companion_list)
{
monster* mons = monster_by_mid(entry.first);
if (!mons)
mons = &entry.second.mons.mons;
if (_yred_high_level_servant(mons->type))
current_high_level++;
}
if (current_high_level >= 3)
return -1;
}
int how_many = (mon_type == MONS_FLYING_SKULL) ? 2 + random2(4)
: 1;
mgen_data mg(mon_type, !force_hostile ? BEH_FRIENDLY : BEH_HOSTILE,
you.pos(), MHITYOU);
mg.set_summoned(!force_hostile ? &you : 0, 0, 0, GOD_YREDELEMNUL);
if (force_hostile)
mg.non_actor_summoner = "the anger of Yredelemnul";
int created = 0;
if (force_hostile)
{
mg.extra_flags |= (MF_NO_REWARD | MF_HARD_RESET);
for (; how_many > 0; --how_many)
{
if (create_monster(mg))
created++;
}
}
else
{
for (; how_many > 0; --how_many)
delayed_monster(mg);
}
return created;
}
static bool _need_missile_gift(bool forced)
{
skill_type sk = best_skill(SK_SLINGS, SK_THROWING);
// Default to throwing if all missile skills are at zero.
if (you.skills[sk] == 0)
sk = SK_THROWING;
return forced
|| (you.piety >= piety_breakpoint(2)
&& random2(you.piety) > 70
&& one_chance_in(8)
&& x_chance_in_y(1 + you.skills[sk], 12));
}
static bool _give_nemelex_gift(bool forced = false)
{
// But only if you're not flying over deep water.
if (!(feat_has_solid_floor(grd(you.pos()))
|| feat_is_watery(grd(you.pos())) && species_likes_water(you.species)))
{
return false;
}
// Nemelex will give at least one gift early.
if (forced
|| !you.num_total_gifts[GOD_NEMELEX_XOBEH]
&& x_chance_in_y(you.piety + 1, piety_breakpoint(1))
|| one_chance_in(3) && x_chance_in_y(you.piety + 1, MAX_PIETY))
{
misc_item_type gift_type = random_choose_weighted(
5, MISC_DECK_OF_DESTRUCTION,
4, MISC_DECK_OF_SUMMONING,
2, MISC_DECK_OF_ESCAPE);
int thing_created = items(true, OBJ_MISCELLANY, gift_type, 1, 0,
GOD_NEMELEX_XOBEH);
move_item_to_grid(&thing_created, you.pos(), true);
if (thing_created != NON_ITEM)
{
// Piety|Common | Rare |Legendary
// --------------------------------
// 0: 95.00%, 5.00%, 0.00%
// 20: 86.00%, 10.50%, 3.50%
// 40: 77.00%, 16.00%, 7.00%
// 60: 68.00%, 21.50%, 10.50%
// 80: 59.00%, 27.00%, 14.00%
// 100: 50.00%, 32.50%, 17.50%
// 120: 41.00%, 38.00%, 21.00%
// 140: 32.00%, 43.50%, 24.50%
// 160: 23.00%, 49.00%, 28.00%
// 180: 14.00%, 54.50%, 31.50%
// 200: 5.00%, 60.00%, 35.00%
const int common_weight = 95 - (90 * you.piety / MAX_PIETY);
const int rare_weight = 5 + (55 * you.piety / MAX_PIETY);
const int legend_weight = 0 + (35 * you.piety / MAX_PIETY);
const deck_rarity_type rarity = random_choose_weighted(
common_weight, DECK_RARITY_COMMON,
rare_weight, DECK_RARITY_RARE,
legend_weight, DECK_RARITY_LEGENDARY);
item_def &deck(mitm[thing_created]);
deck.deck_rarity = rarity;
deck.flags |= ISFLAG_KNOW_TYPE;
simple_god_message(" grants you a gift!");
// included in default force_more_message
canned_msg(MSG_SOMETHING_APPEARS);