From cce3c6e018e1ec88a1b49eaf2fbfde88f51ada01 Mon Sep 17 00:00:00 2001 From: Haran Pilpel Date: Wed, 13 Jan 2010 10:01:03 +0200 Subject: Various cleanups, use you.weapon() more often, fix a note in README.txt. --- crawl-ref/source/effects.cc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'crawl-ref/source/effects.cc') 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; } } -- cgit v1.2.3-54-g00ecf