summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/xom.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-04-19 16:06:29 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-04-19 16:06:29 +0000
commit6c343fd8e3a09865c8ee23ffeb5da6dc07379cfe (patch)
treee751b603908fa9ebffa8b9dfa5d3f57f9d9b76f5 /crawl-ref/source/xom.cc
parent90a29a297d45fe8cc7f7b553123c8adc191a46ad (diff)
downloadcrawl-ref-6c343fd8e3a09865c8ee23ffeb5da6dc07379cfe.tar.gz
crawl-ref-6c343fd8e3a09865c8ee23ffeb5da6dc07379cfe.zip
Enable menu colour for the 'V' item sub-menu.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9657 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/xom.cc')
-rw-r--r--crawl-ref/source/xom.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 1c0012ac01..9e0dba7e50 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -179,13 +179,17 @@ bool xom_is_nice(int tension)
: std::min((MAX_PIETY - you.piety) / 2,
random2(tension)));
+ const int effective_piety = you.piety + tension_bonus;
+ ASSERT(effective_piety >= 0 && effective_piety <= MAX_PIETY);
+
#ifdef DEBUG_XOM
mprf(MSGCH_DIAGNOSTICS,
- "Xom: tension: %d, piety: %d -> tension bonus = %d",
- tension, you.piety, tension_bonus);
+ "Xom: tension: %d, piety: %d -> tension bonus = %d, eff. piety: %d",
+ tension, you.piety, tension_bonus, effective_piety);
#endif
+
// Whether Xom is nice depends largely on his mood (== piety).
- return (x_chance_in_y(you.piety + tension_bonus, MAX_PIETY));
+ return (x_chance_in_y(effective_piety, MAX_PIETY));
}
else // CARD_XOM
return coinflip();
@@ -482,6 +486,8 @@ static bool _xom_makes_you_cast_random_spell(int sever, int tension)
else
{
const int nxomspells = ARRAYSZ(_xom_nontension_spells);
+ // spellenum will be at least 3, so we don't run into infinite loops
+ // for Detect Creatures/Magic Mapping in fully explored levels.
spellenum = std::min(nxomspells, std::max(3 + coinflip(), spellenum));
spell = _xom_nontension_spells[random2(spellenum)];
@@ -1463,12 +1469,14 @@ static bool _xom_give_mutations(bool good)
const int num_tries = random2(4) + 1;
static char mut_buf[80];
- snprintf(mut_buf, sizeof(mut_buf), "give %smutations",
+ snprintf(mut_buf, sizeof(mut_buf), "give %smutation%s",
#ifdef NOTE_DEBUG_XOM
- good ? "good " : "random ");
+ good ? "good " : "random ",
#else
- "");
+ "",
#endif
+ num_tries > 1 ? "s" : "");
+
take_note(Note(NOTE_XOM_EFFECT, you.piety, -1, mut_buf), true);
mpr("Your body is suffused with distortional energy.");
@@ -2943,7 +2951,7 @@ void xom_acts(bool niceness, int sever, int tension)
const FixedVector<unsigned char, NUM_MUTATIONS> orig_mutation
= you.mutation;
-#ifdef DEBUG_XOM
+#ifdef NOTE_DEBUG_XOM
static char xom_buf[100];
snprintf(xom_buf, sizeof(xom_buf), "xom_acts(%s, %d, %d), mood: %d",
(niceness ? "true" : "false"), sever, tension, you.piety);
@@ -2961,7 +2969,7 @@ void xom_acts(bool niceness, int sever, int tension)
{
if (was_bored && Options.note_xom_effects)
take_note(Note(NOTE_MESSAGE, 0, 0, "XOM is BORED!"), true);
-#ifdef DEBUG_XOM
+#ifdef NOTE_DEBUG_XOM
else if (niceness)
{
take_note(Note(NOTE_MESSAGE, 0, 0, "good act randomly turned bad"),
@@ -2997,9 +3005,8 @@ void xom_acts(bool niceness, int sever, int tension)
const std::string msg = "You are now " + new_xom_favour;
god_speaks(you.religion, msg.c_str());
}
-#ifdef DEBUG_XOM
- snprintf(info, INFO_SIZE, "xom_acts(): reroll piety(1/5), piety: %d",
- you.piety);
+#ifdef NOTE_DEBUG_XOM
+ snprintf(info, INFO_SIZE, "reroll piety: %d", you.piety);
take_note(Note(NOTE_MESSAGE, 0, 0, info), true);
#endif
}