From c1bcbec614c07a816debe3a6e1a67baeb84712e0 Mon Sep 17 00:00:00 2001 From: dolorous Date: Mon, 9 Jun 2008 18:22:35 +0000 Subject: Consolidate the (single) spatial vortex-summoning routines, and add more minor cleanups. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5667 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells2.cc | 29 +++++++++++++++++++++++------ crawl-ref/source/spells2.h | 3 ++- crawl-ref/source/spells3.cc | 8 ++++---- crawl-ref/source/spl-cast.cc | 10 ++-------- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 205683c47c..3a0bffba35 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -971,8 +971,20 @@ char burn_freeze(int pow, beam_type flavour) return 1; } -void summon_animals(int pow) +bool summon_spatial_vortex(bool god_gift) { + mpr("Space twists in upon itself!"); + + return (create_monster( + mgen_data(MONS_SPATIAL_VORTEX, BEH_HOSTILE, + 3, you.pos(), + MHITYOU, (god_gift ? MG_GOD_GIFT : 0))) != -1); +} + +bool summon_animals(int pow) +{ + bool success = false; + // Maybe we should just generate a Lair monster instead (and // guarantee that it is mobile)? const monster_type animals[] = { @@ -1010,12 +1022,17 @@ void summon_animals(int pow) const bool friendly = (random2(pow) > 4); - create_monster( - mgen_data(mon, - friendly ? BEH_FRIENDLY : BEH_HOSTILE, - 4, you.pos(), - friendly ? you.pet_target : MHITYOU)); + if (create_monster( + mgen_data(mon, + friendly ? BEH_FRIENDLY : BEH_HOSTILE, + 4, you.pos(), + friendly ? you.pet_target : MHITYOU)) != -1) + { + success = true; + } } + + return (success); } bool cast_summon_butterflies(int pow, bool god_gift) diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h index d1abd1a22f..356d1cbb02 100644 --- a/crawl-ref/source/spells2.h +++ b/crawl-ref/source/spells2.h @@ -152,7 +152,8 @@ bool summon_daeva(int pow, bool god_gift = false); /* *********************************************************************** * called from: spell * *********************************************************************** */ -void summon_animals(int pow); +bool summon_spatial_vortex(bool god_gift = false); +bool summon_animals(int pow); // last updated 24may2000 {dlb} diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index f45f368fe0..8c9ee35340 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -417,10 +417,10 @@ bool summon_shadow(bool god_gift, bool force_hostile) { return (create_monster( mgen_data(MONS_SHADOW, - !force_hostile ? BEH_FRIENDLY : BEH_HOSTILE, - 2, you.pos(), - !force_hostile ? you.pet_target : MHITYOU, - (god_gift ? MG_GOD_GIFT : 0))) != -1); + !force_hostile ? BEH_FRIENDLY : BEH_HOSTILE, + 2, you.pos(), + !force_hostile ? you.pet_target : MHITYOU, + (god_gift ? MG_GOD_GIFT : 0))) != -1); } bool cast_call_imp(int pow, bool god_gift) diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index c63472489a..3d6e55240c 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -2369,10 +2369,7 @@ static void _miscast_translocation(int severity, const char* cause) ouch(4 + random2avg(7, 2), 0, KILLED_BY_WILD_MAGIC, cause); break; case 5: - mpr("Space twists in upon itself!"); - create_monster( - mgen_data(MONS_SPATIAL_VORTEX, BEH_HOSTILE, 3, - you.pos(), MHITYOU)); + summon_spatial_vortex(); break; } break; @@ -2497,10 +2494,7 @@ static void _miscast_summoning(int severity, const char* cause) break; case 3: - mpr("Space twists in upon itself!"); - create_monster( - mgen_data(MONS_SPATIAL_VORTEX, BEH_HOSTILE, 3, - you.pos(), MHITYOU)); + summon_spatial_vortex(); break; case 4: -- cgit v1.2.3-54-g00ecf