From 1dde04b0326769c817ada34bf735d8dd3e323896 Mon Sep 17 00:00:00 2001 From: dolorous Date: Tue, 24 Jun 2008 03:12:04 +0000 Subject: 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 --- crawl-ref/source/xom.cc | 89 +++++++++++++++++++++++++------------------------ 1 file 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) { -- cgit v1.2.3-54-g00ecf