-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
describe-god.cc
1292 lines (1107 loc) · 42.5 KB
/
describe-god.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 used to print information about gods.
**/
#include "AppHdr.h"
#include "describe-god.h"
#include <iomanip>
#include "ability.h"
#include "branch.h"
#include "cio.h"
#include "database.h"
#include "describe.h"
#include "english.h"
#include "eq-type-flags.h"
#include "food.h"
#include "god-abil.h"
#include "god-conduct.h"
#include "god-passive.h"
#include "god-prayer.h"
#include "god-type.h"
#include "libutil.h"
#include "macro.h"
#include "menu.h"
#include "message.h"
#include "religion.h"
#include "scroller.h"
#include "skills.h"
#include "spl-util.h"
#include "stringutil.h"
#include "terrain.h"
#include "tilepick.h"
#include "unicode.h"
#include "xom.h"
using namespace ui;
static int _piety_level(int piety)
{
return (piety >= piety_breakpoint(5)) ? 7 :
(piety >= piety_breakpoint(4)) ? 6 :
(piety >= piety_breakpoint(3)) ? 5 :
(piety >= piety_breakpoint(2)) ? 4 :
(piety >= piety_breakpoint(1)) ? 3 :
(piety >= piety_breakpoint(0)) ? 2 :
(piety > 0) ? 1
: 0;
}
static int _gold_level()
{
return (you.gold >= 50000) ? 7 :
(you.gold >= 10000) ? 6 :
(you.gold >= 5000) ? 5 :
(you.gold >= 1000) ? 4 :
(you.gold >= 500) ? 3 :
(you.gold >= 100) ? 2
: 1;
}
static int _invocations_level()
{
int invo = you.skills[SK_INVOCATIONS];
return (invo == 27) ? 7 :
(invo >= 24) ? 6 :
(invo >= 20) ? 5 :
(invo >= 16) ? 4 :
(invo >= 12) ? 3 :
(invo >= 8) ? 2
: 1;
}
int god_favour_rank(god_type which_god)
{
if (which_god == GOD_GOZAG)
return _gold_level();
else if (which_god == GOD_USKAYAW)
return _invocations_level();
else
return _piety_level(you.piety);
}
static string _describe_favour(god_type which_god)
{
if (player_under_penance())
{
const int penance = you.penance[which_god];
return (penance >= 50) ? "Godly wrath is upon you!" :
(penance >= 20) ? "You've transgressed heavily! Be penitent!" :
(penance >= 5) ? "You are under penance."
: "You should show more discipline.";
}
if (which_god == GOD_XOM)
return uppercase_first(describe_xom_favour());
const string godname = god_name(which_god);
switch (god_favour_rank(which_god))
{
case 7: return "A prized avatar of " + godname;
case 6: return "A favoured servant of " + godname + ".";
case 5:
if (you_worship(GOD_DITHMENOS))
return "A glorious shadow in the eyes of " + godname + ".";
else
return "A shining star in the eyes of " + godname + ".";
case 4:
if (you_worship(GOD_DITHMENOS))
return "A rising shadow in the eyes of " + godname + ".";
else
return "A rising star in the eyes of " + godname + ".";
case 3: return uppercase_first(godname) + " is pleased with you.";
case 2: return uppercase_first(godname) + " is aware of your devotion.";
default: return uppercase_first(godname) + " is noncommittal.";
}
}
// The various titles granted by the god of your choice. Note that Xom
// doesn't use piety the same way as the other gods, so these are just
// placeholders.
static const char *divine_title[][8] =
{
// No god.
{"Buglet", "Firebug", "Bogeybug", "Bugger",
"Bugbear", "Bugged One", "Giant Bug", "Lord of the Bugs"},
// Zin.
{"Blasphemer", "Anchorite", "Apologist", "Pious",
"Devout", "Orthodox", "Immaculate", "Bringer of Law"},
// The Shining One.
{"Honourless", "Acolyte", "Righteous", "Unflinching",
"Holy Warrior", "Exorcist", "Demon Slayer", "Bringer of Light"},
// Kikubaaqudgha -- scholarly death.
{"Tormented", "Purveyor of Pain", "Scholar of Death", "Merchant of Misery",
"Artisan of Death", "Dealer of Despair", "Black Sun", "Lord of Darkness"},
// Yredelemnul -- zombie death.
{"Traitor", "Tainted", "Torchbearer", "Fey @Genus@",
"Black Crusader", "Sculptor of Flesh", "Harbinger of Death", "Grim Reaper"},
// Xom.
{"Toy", "Toy", "Toy", "Toy",
"Toy", "Toy", "Toy", "Toy"},
// Vehumet -- battle mage theme.
{"Meek", "Sorcerer's Apprentice", "Scholar of Destruction", "Caster of Ruination",
"Traumaturge", "Battlemage", "Warlock", "Luminary of Lethal Lore"},
// Okawaru -- battle theme.
{"Coward", "Struggler", "Combatant", "Warrior",
"Knight", "Warmonger", "Commander", "Victor of a Thousand Battles"},
// Makhleb -- chaos theme.
{"Orderly", "Spawn of Chaos", "Disciple of Destruction", "Fanfare of Bloodshed",
"Fiendish", "Demolition @Genus@", "Pandemonic", "Champion of Chaos"},
// Sif Muna -- scholarly theme.
{"Ignorant", "Disciple", "Student", "Adept",
"Scribe", "Scholar", "Sage", "Genius of the Arcane"},
// Trog -- anger theme.
{"Puny", "Troglodyte", "Angry Troglodyte", "Frenzied",
"@Genus@ of Prey", "Rampant", "Wild @Genus@", "Bane of Scribes"},
// Nemelex Xobeh -- alluding to Tarot and cards.
{"Unlucky @Genus@", "Pannier", "Jester", "Fortune-Teller",
"Soothsayer", "Magus", "Cardsharp", "Hand of Fortune"},
// Elyvilon.
{"Sinner", "Practitioner", "Comforter", "Caregiver",
"Mender", "Pacifist", "Purifying @Genus@", "Bringer of Life"},
// Lugonu -- distortion theme.
{"Pure", "Abyss-Baptised", "Unweaver", "Distorting @Genus@",
"Agent of Entropy", "Schismatic", "Envoy of Void", "Corrupter of Planes"},
// Beogh -- messiah theme.
{"Apostate", "Messenger", "Proselytiser", "Priest",
"Missionary", "Evangelist", "Apostle", "Messiah"},
// Jiyva -- slime and jelly theme.
{"Scum", "Squelcher", "Ooze", "Jelly",
"Slime Creature", "Dissolving @Genus@", "Blob", "Royal Jelly"},
// Fedhas Madash -- nature theme.
{"@Walking@ Fertiliser", "Fungal", "Green @Genus@", "Cultivator",
"Fruitful", "Photosynthesist", "Green Death", "Force of Nature"},
// Cheibriados -- slow theme
{"Hasty", "Sluggish @Genus@", "Deliberate", "Unhurried",
"Contemplative", "Epochal", "Timeless", "@Adj@ Aeon"},
// Ashenzari -- divination theme
{"Star-crossed", "Cursed", "Initiated", "Soothsayer",
"Seer", "Oracle", "Illuminatus", "Omniscient"},
// Dithmenos -- darkness theme
{"Ember", "Gloomy", "Darkened", "Extinguished",
"Caliginous", "Umbral", "Hand of Shadow", "Eternal Night"},
// Gozag -- entrepreneur theme
{"Profligate", "Pauper", "Entrepreneur", "Capitalist",
"Rich", "Opulent", "Tycoon", "Plutocrat"},
// Qazlal -- natural disaster theme
{"Unspoiled", "@Adj@ Mishap", "Lightning Rod", "@Adj@ Disaster",
"Eye of the Storm", "@Adj@ Catastrophe", "@Adj@ Cataclysm", "End of an Era"},
// Ru -- enlightenment theme
{"Sleeper", "Questioner", "Initiate", "Seeker of Truth",
"@Walker@ of the Path","Lifter of the Veil", "Transcendent", "Drop of Water"},
// Pakellas -- inventor theme
{"Reactionary", "Apprentice", "Inquisitive", "Experimenter",
"Inventor", "Pioneer", "Brilliant", "Grand Gadgeteer"},
// Uskayaw -- reveler theme
{"Prude", "Wallflower", "Party-goer", "Dancer",
"Impassioned", "Rapturous", "Ecstatic", "Rhythm of Life and Death"},
// Hepliaklqana -- memory/ancestry theme
{"Damnatio Memoriae", "Hazy", "@Adj@ Child", "Storyteller",
"Brooding", "Anamnesiscian", "Grand Scion", "Unforgettable"},
// Wu Jian -- animal/chinese martial arts monk theme
{"Wooden Rat", "Young Dog", "Young Crane", "Young Tiger",
"Young Dragon", "Red Sash", "Golden Sash", "Sifu"},
};
COMPILE_CHECK(ARRAYSZ(divine_title) == NUM_GODS);
string god_title(god_type which_god, species_type which_species, int piety)
{
string title;
if (player_under_penance(which_god))
title = divine_title[which_god][0];
else if (which_god == GOD_USKAYAW)
title = divine_title[which_god][_invocations_level()];
else if (which_god == GOD_GOZAG)
title = divine_title[which_god][_gold_level()];
else
title = divine_title[which_god][_piety_level(piety)];
const map<string, string> replacements =
{
{ "Adj", species_name(which_species, SPNAME_ADJ) },
{ "Genus", species_name(which_species, SPNAME_GENUS) },
{ "Walking", species_walking_verb(which_species) + "ing" },
{ "Walker", species_walking_verb(which_species) + "er" },
};
return replace_keys(title, replacements);
}
static string _describe_ash_skill_boost()
{
if (!you.bondage_level)
{
return "Ashenzari won't support your skills until you bind yourself "
"with cursed items.";
}
static const char* bondage_parts[NUM_ET] = { "Weapon hand", "Shield hand",
"Armour", "Jewellery" };
static const char* bonus_level[3] = { "Low", "Medium", "High" };
ostringstream desc;
desc.setf(ios::left);
desc << "<white>";
desc << setw(18) << "Bound part";
desc << setw(30) << "Boosted skills";
desc << "Bonus\n";
desc << "</white>";
for (int i = ET_WEAPON; i < NUM_ET; i++)
{
if (you.bondage[i] <= 0 || i == ET_SHIELD && you.bondage[i] == 3)
continue;
desc << setw(18);
if (i == ET_WEAPON && you.bondage[i] == 3)
desc << "Hands";
else
desc << bondage_parts[i];
string skills;
map<skill_type, int8_t> boosted_skills = ash_get_boosted_skills(eq_type(i));
const int8_t bonus = boosted_skills.begin()->second;
auto it = boosted_skills.begin();
// First, we keep only one magic school skill (conjuration).
// No need to list all of them since we boost all or none.
while (it != boosted_skills.end())
{
if (it->first > SK_CONJURATIONS && it->first <= SK_LAST_MAGIC)
{
boosted_skills.erase(it);
it = boosted_skills.begin();
}
else
++it;
}
it = boosted_skills.begin();
while (!boosted_skills.empty())
{
// For now, all the bonuses from the same bounded part have
// the same level.
ASSERT(bonus == it->second);
if (it->first == SK_CONJURATIONS)
skills += "Magic schools";
else
skills += skill_name(it->first);
if (boosted_skills.size() > 2)
skills += ", ";
else if (boosted_skills.size() == 2)
skills += " and ";
boosted_skills.erase(it++);
}
desc << setw(30) << skills;
desc << bonus_level[bonus -1] << "\n";
}
return desc.str();
}
typedef pair<int, string> ancestor_upgrade;
static const map<monster_type, vector<ancestor_upgrade> > ancestor_data =
{
{ MONS_ANCESTOR_KNIGHT,
{ { 1, "Flail" },
{ 1, "Shield" },
{ 1, "Chain mail (+AC)" },
{ 15, "Broad axe (flame)" },
{ 19, "Large shield (reflect)" },
{ 19, "Haste" },
{ 24, "Broad axe (speed)" },
}
},
{ MONS_ANCESTOR_BATTLEMAGE,
{ { 1, "Quarterstaff" },
{ 1, "Throw Frost" },
{ 1, "Stone Arrow" },
{ 1, "Increased melee damage" },
{ 15, "Bolt of Magma" },
{ 19, "Lajatang (freeze)" },
{ 19, "Haste" },
{ 24, "Lehudib's Crystal Spear" },
}
},
{ MONS_ANCESTOR_HEXER,
{ { 1, "Dagger (drain)" },
{ 1, "Slow" },
{ 1, "Confuse" },
{ 15, "Paralyse" },
{ 19, "Mass Confusion" },
{ 19, "Haste" },
{ 24, "Quick blade (antimagic)" },
}
},
};
/// Build & return a table of Hep's upgrades for your chosen ancestor type.
static string _describe_ancestor_upgrades()
{
if (!you.props.exists(HEPLIAKLQANA_ALLY_TYPE_KEY))
return "";
string desc;
const monster_type ancestor =
static_cast<monster_type>(you.props[HEPLIAKLQANA_ALLY_TYPE_KEY].get_int());
const vector<ancestor_upgrade> *upgrades = map_find(ancestor_data,
ancestor);
if (upgrades)
{
desc = "<white>XL Upgrade\n</white>";
for (auto &entry : *upgrades)
{
desc += make_stringf("%s%2d %s%s\n",
you.experience_level < entry.first
? "<darkgrey>" : "",
entry.first,
entry.second.c_str(),
you.experience_level < entry.first
? "</darkgrey>" : "");
}
}
// XXX: maybe it'd be nice to let you see other ancestor types'...?
return desc;
}
// from dgn-overview.cc
extern map<branch_type, set<level_id> > stair_level;
/**
* Populate a provided vector with a list of bribable branches which are known
* to the player.
*
* @param[out] targets A list of bribable branches.
*/
static void _list_bribable_branches(vector<branch_type> &targets)
{
for (branch_iterator it; it; ++it)
{
const branch_type br = it->id;
if (!gozag_branch_bribable(br))
continue;
// Only list the Hells once.
if (is_hell_subbranch(br))
continue;
// If you don't know the branch exists, don't list it;
// this mainly plugs info leaks about Lair branch structure.
if (!stair_level.count(br) && is_random_subbranch(br))
continue;
targets.push_back(br);
}
}
/**
* Describe the current options for Gozag's bribe branch ability.
*
* @return A description of branches' bribe status.
*/
static string _describe_branch_bribability()
{
string ret = "You can bribe the following branches of the dungeon:\n";
vector<branch_type> targets;
_list_bribable_branches(targets);
size_t width = 0;
for (branch_type br : targets)
width = max(width, strlen(branches[br].shortname));
for (branch_type br : targets)
{
string line = " ";
line += branches[br].shortname;
line += string(width + 3 - strwidth(line), ' ');
if (!branch_bribe[br])
line += "not bribed";
else
line += make_stringf("$%d", branch_bribe[br]);
ret += line + "\n";
}
return ret;
}
static inline void _add_par(formatted_string &desc, const string &str)
{
if (!str.empty())
desc += formatted_string::parse_string(trimmed_string(str) + "\n\n");
}
/**
* Describe the causes of the given god's wrath.
*
* @param which_god The god in question.
* @return A description of the actions that cause this god's
* wrath.
*/
static string _describe_god_wrath_causes(god_type which_god)
{
if (which_god == GOD_RU)
return ""; // no wrath
vector<god_type> evil_gods;
vector<god_type> chaotic_gods;
for (god_iterator it; it; ++it)
{
const god_type god = *it;
if (is_evil_god(god))
evil_gods.push_back(god);
else if (is_chaotic_god(god)) // intentionally not including evil!
chaotic_gods.push_back(god);
// XXX: refactor this if any god hates chaotic but not evil gods
}
switch (which_god)
{
case GOD_SHINING_ONE:
case GOD_ELYVILON:
return uppercase_first(god_name(which_god)) +
" forgives followers for abandonment; however, those who"
" later take up the worship of an evil god will be"
" punished. (" +
comma_separated_fn(begin(evil_gods), end(evil_gods),
bind(god_name, placeholders::_1, false)) +
" are evil gods.)";
case GOD_ZIN:
return uppercase_first(god_name(which_god)) +
" forgives followers for abandonment; however, those who"
" later take up the worship of an evil or chaotic god will"
" be scourged. (" +
comma_separated_fn(begin(evil_gods), end(evil_gods),
bind(god_name, placeholders::_1, false)) +
" are evil, and " +
comma_separated_fn(begin(chaotic_gods), end(chaotic_gods),
bind(god_name, placeholders::_1, false)) +
" are chaotic.)";
default:
return uppercase_first(god_name(which_god)) +
" does not appreciate abandonment, and will call down"
" fearful punishments on disloyal followers!";
}
}
/**
* Print a description of the given god's dislikes & wrath effects.
*
* @param which_god The god in question.
*/
static formatted_string _god_wrath_description(god_type which_god)
{
formatted_string desc;
_add_par(desc, get_god_dislikes(which_god));
_add_par(desc, _describe_god_wrath_causes(which_god));
_add_par(desc, getLongDescription(god_name(which_god) + " wrath"));
if (which_god != GOD_RU) // Permanent wrath.
{
const bool long_wrath = initial_wrath_penance_for(which_god) > 30;
_add_par(desc, apostrophise(uppercase_first(god_name(which_god)))
+ " wrath lasts for a relatively " +
(long_wrath ? "long" : "short") + " duration.");
}
return desc;
}
/**
* Describe miscellaneous information about the given god.
*
* @param which_god The god in question.
* @return Info about gods which isn't covered by their powers,
* likes, or dislikes.
*/
static string _get_god_misc_info(god_type which_god)
{
string info = "";
skill_type skill = invo_skill(which_god);
switch (skill)
{
case SK_INVOCATIONS:
break;
case SK_NONE:
if (which_god == GOD_GOZAG || which_god == GOD_WU_JIAN)
break; // XXX: no space for details
info += uppercase_first(apostrophise(god_name(which_god))) +
" powers are based on piety instead of Invocations skill.";
break;
default:
info += uppercase_first(apostrophise(god_name(which_god))) +
" powers are based on " + skill_name(skill) + " instead"
" of Invocations skill.";
break;
}
if (!info.empty())
info += "\n\n";
return info;
}
static string _get_god_specific_table(god_type which_god)
{
switch (which_god)
{
case GOD_ASHENZARI:
if (have_passive(passive_t::bondage_skill_boost))
return _describe_ash_skill_boost();
return "";
case GOD_GOZAG:
return _describe_branch_bribability();
case GOD_HEPLIAKLQANA:
return _describe_ancestor_upgrades();
default:
return "";
}
}
/**
* Print a detailed description of the given god's likes and powers.
*
* @param god The god in question.
*/
static formatted_string _detailed_god_description(god_type which_god, bool for_web = false)
{
formatted_string desc;
_add_par(desc, getLongDescription(god_name(which_god) + " powers"));
_add_par(desc, get_god_likes(which_god));
_add_par(desc, _get_god_misc_info(which_god));
if (!for_web)
_add_par(desc, _get_god_specific_table(which_god));
return desc;
}
/**
* Describe the given god's level of irritation at the player.
*
* Player may or may not be currently under penance.
*
* @param which_god The god in question.
* @return A format string, describing the god's ire (or lack of).
*/
static string _raw_penance_message(god_type which_god)
{
const int penance = you.penance[which_god];
// Give more appropriate message for the good gods.
if (penance > 0 && is_good_god(which_god))
{
if (is_good_god(you.religion))
return "%s is ambivalent towards you.";
if (!god_hates_your_god(which_god))
{
return "%s is almost ready to forgive your sins.";
// == "Come back to the one true church!"
}
}
const int initial_penance = initial_wrath_penance_for(which_god);
// could do some math tricks to turn this into a table, but it seems fiddly
if (penance > initial_penance * 3 / 4)
return "%s's wrath is upon you!";
if (penance > initial_penance / 2)
return "%s well remembers your sins.";
if (penance > initial_penance / 4)
return "%s's wrath is beginning to fade.";
if (penance > 0)
return "%s is almost ready to forgive your sins.";
return "%s is neutral towards you.";
}
/**
* Describe the given god's level of irritation at the player.
*
* Player may or may not be currently under penance.
*
* @param which_god The god in question.
* @return A description of the god's ire (or lack thereof).
*/
static string _god_penance_message(god_type which_god)
{
const string message = _raw_penance_message(which_god);
return make_stringf(message.c_str(),
uppercase_first(god_name(which_god)).c_str());
}
/**
* Print a description of the powers & abilities granted to the player by the
* given god. If player worships the god, the currently available powers are
* highlighted.
*
* @param which_god The god in question.
*/
static formatted_string _describe_god_powers(god_type which_god)
{
formatted_string desc;
int piety = you_worship(which_god) ? you.piety : 0;
desc.textcolour(LIGHTGREY);
const char *header = "Granted powers:";
const char *cost = "(Cost)";
desc.cprintf("\n\n%s%*s%s\n", header,
80 - strwidth(header) - strwidth(cost),
"", cost);
bool have_any = false;
// set default color here, so we don't have to set in multiple places for
// always available passive abilities
if (!you_worship(which_god))
desc.textcolour(DARKGREY);
else
desc.textcolour(god_colour(which_god));
// mv: Some gods can protect you from harm.
// The god isn't really protecting the player - only sometimes saving
// his life.
if (have_passive(passive_t::protect_from_harm))
{
have_any = true;
int prot_chance = 10 + piety/10; // chance * 100
const char *when = "";
if (which_god == GOD_ELYVILON)
{
switch (elyvilon_lifesaving())
{
case lifesaving_chance::sometimes:
when = ", especially when called upon";
prot_chance += 100 - 3000/piety;
break;
case lifesaving_chance::always:
when = ", and always does so when called upon";
prot_chance = 100;
break;
default:
break;
}
}
const char *how = (prot_chance >= 85) ? "carefully" :
(prot_chance >= 55) ? "often" :
(prot_chance >= 25) ? "sometimes"
: "occasionally";
desc.cprintf("%s %s watches over you%s.\n",
uppercase_first(god_name(which_god)).c_str(),
how,
when);
}
switch (which_god)
{
case GOD_ZIN:
{
have_any = true;
const char *how =
(piety >= piety_breakpoint(5)) ? "always" :
(piety >= piety_breakpoint(3)) ? "often" :
(piety >= piety_breakpoint(1)) ? "sometimes" :
"occasionally";
desc.cprintf("%s %s shields you from chaos.\n",
uppercase_first(god_name(which_god)).c_str(), how);
break;
}
case GOD_SHINING_ONE:
{
have_any = true;
desc.cprintf("%s prevents you from stabbing unaware foes.\n",
uppercase_first(god_name(which_god)).c_str());
if (piety < piety_breakpoint(1))
desc.textcolour(DARKGREY);
else
desc.textcolour(god_colour(which_god));
const char *how =
(piety >= piety_breakpoint(5)) ? "completely" :
(piety >= piety_breakpoint(3)) ? "mostly" :
"partially";
desc.cprintf("%s %s shields you from negative energy.\n",
uppercase_first(god_name(which_god)).c_str(), how);
const int halo_size = you_worship(which_god) ? you.halo_radius() : -1;
if (halo_size < 0)
desc.textcolour(DARKGREY);
else
desc.textcolour(god_colour(which_god));
desc.cprintf("You radiate a%s righteous aura, and others within it are "
"easier to hit.\n",
halo_size > 5 ? " large" :
halo_size > 3 ? "" :
" small");
break;
}
case GOD_JIYVA:
have_any = true;
if (have_passive(passive_t::resist_corrosion))
desc.textcolour(god_colour(which_god));
else
desc.textcolour(DARKGREY);
desc.cprintf("%s shields you from corrosive effects.\n",
uppercase_first(god_name(which_god)).c_str());
if (have_passive(passive_t::slime_feed))
desc.textcolour(god_colour(which_god));
else
desc.textcolour(DARKGREY);
desc.cprintf("You gain nutrition%s when your fellow slimes consume items.\n",
have_passive(passive_t::slime_hp) ? ", magic and health" :
have_passive(passive_t::slime_mp) ? " and magic" :
"");
break;
case GOD_FEDHAS:
have_any = true;
desc.cprintf("You can walk through plants and fire through allied plants.\n");
break;
case GOD_ASHENZARI:
have_any = true;
desc.cprintf("You are provided with a bounty of information.\n");
break;
case GOD_CHEIBRIADOS:
have_any = true;
if (have_passive(passive_t::stat_boost))
desc.textcolour(god_colour(which_god));
else
desc.textcolour(DARKGREY);
desc.cprintf("%s %sslows your movement.\n",
uppercase_first(god_name(which_god)).c_str(),
piety >= piety_breakpoint(5) ? "greatly " :
piety >= piety_breakpoint(2) ? "" :
"slightly ");
desc.cprintf("%s supports your attributes. (+%d)\n",
uppercase_first(god_name(which_god)).c_str(),
chei_stat_boost(piety));
break;
case GOD_VEHUMET:
have_any = true;
if (const int numoffers = you.vehumet_gifts.size())
{
const char* offer = numoffers == 1
? spell_title(*you.vehumet_gifts.begin())
: "some of Vehumet's most lethal spells";
desc.cprintf("You can memorise %s.\n", offer);
}
else
{
desc.textcolour(DARKGREY);
desc.cprintf("You can memorise some of Vehumet's spells.\n");
}
break;
case GOD_DITHMENOS:
{
have_any = true;
const int umbra_size = you_worship(which_god) ? you.umbra_radius() : -1;
if (umbra_size < 0)
desc.textcolour(DARKGREY);
else
desc.textcolour(god_colour(which_god));
desc.cprintf("You radiate a%s aura of darkness, enhancing your stealth "
"and reducing the accuracy of your foes.\n",
umbra_size > 5 ? " large" :
umbra_size > 3 ? "n" :
" small");
break;
}
case GOD_GOZAG:
have_any = true;
desc.cprintf("You passively detect gold.\n");
desc.cprintf("%s turns your defeated foes' bodies to gold.\n",
uppercase_first(god_name(which_god)).c_str());
desc.cprintf("Your enemies may become distracted by gold.\n");
break;
case GOD_HEPLIAKLQANA:
have_any = true;
desc.cprintf("Your life essence is reduced. (-10%% HP)\n");
break;
case GOD_PAKELLAS:
{
have_any = true;
desc.cprintf("%s prevents your magic from regenerating.\n",
uppercase_first(god_name(which_god)).c_str());
desc.cprintf("%s identifies device charges for you.\n",
uppercase_first(god_name(which_god)).c_str());
if (!you_foodless(false))
{
if (have_passive(passive_t::bottle_mp))
desc.textcolour(god_colour(which_god));
else
desc.textcolour(DARKGREY);
desc.cprintf("%s will collect and distill excess magic from your "
"kills.\n",
uppercase_first(god_name(which_god)).c_str());
}
break;
}
case GOD_LUGONU:
have_any = true;
cprintf("You are protected from the effects of unwielding distortion weapons.\n");
break;
default:
break;
}
for (const auto& power : get_god_powers(which_god))
{
// hack: don't mention the necronomicon alone unless it
// wasn't already mentioned by the other description
if (power.abil == ABIL_KIKU_GIFT_NECRONOMICON
&& you.species != SP_FELID)
{
continue;
}
have_any = true;
if (you_worship(which_god)
&& (power.rank <= 0
|| power.rank == 7 && can_do_capstone_ability(which_god)
|| piety_rank(piety) >= power.rank)
&& (!player_under_penance()
|| power.rank == -1))
{
desc.textcolour(god_colour(which_god));
}
else
desc.textcolour(DARKGREY);
string buf = power.gain;
if (!isupper(buf[0])) // Complete sentence given?
buf = "You can " + buf + ".";
const int desc_len = buf.size();
string abil_cost = "(" + make_cost_description(power.abil) + ")";
if (abil_cost == "(None)")
abil_cost = "";
desc.cprintf("%s%*s%s\n", buf.c_str(), 80 - desc_len - (int)abil_cost.size(),
"", abil_cost.c_str());
}
if (!have_any)
desc.cprintf("None.\n");
return desc;
}
static formatted_string _god_overview_description(god_type which_god)
{
formatted_string desc;
// Print god's description.
const string god_desc = getLongDescription(god_name(which_god));
desc += formatted_string(trimmed_string(god_desc) + "\n");
// Title only shown for our own god.
if (you_worship(which_god))
{
// Print title based on piety.
desc.cprintf("\nTitle - ");
desc.textcolour(god_colour(which_god));
string title = god_title(which_god, you.species, you.piety);
desc.cprintf("%s", title.c_str());
}
// mv: Now let's print favour as Brent suggested.
// I know these messages aren't perfect so if you can think up
// something better, do it.
desc.textcolour(LIGHTGREY);
desc.cprintf("\nFavour - ");
desc.textcolour(god_colour(which_god));
if (!you_worship(which_god))
desc.cprintf("%s", _god_penance_message(which_god).c_str());
else
{
desc.cprintf("%s", _describe_favour(which_god).c_str());
if (which_god == GOD_ASHENZARI)
desc.cprintf("\n%s", ash_describe_bondage(ETF_ALL, true).c_str());
}
desc += _describe_god_powers(which_god);
desc.cprintf("\n\n");
return desc;
}
static void build_partial_god_ui(god_type which_god, shared_ptr<ui::Popup>& popup, shared_ptr<Switcher>& desc_sw, shared_ptr<Switcher>& more_sw)
{
formatted_string topline;
topline.textcolour(god_colour(which_god));
topline += formatted_string(uppercase_first(god_name(which_god, true)));
auto vbox = make_shared<Box>(Widget::VERT);
auto title_hbox = make_shared<Box>(Widget::HORZ);
#ifdef USE_TILE
auto icon = make_shared<Image>();