summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/effects.cc
diff options
context:
space:
mode:
authorHaran Pilpel <haranp@users.sourceforge.net>2010-01-13 10:01:03 +0200
committerHaran Pilpel <haranp@users.sourceforge.net>2010-01-13 10:01:03 +0200
commitcce3c6e018e1ec88a1b49eaf2fbfde88f51ada01 (patch)
treed075743f82d153e2c17f5da43d5e5fb0dffb1636 /crawl-ref/source/effects.cc
parent253d9973468723045300b5025e2de1e96e350a99 (diff)
downloadcrawl-ref-cce3c6e018e1ec88a1b49eaf2fbfde88f51ada01.tar.gz
crawl-ref-cce3c6e018e1ec88a1b49eaf2fbfde88f51ada01.zip
Various cleanups, use you.weapon() more often, fix a note in README.txt.
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r--crawl-ref/source/effects.cc23
1 files changed, 11 insertions, 12 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 9f18a9d5b8..ee09fc5689 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -1275,19 +1275,18 @@ static bool _try_give_plain_armour(item_def &arm)
// Consider shield slot filled in some cases.
if (armour_slots[i] == EQ_SHIELD)
{
- if (you.equip[EQ_WEAPON] == -1)
- {
- if (you.skills[SK_UNARMED_COMBAT] > random2(8))
- continue;
- }
- else
+ const item_def* weapon = you.weapon();
+
+ // Unarmed fighters don't need shields.
+ if (!weapon && you.skills[SK_UNARMED_COMBAT] > random2(8))
+ continue;
+
+ // Two-handed weapons and ranged weapons conflict with shields.
+ if (weapon
+ && (hands_reqd(*weapon, you.body_size()) == HANDS_TWO)
+ || is_range_weapon(*weapon))
{
- const item_def weapon = you.inv[you.equip[EQ_WEAPON]];
- const hands_reqd_type hand = hands_reqd(weapon, you.body_size());
- if (hand == HANDS_TWO || is_range_weapon(weapon))
- {
- continue;
- }
+ continue;
}
}