summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/xom.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-24 03:12:04 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-24 03:12:04 +0000
commit1dde04b0326769c817ada34bf735d8dd3e323896 (patch)
treea84ff1b6b875afb4288f638c773355d35bc8f2c3 /crawl-ref/source/xom.cc
parent843b4276d600c3f88f9603b9d0deea9eb1152398 (diff)
downloadcrawl-ref-1dde04b0326769c817ada34bf735d8dd3e323896.tar.gz
crawl-ref-1dde04b0326769c817ada34bf735d8dd3e323896.zip
Clean up Xom's friendly multiple summoning routine again.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6098 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/xom.cc')
-rw-r--r--crawl-ref/source/xom.cc89
1 files changed, 46 insertions, 43 deletions
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 7f8b6ed449..e1155741b6 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -469,63 +469,67 @@ static bool _xom_is_good(int sever)
{
const int numdemons =
std::min(random2(random2(random2(sever+1)+1)+1)+2, 16);
-
int numdifferent = 0;
- monster_type *monster = new monster_type[numdemons];
+ // If we have a mix of demons and non-demons, there's a chance
+ // that one or both of the factions may be hostile.
+ int hostile = random2(12);
+ int hostiletype =
+ (hostile < 3) ? 0 : // 1/4: both are friendly
+ (hostile < 11) ? (coinflip() ? 1 : 2) // 2/3: one is hostile
+ : 3; // 1/12: both are hostile
+
bool *is_demonic = new bool[numdemons];
+ int *summons = new int[numdemons];
+
+ bool success = false;
for (int i = 0; i < numdemons; ++i)
{
- monster[i] = _xom_random_demon(sever);
- is_demonic[i] = (mons_class_holiness(monster[i]) == MH_DEMONIC);
+ monster_type monster = _xom_random_demon(sever);
+
+ is_demonic[i] = (mons_class_holiness(monster) == MH_DEMONIC);
// If it's not a demon, Xom got it someplace else, so use
- // different messages.
+ // different messages below.
if (!is_demonic[i])
numdifferent++;
- }
- if (numdifferent == numdemons)
- god_speaks(GOD_XOM, _get_xom_speech("multiple holy summons"));
- else if (numdifferent > 0)
- god_speaks(GOD_XOM, _get_xom_speech("multiple mixed summons"));
- else
- god_speaks(GOD_XOM, _get_xom_speech("multiple summons"));
+ summons[i] =
+ create_monster(
+ mgen_data(monster, BEH_FRIENDLY, 3,
+ you.pos(), you.pet_target, MG_FORCE_BEH, GOD_XOM));
- // If we have a mix of demons and non-demons, there's a chance
- // that one or both of the factions may be hostile.
- int hostile = random2(12);
- int hostiletype =
- (hostile < 3) ? 0 : // 1/4: both are friendly
- (hostile < 11) ? (coinflip() ? 1 : 2) // 2/3: one is hostile
- : 3; // 1/12: both are hostile
+ if (summons[i] != -1)
+ success = true;
+ }
- if (numdifferent == numdemons)
+ if (success)
{
- // If we have only demons, they'll always be friendly.
- if (numdifferent == 0)
- hostiletype = 0;
- // If we have only non-demons, there's a chance that they
- // may be hostile.
- else if (one_chance_in(4))
- hostiletype = 2;
- }
+ if (numdifferent == numdemons)
+ god_speaks(GOD_XOM, _get_xom_speech("multiple holy summons"));
+ else if (numdifferent > 0)
+ god_speaks(GOD_XOM, _get_xom_speech("multiple mixed summons"));
+ else
+ god_speaks(GOD_XOM, _get_xom_speech("multiple summons"));
- bool success = false;
+ if (numdifferent == numdemons)
+ {
+ // If we have only demons, they'll always be friendly.
+ if (numdifferent == 0)
+ hostiletype = 0;
+ // If we have only non-demons, there's a chance that
+ // they may be hostile.
+ else if (one_chance_in(4))
+ hostiletype = 2;
+ }
- for (int i = 0; i < numdemons; ++i)
- {
- if (create_monster(
- mgen_data(monster[i], BEH_FRIENDLY, 3,
- you.pos(), you.pet_target, 0, GOD_XOM)) != -1)
+ for (int i = 0; i < numdemons; ++i)
{
- success = true;
+ monsters *mon = &menv[i];
if (hostiletype != 0)
{
- monsters *mon = &menv[i];
-
// Mark factions hostile as appropriate.
if (hostiletype == 3
|| (is_demonic[i] && hostiletype == 1)
@@ -535,16 +539,15 @@ static bool _xom_is_good(int sever)
behaviour_event(mon, ME_ALERT, MHITYOU);
}
}
+
+ player_angers_monster(mon);
}
+
+ done = true;
}
delete[] is_demonic;
- delete[] monster;
-
- if (!success)
- god_speaks(GOD_XOM, "\"No, forget it.\"");
-
- done = true;
+ delete[] summons;
}
else if (random2(sever) <= 4)
{