summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells3.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-08 16:41:20 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-08 16:41:20 +0000
commit073c543794a6c722916775207213877500167327 (patch)
tree34ca8101ffe5c5ff7cd64ce857aba1698315bd81 /crawl-ref/source/spells3.cc
parent220cc50e053ae2c95299fc59426dbfe535eb46d3 (diff)
downloadcrawl-ref-073c543794a6c722916775207213877500167327.tar.gz
crawl-ref-073c543794a6c722916775207213877500167327.zip
Clean up "Simulacrum".
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5598 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells3.cc')
-rw-r--r--crawl-ref/source/spells3.cc62
1 files changed, 30 insertions, 32 deletions
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<monster_type>(you.inv[ chunk ].plus);
+ const monster_type mon =
+ static_cast<monster_type>(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