From 073c543794a6c722916775207213877500167327 Mon Sep 17 00:00:00 2001 From: dolorous Date: Sun, 8 Jun 2008 16:41:20 +0000 Subject: Clean up "Simulacrum". git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5598 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells3.cc | 62 +++++++++++++++++++++----------------------- crawl-ref/source/spells3.h | 2 +- crawl-ref/source/spl-cast.cc | 18 ++++++------- 3 files changed, 40 insertions(+), 42 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index df9cc7c4ca..028fced8e3 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -418,57 +418,55 @@ void sublimation(int power) // Hides and other "animal part" items are intentionally left out, it's // unrequired complexity, and fresh flesh makes more "sense" for a spell // reforming the original monster out of ice anyways. -void simulacrum(int power) +bool simulacrum(int pow, bool god_gift) { - int max_num = 4 + random2(power) / 20; - if (max_num > 8) - max_num = 8; + int how_many_max = std::min(8, 4 + random2(pow) / 20); const int chunk = you.equip[EQ_WEAPON]; if (chunk != -1 - && is_valid_item( you.inv[ chunk ] ) - && (you.inv[ chunk ].base_type == OBJ_CORPSES - || (you.inv[ chunk ].base_type == OBJ_FOOD - && you.inv[ chunk ].sub_type == FOOD_CHUNK))) + && is_valid_item(you.inv[chunk]) + && (you.inv[chunk].base_type == OBJ_CORPSES + || (you.inv[chunk].base_type == OBJ_FOOD + && you.inv[chunk].sub_type == FOOD_CHUNK))) { - const monster_type mons_type = - static_cast(you.inv[ chunk ].plus); + const monster_type mon = + static_cast(you.inv[chunk].plus); - // Can't create more than the available chunks - if (you.inv[ chunk ].quantity < max_num) - max_num = you.inv[ chunk ].quantity; + // Can't create more than the available chunks. + if (you.inv[chunk].quantity < how_many_max) + how_many_max = you.inv[chunk].quantity; - dec_inv_item_quantity( chunk, max_num ); + dec_inv_item_quantity(chunk, how_many_max); - int summoned = 0; + int count = 0; - for (int i = 0; i < max_num; i++) + for (int i = 0; i < how_many_max; ++i) { if (create_monster( - mgen_data(MONS_SIMULACRUM_SMALL, - BEH_FRIENDLY, 6, - you.pos(), you.pet_target, - 0, mons_type)) != -1) + mgen_data(MONS_SIMULACRUM_SMALL, BEH_FRIENDLY, + 6, you.pos(), you.pet_target, + god_gift ? MF_GOD_GIFT : 0, + mon)) != -1) { - summoned++; + count++; } } - if (summoned) + if (count > 0) { - mprf("%s before you!", - (summoned == 1) ? "An icy figure forms " - : "Some icy figures form "); + mprf("%s icy figure form%s before you!", + count > 1 ? "Some" : "An", count > 1 ? "s" : ""); + return (true); } - else - mpr( "You feel cold for a second." ); - } - else - { - mpr( "You need to wield a piece of raw flesh for this spell " - "to be effective!" ); + + mpr("You feel cold for a second."); + return (false); } + + mpr("You need to wield a piece of raw flesh for this spell to be " + "effective!"); + return (false); } // This function returns true if the player can use controlled teleport diff --git a/crawl-ref/source/spells3.h b/crawl-ref/source/spells3.h index 3c8b4bdcfc..52aa5f8866 100644 --- a/crawl-ref/source/spells3.h +++ b/crawl-ref/source/spells3.h @@ -124,7 +124,7 @@ void sublimation(int power); /* *********************************************************************** * called from: spell * *********************************************************************** */ -void simulacrum(int power); +bool simulacrum(int pow, bool god_gift = false); // updated 24may2000 {dlb} diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index d836d841da..954ca4e4b7 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1540,6 +1540,15 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) cast_conjure_ball_lightning(powc); break; + case SPELL_TUKIMAS_DANCE: + crawl_state.cant_cmd_repeat("You can't repeat dancing weapon."); + dancing_weapon(powc); + break; + + case SPELL_SIMULACRUM: + simulacrum(powc); + break; + case SPELL_OZOCUBUS_ARMOUR: ice_armour(powc, false); break; @@ -1604,11 +1613,6 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) sublimation(powc); break; - case SPELL_TUKIMAS_DANCE: - crawl_state.cant_cmd_repeat("You can't repeat dancing weapon."); - dancing_weapon(powc); - break; - case SPELL_HELLFIRE: // Should only be available from: // staff of Dispater & Sceptre of Asmodeus @@ -1977,10 +1981,6 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) cast_stoneskin(powc); break; - case SPELL_SIMULACRUM: - simulacrum(powc); - break; - case SPELL_CHAIN_LIGHTNING: cast_chain_lightning(powc); break; -- cgit v1.2.3-54-g00ecf