diff options
-rw-r--r-- | crawl-ref/source/effects.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 154 | ||||
-rw-r--r-- | crawl-ref/source/item_use.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/transfor.cc | 39 | ||||
-rw-r--r-- | crawl-ref/source/transfor.h | 2 |
5 files changed, 113 insertions, 92 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index b213683e5d..66ce66797d 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1155,14 +1155,16 @@ bool acquirement(object_class_type class_wanted, int agent) continue; const item_def &doodad(mitm[thing_created]); - if (doodad.base_type == OBJ_WEAPONS - && !can_wield(&doodad, false, true)) + if ((doodad.base_type == OBJ_WEAPONS + && !can_wield(&doodad, false, true)) + || (doodad.base_type == OBJ_ARMOUR + && !can_wear_armour(doodad, false, true))) { destroy_item(thing_created); thing_created = NON_ITEM; continue; } - + // MT - Check: god-gifted weapons and armor shouldn't kill you. // Except Xom. if ((agent == GOD_TROG || agent == GOD_OKAWARU) 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]] )) diff --git a/crawl-ref/source/item_use.h b/crawl-ref/source/item_use.h index d0ccb961c9..3597d42510 100644 --- a/crawl-ref/source/item_use.h +++ b/crawl-ref/source/item_use.h @@ -94,6 +94,8 @@ void throw_anything(void); * *********************************************************************** */ void wear_armour( void ); +bool can_wear_armour(const item_def &item, bool verbose, bool ignore_temporary); + // last updated 10Sept2001 {bwr} /* *********************************************************************** * called from: acr diff --git a/crawl-ref/source/transfor.cc b/crawl-ref/source/transfor.cc index cb69bfb31b..58a14e4532 100644 --- a/crawl-ref/source/transfor.cc +++ b/crawl-ref/source/transfor.cc @@ -542,12 +542,12 @@ void untransform(void) // XXX: This whole system is a mess as it still relies on special // cases to handle a large number of things (see wear_armour()) -- bwr -bool can_equip( equipment_type use_which ) +bool can_equip( equipment_type use_which, bool ignore_temporary ) { // if more cases are added to this if must also change in // item_use for naga barding - if (!player_is_shapechanged()) + if (ignore_temporary || !player_is_shapechanged()) /* or a transformation which doesn't change overall shape */ { if (use_which == EQ_BOOTS) @@ -583,27 +583,30 @@ bool can_equip( equipment_type use_which ) if (use_which == EQ_GLOVES && you.mutation[MUT_CLAWS] >= 3) return (false); - switch (you.attribute[ATTR_TRANSFORMATION]) + if (!ignore_temporary) { - case TRAN_NONE: - case TRAN_LICH: - return (true); + switch (you.attribute[ATTR_TRANSFORMATION]) + { + case TRAN_NONE: + case TRAN_LICH: + return (true); - case TRAN_BLADE_HANDS: - return (use_which != EQ_WEAPON - && use_which != EQ_GLOVES - && use_which != EQ_SHIELD); + case TRAN_BLADE_HANDS: + return (use_which != EQ_WEAPON + && use_which != EQ_GLOVES + && use_which != EQ_SHIELD); - case TRAN_STATUE: - return (use_which == EQ_WEAPON - || use_which == EQ_CLOAK - || use_which == EQ_HELMET); + case TRAN_STATUE: + return (use_which == EQ_WEAPON + || use_which == EQ_CLOAK + || use_which == EQ_HELMET); - case TRAN_ICE_BEAST: - return (use_which == EQ_CLOAK); + case TRAN_ICE_BEAST: + return (use_which == EQ_CLOAK); - default: - return (false); + default: + return (false); + } } return (true); diff --git a/crawl-ref/source/transfor.h b/crawl-ref/source/transfor.h index 5d5480c026..cc9e44de78 100644 --- a/crawl-ref/source/transfor.h +++ b/crawl-ref/source/transfor.h @@ -32,7 +32,7 @@ void untransform(void); /* *********************************************************************** * called from: item_use * *********************************************************************** */ -bool can_equip(equipment_type use_which); +bool can_equip(equipment_type use_which, bool ignore_temporary); size_type transform_size(int psize = PSIZE_BODY); // last updated 12may2000 {dlb} |