summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-08 02:44:57 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-08 02:44:57 +0000
commitaa81a23dd84ce7019956684a2d9010ccc7804f78 (patch)
tree6bb38815f1f127f6cb453ede88afc749e7411e21
parent42834623f58aaedb7a30a9e147d5bce0570860f8 (diff)
downloadcrawl-ref-aa81a23dd84ce7019956684a2d9010ccc7804f78.tar.gz
crawl-ref-aa81a23dd84ce7019956684a2d9010ccc7804f78.zip
Consolidate the demon-summoning routines again.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5572 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/abl-show.cc13
-rw-r--r--crawl-ref/source/spells2.cc109
-rw-r--r--crawl-ref/source/spells2.h12
3 files changed, 78 insertions, 56 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 040c579c5d..0591520d59 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -1277,7 +1277,7 @@ static bool _do_ability(const ability_def& abil)
// DEMONIC POWERS:
case ABIL_SUMMON_MINOR_DEMON:
- summon_minor_demon(you.experience_level * 4);
+ summon_lesser_demon(you.experience_level * 4);
break;
case ABIL_SUMMON_DEMON:
@@ -1456,7 +1456,8 @@ static bool _do_ability(const ability_def& abil)
break;
case ABIL_KIKU_INVOKE_DEATH:
- summon_demon(MONS_REAPER, 20 + you.skills[SK_INVOCATIONS] * 3, true);
+ summon_demon_type(MONS_REAPER,
+ 20 + you.skills[SK_INVOCATIONS] * 3, true);
exercise(SK_INVOCATIONS, 10 + random2(14));
break;
@@ -1536,8 +1537,8 @@ static bool _do_ability(const ability_def& abil)
break;
case ABIL_MAKHLEB_LESSER_SERVANT_OF_MAKHLEB:
- summon_demon(static_cast<monster_type>(MONS_NEQOXEC + random2(5)),
- 20 + you.skills[SK_INVOCATIONS] * 3, true);
+ summon_demon_type(static_cast<monster_type>(MONS_NEQOXEC + random2(5)),
+ 20 + you.skills[SK_INVOCATIONS] * 3, true);
exercise(SK_INVOCATIONS, 2 + random2(3));
break;
@@ -1595,8 +1596,8 @@ static bool _do_ability(const ability_def& abil)
break;
case ABIL_MAKHLEB_GREATER_SERVANT_OF_MAKHLEB:
- summon_demon(static_cast<monster_type>(MONS_EXECUTIONER + random2(5)),
- 20 + you.skills[SK_INVOCATIONS] * 3, true);
+ summon_demon_type(static_cast<monster_type>(MONS_EXECUTIONER + random2(5)),
+ 20 + you.skills[SK_INVOCATIONS] * 3, true);
exercise(SK_INVOCATIONS, 6 + random2(6));
break;
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 0711a6e37b..6168382ff8 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -1888,57 +1888,85 @@ bool cast_call_canine_familiar(int pow, bool god_gift)
return (success);
}
-static bool _summon_demon_wrapper(int pow, bool god_gift, demon_class_type dct,
- int dur, bool friendly, bool charmed,
- int how_many)
+static bool _summon_demon_class_wrapper(int pow, bool god_gift,
+ demon_class_type dct, int dur,
+ bool friendly, bool charmed)
{
bool success = false;
mpr("You open a gate to Pandemonium!");
- for (int i = 0; i < how_many; ++i)
- {
- monster_type mon = summon_any_demon(dct);
+ monster_type mon = summon_any_demon(dct);
- if (create_monster(
- mgen_data(mon,
- friendly ? BEH_FRIENDLY :
- charmed ? BEH_CHARMED : BEH_HOSTILE,
- dur, you.pos(),
- friendly ? you.pet_target : MHITYOU,
- god_gift ? MF_GOD_GIFT : 0)) != -1)
- {
- success = true;
+ if (create_monster(
+ mgen_data(mon,
+ friendly ? BEH_FRIENDLY :
+ charmed ? BEH_CHARMED : BEH_HOSTILE,
+ dur, you.pos(),
+ friendly ? you.pet_target : MHITYOU,
+ god_gift ? MF_GOD_GIFT : 0)) != -1)
+ {
+ success = true;
- mprf("A demon appears!%s",
- friendly ? "" :
- charmed ? " You don't feel so good about this..."
- : " It doesn't look very happy.");
- }
+ mprf("A demon appears!%s",
+ friendly ? "" :
+ charmed ? " You don't feel so good about this..."
+ : " It doesn't look very happy.");
}
- if (!success)
- canned_msg(MSG_NOTHING_HAPPENS);
-
return (success);
}
+bool summon_lesser_demon(int pow, bool god_gift)
+{
+ return _summon_demon_class_wrapper(pow, god_gift, DEMON_LESSER,
+ std::min(2 + (random2(pow) / 4), 6),
+ random2(pow) > 3, false);
+}
+
+bool summon_common_demon(int pow, bool god_gift)
+{
+ return _summon_demon_class_wrapper(pow, god_gift, DEMON_COMMON,
+ std::min(2 + (random2(pow) / 4), 6),
+ random2(pow) > 3, false);
+}
+
+bool summon_greater_demon(int pow, bool god_gift)
+{
+ return _summon_demon_class_wrapper(pow, god_gift, DEMON_GREATER,
+ 5, false, random2(pow) > 5);
+}
+
bool cast_summon_demon(int pow, bool god_gift)
{
mpr("You open a gate to Pandemonium!");
- return summon_common_demon(pow, god_gift);
+ bool success = summon_common_demon(pow, god_gift);
+
+ if (!success)
+ canned_msg(MSG_NOTHING_HAPPENS);
+
+ return (success);
}
bool cast_demonic_horde(int pow, bool god_gift)
{
+ bool success = false;
+
const int how_many = 7 + random2(5);
mpr("You open a gate to Pandemonium!");
- return _summon_demon_wrapper(pow, god_gift, DEMON_LESSER,
- std::min(2 + (random2(pow) / 4), 6),
- random2(pow) > 3, false, how_many);
+ for (int i = 0; i < how_many; ++i)
+ {
+ if (summon_lesser_demon(pow, god_gift))
+ success = true;
+ }
+
+ if (!success)
+ canned_msg(MSG_NOTHING_HAPPENS);
+
+ return (success);
}
bool cast_summon_ice_beast(int pow, bool god_gift)
@@ -2001,8 +2029,13 @@ bool cast_summon_greater_demon(int pow, bool god_gift)
mpr("You open a gate to Pandemonium!");
- return _summon_demon_wrapper(pow, god_gift, DEMON_GREATER,
- 5, false, charmed, 1);
+ bool success = _summon_demon_class_wrapper(pow, god_gift, DEMON_GREATER,
+ 5, false, charmed);
+
+ if (!success)
+ canned_msg(MSG_NOTHING_HAPPENS);
+
+ return (success);
}
bool cast_summon_wraiths(int pow, bool god_gift)
@@ -2072,22 +2105,8 @@ bool cast_summon_dragon(int pow, bool god_gift)
return (success);
}
-bool summon_minor_demon(int pow, bool god_gift)
-{
- return _summon_demon_wrapper(pow, god_gift, DEMON_LESSER,
- std::min(2 + (random2(pow) / 4), 6),
- random2(pow) > 3, false, 1);
-}
-
-bool summon_common_demon(int pow, bool god_gift)
-{
- return _summon_demon_wrapper(pow, god_gift, DEMON_COMMON,
- std::min(2 + (random2(pow) / 4), 6),
- random2(pow) > 3, false, 1);
-}
-
-// One of the demon-associated gods sends a demon for a follower.
-bool summon_demon(monster_type mon, int pow, bool god_gift)
+// A demon-associated god sends a demonic buddy (or enemy) for a follower.
+bool summon_demon_type(monster_type mon, int pow, bool god_gift)
{
bool success = false;
diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h
index 4ac7873b5c..9d277ae685 100644
--- a/crawl-ref/source/spells2.h
+++ b/crawl-ref/source/spells2.h
@@ -151,6 +151,12 @@ bool cast_call_imp(int pow, bool god_gift = false);
bool cast_call_canine_familiar(int pow, bool god_gift = false);
+bool summon_lesser_demon(int pow, bool god_gift = false);
+
+bool summon_common_demon(int pow, bool god_gift = false);
+
+bool summon_greater_demon(int pow, bool god_gift = false);
+
bool cast_summon_demon(int pow, bool god_gift = false);
bool cast_demonic_horde(int pow, bool god_gift = false);
@@ -165,11 +171,7 @@ bool cast_summon_wraiths(int pow, bool god_gift = false);
bool cast_summon_dragon(int pow, bool god_gift = false);
-bool summon_minor_demon(int pow, bool god_gift = false);
-
-bool summon_common_demon(int pow, bool god_gift = false);
-
-bool summon_demon(monster_type mon, int pow, bool god_gift = false);
+bool summon_demon_type(monster_type mon, int pow, bool god_gift = false);
bool summon_berserker(int pow, bool god_gift = false,
bool force_hostile = false);