diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-10-12 01:49:12 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-10-12 01:49:12 +0000 |
commit | af9d6c8e0e2e3f58d255449716ad7875cde5ae07 (patch) | |
tree | 1a2d6ffcad7f74d1fbebaa349233928bd60d8d2e /crawl-ref/source/fight.cc | |
parent | 192cbf9887aae64c3ef02cde310ee3175a0d4fb5 (diff) | |
download | crawl-ref-af9d6c8e0e2e3f58d255449716ad7875cde5ae07.tar.gz crawl-ref-af9d6c8e0e2e3f58d255449716ad7875cde5ae07.zip |
General code improvements.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7220 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r-- | crawl-ref/source/fight.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 314b1bad7f..913119784c 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -193,9 +193,9 @@ int calc_heavy_armour_penalty( bool random_factor ) int heavy_armour = 0; // heavy armour modifiers for shield borne - if (you.equip[EQ_SHIELD] != -1) + if (you.shield()) { - switch (you.inv[you.equip[EQ_SHIELD]].sub_type) + switch (you.shield()->sub_type) { case ARM_SHIELD: if (you.skills[SK_SHIELDS] < maybe_random2(7, random_factor)) @@ -4261,22 +4261,19 @@ int weapon_str_weight( object_class_type wpn_class, int wpn_type ) // Returns a value from 0 to 10 representing the weight of strength to // dexterity for the players currently wielded weapon. -static inline int player_weapon_str_weight( void ) +static inline int player_weapon_str_weight() { - const int weapon = you.equip[ EQ_WEAPON ]; + const item_def* weapon = you.weapon(); // unarmed, weighted slightly towards dex -- would have been more, // but then we'd be punishing Trolls and Ghouls who are strong and // get special unarmed bonuses. - if (weapon == -1) + if (!weapon) return (4); - int ret = weapon_str_weight( you.inv[weapon].base_type, you.inv[weapon].sub_type ); - - const bool shield = (you.equip[EQ_SHIELD] != -1); - const int hands = hands_reqd(you.inv[weapon], player_size()); + int ret = weapon_str_weight(weapon->base_type, weapon->sub_type); - if (hands == HANDS_HALF && !shield) + if (hands_reqd(*weapon, player_size()) == HANDS_HALF && !you.shield()) ret += 1; return (ret); |