From 80c38b0682f61fc2901af257cc115676bacc9bde Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sat, 4 Aug 2007 09:53:52 +0000 Subject: Fixed acquirement giving unwearable armour (Iaido). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1961 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/item_use.cc | 154 +++++++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 70 deletions(-) (limited to 'crawl-ref/source/item_use.cc') diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 75e6ec034e..b15d66e35b 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -87,9 +87,7 @@ bool can_wield(const item_def *weapon, bool say_reason, SAY(canned_msg(MSG_TOO_BERSERK)); return false; } - if (!ignore_temporary_disability - && you.attribute[ATTR_TRANSFORMATION] != TRAN_NONE - && !can_equip( EQ_WEAPON )) + if (!can_equip( EQ_WEAPON, ignore_temporary_disability )) { SAY(mpr("You can't wield anything in your present form.")); return false; @@ -720,60 +718,21 @@ static int armour_equip_delay(const item_def &item) return (delay); } -bool do_wear_armour( int item, bool quiet ) +bool can_wear_armour(const item_def &item, bool verbose, bool ignore_temporary) { - if (!is_valid_item( you.inv[item] )) - { - if (!quiet) - mpr("You don't have any such object."); - - return (false); - } - - const object_class_type base_type = you.inv[item].base_type; + const object_class_type base_type = item.base_type; if (base_type != OBJ_ARMOUR) { - if (!quiet) + if (verbose) mpr("You can't wear that."); return (false); } - - const int sub_type = you.inv[item].sub_type; - const item_def &invitem = you.inv[item]; - const equipment_type slot = get_armour_slot(invitem); - - if (item == you.equip[EQ_WEAPON]) - { - if (!quiet) - mpr("You are wielding that object!"); - - return (false); - } - - if ( wearing_slot(item) ) - { - if (!quiet) - mpr("You are already wearing that!"); - - return (false); - } - - // if you're wielding something, - if (you.equip[EQ_WEAPON] != -1 - // attempting to wear a shield, - && is_shield(you.inv[item]) - && is_shield_incompatible( - you.inv[you.equip[EQ_WEAPON]], - &you.inv[item])) - { - if (!quiet) - mpr("You'd need three hands to do that!"); - - return (false); - } - + bool can_wear = true; + const int sub_type = item.sub_type; + const equipment_type slot = get_armour_slot(item); + if (sub_type == ARM_NAGA_BARDING) can_wear = (you.species == SP_NAGA); @@ -782,23 +741,24 @@ bool do_wear_armour( int item, bool quiet ) if (!can_wear) { - if (!quiet) + if (verbose) mpr("You can't wear that!"); return (false); } - if (you.inv[item].sub_type == ARM_BOOTS) + if (sub_type == ARM_BOOTS) { if (you.species == SP_NAGA || you.species == SP_CENTAUR) { - if (!quiet) + if (verbose) mpr("You can't wear that!"); return (false); } - if (player_is_swimming() && you.species == SP_MERFOLK) + if (!ignore_temporary && player_is_swimming() + && you.species == SP_MERFOLK) { - if (!quiet) + if (verbose) mpr("You don't currently have feet!"); return (false); @@ -806,36 +766,40 @@ bool do_wear_armour( int item, bool quiet ) } if (you.species == SP_NAGA && sub_type == ARM_NAGA_BARDING - && !player_is_shapechanged()) + && (ignore_temporary || !player_is_shapechanged())) { // it fits + return (true); } else if (you.species == SP_CENTAUR && sub_type == ARM_CENTAUR_BARDING - && !player_is_shapechanged()) + && (ignore_temporary || !player_is_shapechanged())) { // it fits + return (true); } else if (sub_type == ARM_HELMET - && (get_helmet_type(invitem) == THELM_CAP - || get_helmet_type(invitem) == THELM_WIZARD_HAT)) + && (get_helmet_type(item) == THELM_CAP + || get_helmet_type(item) == THELM_WIZARD_HAT)) { // caps & wiz hats always fit + return (true); } - else if (!can_equip( slot )) + else if (!can_equip( slot, ignore_temporary )) { - if (!quiet) + if (verbose) mpr("You can't wear that in your present form."); return (false); } // Cannot swim in heavy armour - if (player_is_swimming() + if (!ignore_temporary + && player_is_swimming() && slot == EQ_BODY_ARMOUR - && !is_light_armour( invitem )) + && !is_light_armour( item )) { - if (!quiet) + if (verbose) mpr("You can't swim in that!"); return (false); @@ -851,10 +815,10 @@ bool do_wear_armour( int item, bool quiet ) && sub_type <= ARM_BUCKLER) || sub_type == ARM_CRYSTAL_PLATE_MAIL || (sub_type == ARM_HELMET - && (get_helmet_type(invitem) == THELM_HELM - || get_helmet_type(invitem) == THELM_HELMET))) + && (get_helmet_type(item) == THELM_HELM + || get_helmet_type(item) == THELM_HELMET))) { - if (!quiet) + if (verbose) mpr("This armour doesn't fit on your body."); return (false); @@ -872,16 +836,65 @@ bool do_wear_armour( int item, bool quiet ) || sub_type == ARM_LARGE_SHIELD || sub_type == ARM_CRYSTAL_PLATE_MAIL || (sub_type == ARM_HELMET - && (get_helmet_type(invitem) == THELM_HELM - || get_helmet_type(invitem) == THELM_HELMET))) + && (get_helmet_type(item) == THELM_HELM + || get_helmet_type(item) == THELM_HELMET))) { - if (!quiet) + if (verbose) mpr("This armour doesn't fit on your body."); return (false); } } + return (true); +} + +bool do_wear_armour( int item, bool quiet ) +{ + if (!is_valid_item( you.inv[item] )) + { + if (!quiet) + mpr("You don't have any such object."); + + return (false); + } + + if (!can_wear_armour(you.inv[item], !quiet, false)) + return (false); + + const item_def &invitem = you.inv[item]; + const equipment_type slot = get_armour_slot(invitem); + + if (item == you.equip[EQ_WEAPON]) + { + if (!quiet) + mpr("You are wielding that object!"); + + return (false); + } + + if ( wearing_slot(item) ) + { + if (!quiet) + mpr("You are already wearing that!"); + + return (false); + } + + // if you're wielding something, + if (you.equip[EQ_WEAPON] != -1 + // attempting to wear a shield, + && is_shield(you.inv[item]) + && is_shield_incompatible( + you.inv[you.equip[EQ_WEAPON]], + &you.inv[item])) + { + if (!quiet) + mpr("You'd need three hands to do that!"); + + return (false); + } + bool removedCloak = false; int cloak = -1; @@ -893,7 +906,8 @@ bool do_wear_armour( int item, bool quiet ) { if ( !quiet ) mprf("%s is stuck to your body!", - you.inv[you.equip[EQ_BODY_ARMOUR]].name(DESC_CAP_YOUR).c_str()); + you.inv[you.equip[EQ_BODY_ARMOUR]].name(DESC_CAP_YOUR) + .c_str()); return (false); } if (!item_cursed( you.inv[you.equip[EQ_CLOAK]] )) -- cgit v1.2.3-54-g00ecf