summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/item_use.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-06 16:47:06 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-06 16:47:06 +0000
commit200b4c0e08504a7c8df898d77a9d72b3fa573c04 (patch)
treeb6cf73c902a55861ab60656e0225f0385c2c3a59 /crawl-ref/source/item_use.cc
parent7f2ded93231941b48fba24bcc9a55602295f72bd (diff)
downloadcrawl-ref-200b4c0e08504a7c8df898d77a9d72b3fa573c04.tar.gz
crawl-ref-200b4c0e08504a7c8df898d77a9d72b3fa573c04.zip
Add a function x_chance_in_y(x,y) to replace the various
random2(y) < x checks, e.g. x_chance_in_y(weight, totalweight). This should make things a bit more readable. Apply it to a number of files. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6428 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/item_use.cc')
-rw-r--r--crawl-ref/source/item_use.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 49855a0b41..568645fc89 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -135,8 +135,7 @@ bool can_wield(const item_def *weapon, bool say_reason,
if (weapon->base_type != OBJ_WEAPONS)
return (true);
- if ((you.species < SP_OGRE || you.species > SP_OGRE_MAGE)
- && item_mass( *weapon ) >= 300)
+ if (player_size(PSIZE_TORSO) < SIZE_LARGE && item_mass( *weapon ) >= 300)
{
SAY(mpr("That's too large and heavy for you to wield."));
return (false);
@@ -164,8 +163,7 @@ bool can_wield(const item_def *weapon, bool say_reason,
int weap_brand = get_weapon_brand( *weapon );
if ((you.is_undead || you.species == SP_DEMONSPAWN)
- && (weap_brand == SPWPN_HOLY_WRATH
- || is_blessed_blade(*weapon)))
+ && (weap_brand == SPWPN_HOLY_WRATH || is_blessed_blade(*weapon)))
{
SAY(mpr("This weapon will not allow you to wield it."));
return (false);
@@ -376,10 +374,12 @@ static void warn_rod_shield_interference(const item_def &)
// Any way to avoid the double entendre? :-)
if (leak_degree)
+ {
mprf(MSGCH_WARN,
"Your %s %sreduces the effectiveness of your rod.",
shield_base_name(player_shield()),
leak_degree);
+ }
}
static void warn_launcher_shield_slowdown(const item_def &launcher)
@@ -394,11 +394,14 @@ static void warn_launcher_shield_slowdown(const item_def &launcher)
{
const char *slow_degree =
shield_impact_degree(slowspeed * 100 / normspeed);
+
if (slow_degree)
+ {
mprf(MSGCH_WARN,
"Your %s %sslows your rate of fire.",
shield_base_name(player_shield()),
slow_degree);
+ }
}
}
@@ -4285,7 +4288,7 @@ void read_scroll( int slot )
// Imperfect vision prevents players from reading actual content {dlb}:
if (player_mutation_level(MUT_BLURRY_VISION)
- && random2(5) < player_mutation_level(MUT_BLURRY_VISION))
+ && x_chance_in_y(player_mutation_level(MUT_BLURRY_VISION), 5))
{
mpr((player_mutation_level(MUT_BLURRY_VISION) == 3 && one_chance_in(3))
? "This scroll appears to be blank."