summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells2.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-09 07:21:05 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-09 07:21:05 +0000
commit15f755e821f33123f3d44d5c77def801810bef06 (patch)
tree35f5da63b9d13644e14ee7f566f1c442e63492ae /crawl-ref/source/spells2.cc
parentae3f3137e8bf48b0276484074f6a03c9dc7497af (diff)
downloadcrawl-ref-15f755e821f33123f3d44d5c77def801810bef06.tar.gz
crawl-ref-15f755e821f33123f3d44d5c77def801810bef06.zip
Clean up "Sticks to Snakes" a bit more.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5646 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells2.cc')
-rw-r--r--crawl-ref/source/spells2.cc73
1 files changed, 37 insertions, 36 deletions
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index b6a5585c54..6222ac49b7 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -1096,15 +1096,9 @@ bool cast_summon_small_mammals(int pow, bool god_gift)
bool cast_sticks_to_snakes(int pow, bool god_gift)
{
- monster_type mon = MONS_PROGRAM_BUG;
-
- const int dur = std::min(3 + random2(pow) / 20, 5);
-
- int how_many_max = 1 + random2(1 + you.skills[SK_TRANSMIGRATION]) / 4;
-
- const int weapon = you.equip[EQ_WEAPON];
+ const int wpn = you.equip[EQ_WEAPON];
- if (weapon == -1)
+ if (wpn == -1)
{
msg::stream << "Your " << your_hand(true) << " feel slithery!"
<< std::endl;
@@ -1112,31 +1106,39 @@ bool cast_sticks_to_snakes(int pow, bool god_gift)
}
// Don't enchant sticks marked with {!D}.
- if (!check_warning_inscriptions(you.inv[ weapon ], OPER_DESTROY))
+ if (!check_warning_inscriptions(you.inv[wpn], OPER_DESTROY))
{
mprf("%s feel%s slithery for a moment!",
- you.inv[weapon].name(DESC_CAP_YOUR).c_str(),
- you.inv[weapon].quantity > 1 ? "s" : "");
+ you.inv[wpn].name(DESC_CAP_YOUR).c_str(),
+ you.inv[wpn].quantity > 1 ? "s" : "");
return (false);
}
- const beh_type beha = item_cursed(you.inv[ weapon ]) ? BEH_HOSTILE
- : BEH_FRIENDLY;
- const unsigned short hitting = (beha == BEH_HOSTILE) ? MHITYOU
- : you.pet_target;
+ monster_type mon = MONS_PROGRAM_BUG;
+
+ const int dur = std::min(3 + random2(pow) / 20, 5);
+
+ int how_many_max = 1 + random2(1 + you.skills[SK_TRANSMIGRATION]) / 4;
+
+ const bool friendly = (!item_cursed(you.inv[wpn]));
+
+ const beh_type beha = (friendly) ? BEH_FRIENDLY
+ : BEH_HOSTILE;
+ const unsigned short hitting = (friendly) ? you.pet_target
+ : MHITYOU;
int count = 0;
- if ((you.inv[weapon].base_type == OBJ_MISSILES
- && (you.inv[weapon].sub_type == MI_ARROW)))
+ if ((you.inv[wpn].base_type == OBJ_MISSILES
+ && (you.inv[wpn].sub_type == MI_ARROW)))
{
- if (you.inv[weapon].quantity < how_many_max)
- how_many_max = you.inv[weapon].quantity;
+ if (you.inv[wpn].quantity < how_many_max)
+ how_many_max = you.inv[wpn].quantity;
for (int i = 0; i <= how_many_max; i++)
{
if (one_chance_in(5 - std::min(4, div_rand_round(pow * 2, 25)))
- || get_ammo_brand(you.inv[weapon]) == SPMSL_POISONED)
+ || get_ammo_brand(you.inv[wpn]) == SPMSL_POISONED)
{
mon = random2(100) < pow / 3 ? MONS_BROWN_SNAKE : MONS_SNAKE;
}
@@ -1155,26 +1157,26 @@ bool cast_sticks_to_snakes(int pow, bool god_gift)
}
}
- if (you.inv[ weapon ].base_type == OBJ_WEAPONS
- && (you.inv[ weapon ].sub_type == WPN_CLUB
- || you.inv[ weapon ].sub_type == WPN_SPEAR
- || you.inv[ weapon ].sub_type == WPN_QUARTERSTAFF
- || you.inv[ weapon ].sub_type == WPN_SCYTHE
- || you.inv[ weapon ].sub_type == WPN_GIANT_CLUB
- || you.inv[ weapon ].sub_type == WPN_GIANT_SPIKED_CLUB
- || you.inv[ weapon ].sub_type == WPN_BOW
- || you.inv[ weapon ].sub_type == WPN_LONGBOW
- || you.inv[ weapon ].sub_type == WPN_ANKUS
- || you.inv[ weapon ].sub_type == WPN_HALBERD
- || you.inv[ weapon ].sub_type == WPN_GLAIVE
- || you.inv[ weapon ].sub_type == WPN_BLOWGUN))
+ if (you.inv[wpn].base_type == OBJ_WEAPONS
+ && (you.inv[wpn].sub_type == WPN_CLUB
+ || you.inv[wpn].sub_type == WPN_SPEAR
+ || you.inv[wpn].sub_type == WPN_QUARTERSTAFF
+ || you.inv[wpn].sub_type == WPN_SCYTHE
+ || you.inv[wpn].sub_type == WPN_GIANT_CLUB
+ || you.inv[wpn].sub_type == WPN_GIANT_SPIKED_CLUB
+ || you.inv[wpn].sub_type == WPN_BOW
+ || you.inv[wpn].sub_type == WPN_LONGBOW
+ || you.inv[wpn].sub_type == WPN_ANKUS
+ || you.inv[wpn].sub_type == WPN_HALBERD
+ || you.inv[wpn].sub_type == WPN_GLAIVE
+ || you.inv[wpn].sub_type == WPN_BLOWGUN))
{
// Upsizing Snakes to Brown Snakes as the base class for using
// the really big sticks (so bonus applies really only to trolls,
// ogres, and most importantly ogre magi). Still it's unlikely
// any character is strong enough to bother lugging a few of
// these around. -- bwr
- if (item_mass(you.inv[weapon]) < 300)
+ if (item_mass(you.inv[wpn]) < 300)
mon = MONS_SNAKE;
else
mon = MONS_BROWN_SNAKE;
@@ -1200,8 +1202,7 @@ bool cast_sticks_to_snakes(int pow, bool god_gift)
}
}
- if (count > you.inv[you.equip[EQ_WEAPON]].quantity)
- count = you.inv[you.equip[EQ_WEAPON]].quantity;
+ count = MIN(count, you.inv[you.equip[EQ_WEAPON]].quantity);
if (count > 0)
{