/
god-wrath.cc
2374 lines (2032 loc) · 68.9 KB
/
god-wrath.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 Divine retribution.
**/
#include "AppHdr.h"
#include "god-wrath.h"
#include <cmath>
#include <queue>
#include <sstream>
#include "act-iter.h"
#include "areas.h"
#include "artefact.h"
#include "attitude-change.h"
#include "cleansing-flame-source-type.h"
#include "coordit.h"
#include "corpse.h"
#include "database.h"
#include "death-curse.h"
#include "decks.h"
#include "env.h"
#include "ghost.h"
#include "god-abil.h"
#include "god-passive.h" // shadow_monster
#include "item-prop.h"
#include "item-status-flag-type.h"
#include "items.h"
#include "losglobal.h"
#include "makeitem.h"
#include "message.h"
#include "misc.h"
#include "mon-behv.h"
#include "mon-cast.h"
#include "mon-pick.h"
#include "mon-place.h"
#include "mon-tentacle.h"
#include "mutation.h"
#include "notes.h"
#include "player-stats.h"
#include "random.h"
#include "religion.h"
#include "shopping.h"
#include "shout.h"
#include "spl-clouds.h"
#include "spl-goditem.h"
#include "spl-selfench.h"
#include "spl-summoning.h"
#include "spl-transloc.h"
#include "spl-util.h"
#include "state.h"
#include "stringutil.h"
#include "tag-version.h"
#include "terrain.h"
#include "traps.h" // is_valid_shaft_level
#include "transform.h"
#include "view.h"
#include "xom.h"
static void _god_smites_you(god_type god, const char *message = nullptr,
kill_method_type death_type = NUM_KILLBY);
static void _tso_blasts_cleansing_flame(const char *message = nullptr);
static const char *_god_wrath_adjectives[] =
{
"bugginess", // NO_GOD
"wrath", // Zin
"wrath", // the Shining One (unused)
"malice", // Kikubaaqudgha
"anger", // Yredelemnul
"capriciousness", // Xom
"wrath", // Vehumet
"fury", // Okawaru
"fury", // Makhleb
"will", // Sif Muna
"fiery rage", // Trog
"wrath", // Nemelex
"displeasure", // Elyvilon
"touch", // Lugonu
"wrath", // Beogh
"all-consuming vengeance", // Jiyva
"enmity", // Fedhas Madash
"meddling", // Cheibriados
"doom", // Ashenzari (unused)
"darkness", // Dithmenos
"greed", // Gozag (unused)
"adversity", // Qazlal
"disappointment", // Ru
#if TAG_MAJOR_VERSION == 34
"progress", // Pakellas
#endif
"fury", // Uskayaw
"memory", // Hepliaklqana (unused)
"rancor", // Wu Jian
"fiery vengeance", // Ignis
};
COMPILE_CHECK(ARRAYSZ(_god_wrath_adjectives) == NUM_GODS);
/**
* Return a name associated with the given god's wrath.
*
* E.g., "the darkness of Dithmenos".
* Used for cause of death messages (e.g. 'killed by a titan (summoned by the
* wrath of Okawaru)')
*
* @param god The god in question.
* @return A string name for the god's wrath.
*/
static string _god_wrath_name(god_type god)
{
const bool use_full_name = god == GOD_FEDHAS // fedhas is very formal.
|| god == GOD_WU_JIAN; // apparently.
return make_stringf("the %s of %s",
_god_wrath_adjectives[god],
god_name(god, use_full_name).c_str());
}
static mgen_data _wrath_mon_data(monster_type mtyp, god_type god)
{
mgen_data mg = mgen_data::hostile_at(mtyp, true, you.pos())
.set_summoned(nullptr, 0, 0, god)
.set_non_actor_summoner(_god_wrath_name(god));
mg.extra_flags |= (MF_NO_REWARD | MF_HARD_RESET);
return mg;
}
static bool _yred_random_zombified_hostile()
{
const bool skel = one_chance_in(4);
monster_type z_base;
do
{
// XXX: better zombie selection?
level_id place(BRANCH_DUNGEON,
min(27, you.experience_level + 5));
z_base = pick_local_zombifiable_monster(place, RANDOM_MONSTER,
you.pos());
}
while (skel && !mons_skeleton(z_base));
mgen_data temp = _wrath_mon_data(skel ? MONS_SKELETON : MONS_ZOMBIE,
GOD_YREDELEMNUL)
.set_base(z_base);
return create_monster(temp, false);
}
static const vector<pop_entry> _okawaru_servants =
{ // warriors
{ 1, 3, 3, FALL, MONS_ORC },
{ 1, 3, 3, FALL, MONS_GNOLL },
{ 2, 6, 3, PEAK, MONS_OGRE },
{ 2, 6, 2, PEAK, MONS_GNOLL_SERGEANT },
{ 3, 7, 1, FLAT, MONS_TWO_HEADED_OGRE },
{ 3, 13, 3, PEAK, MONS_ORC_WARRIOR },
{ 5, 15, 3, PEAK, MONS_ORC_KNIGHT },
{ 5, 15, 2, PEAK, MONS_CYCLOPS },
{ 7, 21, 2, PEAK, MONS_CENTAUR_WARRIOR },
{ 7, 21, 2, PEAK, MONS_NAGA_WARRIOR },
{ 7, 21, 2, PEAK, MONS_TENGU_WARRIOR },
{ 7, 21, 1, FLAT, MONS_MERFOLK_IMPALER },
{ 7, 21, 1, FLAT, MONS_MERFOLK_JAVELINEER },
{ 7, 21, 1, FLAT, MONS_MINOTAUR },
{ 9, 27, 2, FLAT, MONS_STONE_GIANT },
{ 9, 27, 1, FLAT, MONS_DEEP_ELF_KNIGHT },
{ 9, 27, 1, FLAT, MONS_DEEP_ELF_ARCHER },
{ 11, 21, 1, FLAT, MONS_ORC_WARLORD },
{ 11, 27, 2, FLAT, MONS_FIRE_GIANT },
{ 11, 27, 2, FLAT, MONS_FROST_GIANT },
{ 13, 27, 1, FLAT, MONS_DEEP_ELF_BLADEMASTER },
{ 13, 27, 1, FLAT, MONS_DEEP_ELF_MASTER_ARCHER },
{ 13, 27, 1, FLAT, RANDOM_BASE_DRACONIAN },
{ 15, 27, 2, FLAT, MONS_TITAN },
};
static bool _okawaru_random_servant()
{
monster_type mon_type = pick_monster_from(_okawaru_servants,
you.experience_level);
mgen_data temp = _wrath_mon_data(mon_type, GOD_OKAWARU);
// Don't send dream sheep into battle, but otherwise let bands in.
// This makes sure you get multiple orcs/gnolls early on.
if (mon_type != MONS_CYCLOPS)
temp.flags |= MG_PERMIT_BANDS;
return create_monster(temp, false);
}
static bool _dithmenos_random_shadow(const int count, const int tier)
{
monster_type mon_type = MONS_SHADOW;
if (tier >= 2 && count == 0 && coinflip())
mon_type = MONS_TZITZIMITL;
else if (tier >= 1 && count < 3 && coinflip())
mon_type = MONS_SHADOW_DEMON;
return create_monster(_wrath_mon_data(mon_type, GOD_DITHMENOS), false);
}
/**
* Summon divine warriors of the Shining One to punish the player.
*/
static void _tso_summon_warriors()
{
bool success = false;
int how_many = 1 + random2(you.experience_level / 5) + random2(3);
for (; how_many > 0; --how_many)
{
if (summon_holy_warrior(100, true))
success = true;
}
simple_god_message(success ? " sends the divine host to punish "
"you for your evil ways!"
: "'s divine host fails to appear.", GOD_SHINING_ONE);
}
/**
* The Shining One shouts angrily to alert the player's foes!
*/
static void _tso_shouts()
{
simple_god_message(" booms out: "
"\"Take the path of righteousness! REPENT!\"",
GOD_SHINING_ONE);
noisy(25, you.pos()); // same as scroll of noise
}
/**
* The Shining One silences the player!!
*/
static void _tso_squelches()
{
god_speaks(GOD_SHINING_ONE,
"You feel the Shining One's silent rage upon you!");
cast_silence(25);
}
/**
* Call down the wrath of the Shining One upon the player!
*
* Holy warriors/cleansing theme.
*
* @return Whether to take further divine wrath actions afterward.
*/
static bool _tso_retribution()
{
switch (random2(7))
{
case 0:
case 1:
case 2:
_tso_summon_warriors();
break;
case 3:
case 4:
_tso_blasts_cleansing_flame();
break;
case 5:
_tso_shouts();
break;
case 6:
_tso_squelches();
break;
}
return true;
}
static bool _zin_remove_good_mutations()
{
if (!you.how_mutated())
return true; // This was checked in _zin_retribution().
const god_type god = GOD_ZIN;
bool success = false;
simple_god_message(" draws some chaos from your body!", god);
bool failMsg = true;
int how_many = binomial(7, 75, 100); // same avg, var as old bernoullis
for (int i = how_many; i >= 0; --i)
{
// Ensure that only good mutations are removed.
if (delete_mutation(RANDOM_GOOD_MUTATION, _god_wrath_name(god),
failMsg, false, true))
{
success = true;
}
else
failMsg = false;
}
if (success && !you.how_mutated())
simple_god_message(" rids your body of chaos!", god);
return success;
}
static bool _zin_retribution()
{
// preaching/creeping doom theme
const god_type god = GOD_ZIN;
// If not mutated, do something else instead.
const int punishment = you.how_mutated() ? random2(6) : random2(4) + 2;
switch (punishment)
{
case 0:
case 1: // remove good mutations or deliberately fall through
if (_zin_remove_good_mutations())
break;
case 2:
case 3:
case 4: // recital
simple_god_message(" recites the Axioms of Law to you!", god);
switch (random2(3))
{
case 0:
confuse_player(5 + random2(3));
break;
case 1:
you.put_to_sleep(nullptr, 30 + random2(20));
break;
case 2:
paralyse_player(_god_wrath_name(god));
return false;
}
break;
case 5: // noisiness
simple_god_message(" booms out: \"Turn to the light! REPENT!\"", god);
noisy(25, you.pos()); // same as scroll of noise
break;
}
return true;
}
static bool _cheibriados_retribution()
{
// time god/slowness theme
const god_type god = GOD_CHEIBRIADOS;
// Chei retribution might only make sense in combat.
// We can crib some Xom code for this. {bh}
int tension = get_tension(GOD_CHEIBRIADOS);
int wrath_value = random2(tension);
// Determine the level of wrath
int wrath_type = 0;
if (wrath_value < 2)
wrath_type = 0;
else if (wrath_value < 4)
wrath_type = 1;
else if (wrath_value < 8)
wrath_type = 2;
else if (wrath_value < 16)
wrath_type = 3;
else
wrath_type = 4;
// Strip away extra speed
dec_haste_player(10000);
switch (wrath_type)
{
// Very high tension wrath.
// Add noise then start sleeping and slow the player with 2/3 chance.
case 4:
simple_god_message(" strikes the hour.", god);
noisy(40, you.pos());
dec_penance(god, 1); // and fall-through.
// High tension wrath
// Sleep the player and slow the player with 50% chance.
case 3:
mpr("You lose track of time.");
you.put_to_sleep(nullptr, 30 + random2(20));
if (one_chance_in(wrath_type - 1))
break;
else
dec_penance(god, 1); // and fall-through.
// Medium tension
case 2:
mprf(MSGCH_WARN, "You feel the world leave you behind!");
slow_player(91 + random2(10));
break;
// Low/no tension; lose stats.
case 1:
case 0:
mpr("Time shudders.");
lose_stat(STAT_RANDOM, 1 + random2avg(5, 2));
break;
default:
break;
}
return true;
}
static void _banish_foes_nearby()
{
vector<monster*> potential_banishees;
for (monster_near_iterator mi(you.pos(), LOS_NO_TRANS); mi; ++mi)
{
monster *mon = *mi;
if (!mon
|| mon->attitude != ATT_HOSTILE
|| mons_is_conjured(mon->type)
|| mons_is_firewood(*mon))
{
continue;
}
potential_banishees.push_back(mon);
}
if (potential_banishees.empty())
return;
simple_god_message(" does not welcome meddling.");
const int to_banish = roll_dice(2, 3);
shuffle_array(begin(potential_banishees), end(potential_banishees));
for (int i = 0; i < to_banish && i < (int)potential_banishees.size(); ++i)
potential_banishees[i]->banish(&you);
}
static void _spell_retribution(monster* avatar, spell_type spell, god_type god,
const char* message = nullptr)
{
simple_god_message(message ? message : " rains destruction down upon you!",
god);
bolt beam;
beam.source = you.pos();
beam.target = you.pos();
beam.aimed_at_feet = true;
beam.source_name = avatar->mname;
mons_cast(avatar, beam, spell, MON_SPELL_PRIEST, false);
}
/**
* Choose a type of destruction with which to punish the player.
*
* @return A spell type to hurl at the player.
*/
static spell_type _makhleb_destruction_type()
{
const int severity = min(random_range(you.experience_level / 14,
you.experience_level / 9),
2);
switch (severity)
{
case 0:
default:
// minor destruction
return random_choose(SPELL_THROW_FLAME,
SPELL_PAIN,
SPELL_STONE_ARROW,
SPELL_SHOCK,
SPELL_SPIT_ACID);
case 1:
// major destruction
return random_choose(SPELL_BOLT_OF_FIRE,
SPELL_FIREBALL,
SPELL_LIGHTNING_BOLT,
SPELL_STICKY_FLAME,
SPELL_IRON_SHOT,
SPELL_BOLT_OF_DRAINING,
SPELL_ORB_OF_ELECTRICITY);
case 2:
// legendary destruction (no IOOD because it doesn't really
// work here)
return random_choose(SPELL_FIREBALL,
SPELL_LEHUDIBS_CRYSTAL_SPEAR,
SPELL_ORB_OF_ELECTRICITY,
SPELL_FLASH_FREEZE,
SPELL_GHOSTLY_FIREBALL);
}
}
/**
* Create a fake 'avatar' monster representing a god, with which to hurl
* destructive magic at foolish players.
*
* @param god The god doing the wrath-hurling.
* @return An avatar monster, or nullptr if none could be set up.
*/
static monster* get_avatar(god_type god)
{
// TODO: it would be better to abstract the fake monster code from both
// this and shadow monster and possibly use different monster types --
// doing it this way makes it easier for bugs where the two are conflated
// to creep in
monster* avatar = shadow_monster(false);
if (!avatar)
return nullptr;
// shadow_monster() has the player's mid, which is no good here.
avatar->set_new_monster_id();
avatar->mname = _god_wrath_name(god);
avatar->flags |= MF_NAME_REPLACE;
avatar->attitude = ATT_HOSTILE;
avatar->set_hit_dice(you.experience_level);
return avatar;
}
/// Cleanup a temporary 'avatar' monster.
static void _reset_avatar(monster &avatar)
{
env.mid_cache.erase(avatar.mid);
shadow_monster_reset(&avatar);
}
/**
* Rain down Makhleb's destruction upon the player!
*
* @return Whether to take further divine wrath actions afterward.
*/
static bool _makhleb_call_down_destruction()
{
const god_type god = GOD_MAKHLEB;
monster* avatar = get_avatar(god);
// can't be const because mons_cast() doesn't accept const monster*
if (avatar == nullptr)
{
simple_god_message(" has no time to deal with you just now.", god);
return false; // not a very dazzling divine experience...
}
_spell_retribution(avatar, _makhleb_destruction_type(), god);
_reset_avatar(*avatar);
return true;
}
/**
* Figure out how many greater servants (2s) an instance of Makhleb's wrath
* should summon.
*
* @return The number of greater servants to be summoned by Makhleb's wrath.
*/
static int _makhleb_num_greater_servants()
{
const int severity = 1 + you.experience_level / 2
+ random2(you.experience_level / 2);
if (severity > 13)
return 2 + random2((you.experience_level - 2) / 5); // up to 6 at XL27
else if (severity > 7 && !one_chance_in(5))
return 1;
return 0;
}
/**
* Attempt to summon one of Makhleb's diabolical servants to punish the player.
*
* @param servant The type of servant to be summoned.
* @return Whether the summoning was successful.
*/
static bool _makhleb_summon_servant(monster_type servant)
{
return create_monster(_wrath_mon_data(servant, GOD_MAKHLEB), false);
}
/**
* Unleash Makhleb's fiendish minions on the player!
*
* @return Whether to take further divine wrath actions afterward. (true.)
*/
static bool _makhleb_summon_servants()
{
const int greater_servants = _makhleb_num_greater_servants();
// up to 6 at XL25+
const int total_servants = max(greater_servants,
1 + (random2(you.experience_level)
+ random2(you.experience_level)) / 10);
const int lesser_servants = total_servants - greater_servants;
int summoned = 0;
for (int i = 0; i < greater_servants; i++)
{
const monster_type servant = random_choose(MONS_EXECUTIONER,
MONS_GREEN_DEATH,
MONS_BLIZZARD_DEMON,
MONS_BALRUG,
MONS_CACODEMON);
if (_makhleb_summon_servant(servant))
summoned++;
}
for (int i = 0; i < lesser_servants; i++)
{
const monster_type servant = random_choose(MONS_HELLWING,
MONS_NEQOXEC,
MONS_ORANGE_DEMON,
MONS_SMOKE_DEMON,
MONS_YNOXINUL);
if (_makhleb_summon_servant(servant))
summoned++;
}
simple_god_message(summoned > 1 ? " sends minions to punish you." :
summoned > 0 ? " sends a minion to punish you."
: "'s minions fail to arrive.", GOD_MAKHLEB);
return true;
}
/**
* Call down the wrath of Makhleb upon the player!
*
* Demonic servant theme.
*
* @return Whether to take further divine wrath actions afterward.
*/
static bool _makhleb_retribution()
{
if (coinflip())
return _makhleb_call_down_destruction();
else
return _makhleb_summon_servants();
}
static int _count_corpses_in_los(vector<stack_iterator> *positions)
{
int count = 0;
for (radius_iterator rad(you.pos(), LOS_NO_TRANS, true); rad;
++rad)
{
if (actor_at(*rad))
continue;
for (stack_iterator stack_it(*rad); stack_it; ++stack_it)
{
if (stack_it->is_type(OBJ_CORPSES, CORPSE_BODY))
{
if (positions)
positions->push_back(stack_it);
count++;
break;
}
}
}
return count;
}
static bool _kikubaaqudgha_retribution()
{
// death/necromancy theme
const god_type god = GOD_KIKUBAAQUDGHA;
god_speaks(god, coinflip() ? "You hear Kikubaaqudgha cackling."
: "Kikubaaqudgha's malice focuses upon you.");
if (x_chance_in_y(you.experience_level, 27))
{
// torment, or 3 death curses of maximum power
if (!you.res_torment())
torment(nullptr, TORMENT_KIKUBAAQUDGHA, you.pos());
else
{
for (int i = 0; i < 3; ++i)
{
death_curse(you, nullptr,
_god_wrath_name(god), you.experience_level);
}
}
}
else if (random2(you.experience_level) >= 4)
{
// death curse, 25% chance of additional curse
const int num_curses = one_chance_in(4) ? 2 : 1;
for (int i = 0; i < num_curses; i++)
{
death_curse(you, nullptr,
_god_wrath_name(god), you.experience_level);
}
}
return true;
}
static bool _yredelemnul_retribution()
{
// undead theme
const god_type god = GOD_YREDELEMNUL;
if (coinflip())
{
if (you_worship(god) && coinflip() && yred_reclaim_souls())
;
else
{
int how_many = 1 + random2avg(1 + (you.experience_level / 5), 2);
int count = 0;
for (; how_many > 0; --how_many)
{
if (one_chance_in(you.experience_level))
{
if (_yred_random_zombified_hostile())
++count;
}
else
{
if (yred_random_servant(0, true))
++count;
else
++how_many;
}
}
simple_god_message(count > 1 ? " sends servants to punish you." :
count > 0 ? " sends a servant to punish you."
: "'s servants fail to arrive.", god);
}
}
else
{
monster* avatar = get_avatar(god);
// can't be const because mons_cast() doesn't accept const monster*
if (avatar == nullptr)
{
simple_god_message(" has no time to deal with you just now.", god);
return false;
}
_spell_retribution(avatar, SPELL_BOLT_OF_DRAINING, god,
"'s anger turns toward you for a moment.");
_reset_avatar(*avatar);
}
return true;
}
static bool _trog_retribution()
{
// physical/berserk theme
const god_type god = GOD_TROG;
if (coinflip())
{
int count = 0;
int points = 3 + you.experience_level * 3;
{
msg::suppress msg;
while (points > 0)
{
int cost =
min(min(random2avg((1 + you.experience_level / 3), 2) + 3,
10),
points);
// quick reduction for large values
if (points > 20 && coinflip())
{
points -= 10;
cost = min(1 + div_rand_round(you.experience_level, 2), 10);
}
points -= cost;
if (summon_berserker(cost * 20, 0))
count++;
}
}
simple_god_message(count > 1 ? " sends monsters to punish you." :
count > 0 ? " sends a monster to punish you."
: " has no time to punish you... now.",
god);
}
else if (!one_chance_in(3))
{
simple_god_message("'s voice booms out, \"Feel my wrath!\"", god);
// A collection of physical effects that might be better
// suited to Trog than wild fire magic... messages could
// be better here... something more along the lines of apathy
// or loss of rage to go with the anti-berserk effect-- bwr
switch (random2(6))
{
case 0:
case 1:
case 2:
lose_stat(STAT_STR, 1 + random2(you.strength() / 5));
break;
case 3:
if (!you.duration[DUR_PARALYSIS])
{
mprf(MSGCH_WARN, "You suddenly pass out!");
const int turns = 2 + random2(6);
take_note(Note(NOTE_PARALYSIS, min(turns, 13), 0, "Trog"));
you.increase_duration(DUR_PARALYSIS, turns, 13);
}
return false;
case 4:
case 5:
mprf(MSGCH_WARN, "You suddenly feel lethargic!");
slow_player(91 + random2(10));
break;
}
}
else
{
// A fireball is magic when used by a mortal but just a manifestation
// of pure rage when used by a god. --ebering
monster* avatar = get_avatar(god);
// can't be const because mons_cast() doesn't accept const monster*
if (avatar == nullptr)
{
simple_god_message(" has no time to deal with you just now.", god);
return false; // not a very dazzling divine experience...
}
_spell_retribution(avatar, SPELL_FIREBALL,
god, " hurls fiery rage upon you!");
_reset_avatar(*avatar);
}
return true;
}
static bool _beogh_retribution()
{
// orcish theme
const god_type god = GOD_BEOGH;
switch (random2(8))
{
case 0: // smiting (25%)
case 1:
_god_smites_you(god);
break;
case 2: // send out one or two dancing weapons (12.5%)
{
int num_created = 0;
int num_to_create = random_range(1, 2);
for (int i = 0; i < num_to_create; ++i)
{
const int wpn_type =
random_choose(WPN_CLUB, WPN_MACE, WPN_FLAIL,
WPN_MORNINGSTAR, WPN_DAGGER, WPN_SHORT_SWORD,
WPN_LONG_SWORD, WPN_SCIMITAR, WPN_GREAT_SWORD,
WPN_HAND_AXE, WPN_BATTLEAXE, WPN_SPEAR,
WPN_HALBERD);
// Now create monster.
if (monster *mon =
create_monster(_wrath_mon_data(MONS_DANCING_WEAPON, god)))
{
ASSERT(mon->weapon() != nullptr);
item_def& wpn(*mon->weapon());
set_item_ego_type(wpn, OBJ_WEAPONS, SPWPN_ELECTROCUTION);
wpn.plus = random2(3);
wpn.sub_type = wpn_type;
set_ident_flags(wpn, ISFLAG_KNOW_TYPE);
item_colour(wpn);
ghost_demon newstats;
newstats.init_dancing_weapon(wpn,
you.experience_level * 50 / 9);
mon->set_ghost(newstats);
mon->ghost_demon_init();
num_created++;
}
}
if (num_created > 0)
{
ostringstream msg;
msg << " throws "
<< (num_created == 1 ? "an implement" : "implements")
<< " of electrocution at you.";
simple_god_message(msg.str().c_str(), god);
break;
} // else fall through
}
case 3: // 25%, relatively harmless
case 4: // in effect, only for penance
if (you_worship(god) && beogh_followers_abandon_you())
break;
// else fall through
default: // send orcs after you (3/8 to 5/8)
{
const int points = you.experience_level + 3
+ random2(you.experience_level * 3);
monster_type punisher;
// "natural" bands
if (points >= 30) // min: lvl 7, always: lvl 27
punisher = MONS_ORC_WARLORD;
else if (points >= 24) // min: lvl 6, always: lvl 21
punisher = MONS_ORC_HIGH_PRIEST;
else if (points >= 18) // min: lvl 4, always: lvl 15
punisher = MONS_ORC_KNIGHT;
else if (points > 10) // min: lvl 3, always: lvl 8
punisher = MONS_ORC_WARRIOR;
else
punisher = MONS_ORC;
mgen_data temp = _wrath_mon_data(punisher, god);
temp.flags |= MG_PERMIT_BANDS;
monster *mons = create_monster(temp, false);
// sometimes name band leader
if (mons && one_chance_in(3))
give_monster_proper_name(*mons);
simple_god_message(
mons ? " sends forth an army of orcs."
: " is still gathering forces against you.", god);
}
}
return true;
}
static bool _okawaru_retribution()
{
// warrior theme
const god_type god = GOD_OKAWARU;
int how_many = 1 + (you.experience_level / 5);
int count = 0;
for (; how_many > 0; --how_many)
count += _okawaru_random_servant();
simple_god_message(count > 0 ? " sends forces against you!"
: "'s forces are busy with other wars.", god);
return true;
}
static bool _sif_muna_retribution()
{
// magic/intelligence theme
const god_type god = GOD_SIF_MUNA;
simple_god_message("'s wrath finds you.", god);
switch (random2(10))
{
case 0:
case 1:
case 2:
lose_stat(STAT_INT, 1 + random2(you.intel() / 5));
break;
case 3:
case 4:
case 5:
confuse_player(5 + random2(3));
break;
case 6:
case 7:
case 8:
if (you.magic_points > 0)
{
drain_mp(you.magic_points);
canned_msg(MSG_MAGIC_DRAIN);
}
break;
case 9:
// This will set all the extendable duration spells to
// a duration of one round, thus potentially exposing
// the player to real danger.