From c96c36a0477909874c98bdbda3d13333ddb453e2 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 26 Oct 2008 13:18:19 +0000 Subject: Implement FR 1894211: All transformations will now cause your equipment to meld into your body than rather than being removed, so that when untransforming you don't have to put everything on again. * Wielded stuff cannot be melded, and does not yet use the autoswap function. * As before, the low-level transformation spells refuse to work with cursed equipment. * The messages are unnecessarily spammy if you change forms while already transformed (first everything is re-equipped, then unequipped again). Conversely, on simply untransforming the lack of messages might be confusing. * Might be buggy, feedback welcome! git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7300 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/transfor.cc | 47 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'crawl-ref/source/transfor.cc') diff --git a/crawl-ref/source/transfor.cc b/crawl-ref/source/transfor.cc index ab380739e1..d67baf0ec1 100644 --- a/crawl-ref/source/transfor.cc +++ b/crawl-ref/source/transfor.cc @@ -98,7 +98,7 @@ bool remove_equipment(std::set removed) canned_msg(MSG_EMPTY_HANDED); } - // Remove items in order. (std::set is a sorted container) + // Meld items into you in (reverse) order. (std::set is a sorted container) std::set::const_iterator iter; for (iter = removed.begin(); iter != removed.end(); ++iter) { @@ -106,19 +106,41 @@ bool remove_equipment(std::set removed) if (e == EQ_WEAPON || you.equip[e] == -1) continue; - mprf("%s falls away.", + mprf("%s melds into your body.", you.inv[you.equip[e]].name(DESC_CAP_YOUR).c_str()); if (e == EQ_LEFT_RING || e == EQ_RIGHT_RING || e == EQ_AMULET) { item_def &ring = you.inv[you.equip[e]]; - you.equip[e] = -1; - jewellery_remove_effects(ring, false); + jewellery_remove_effects(ring); } else // armour { unwear_armour( you.equip[e] ); - you.equip[e] = -1; + } + } + + return (true); +} + +static bool _unmeld_equipment(std::set melded) +{ + // Unmeld items in order. + std::set::const_iterator iter; + for (iter = melded.begin(); iter != melded.end(); ++iter) + { + const equipment_type e = *iter; + if (e == EQ_WEAPON || you.equip[e] == -1) + continue; + + if (e == EQ_LEFT_RING || e == EQ_RIGHT_RING || e == EQ_AMULET) + { + item_def &ring = you.inv[you.equip[e]]; + jewellery_wear_effects(ring); + } + else // armour + { + armour_wear_effects( you.equip[e] ); } } @@ -138,7 +160,7 @@ static bool check_for_cursed_equipment(const std::set &remove, bool quiet = false) { std::set::const_iterator iter; - for (iter = remove.begin(); iter != remove.end(); ++iter ) + for (iter = remove.begin(); iter != remove.end(); ++iter) { equipment_type e = *iter; if (you.equip[e] == -1) @@ -670,10 +692,19 @@ void untransform(void) you.symbol = '@'; you.colour = LIGHTGREY; - // must be unset first or else infinite loops might result -- bwr + // Must be unset first or else infinite loops might result. -- bwr const transformation_type old_form = static_cast(you.attribute[ ATTR_TRANSFORMATION ]); + // We may have to unmeld a couple of equipment types. + const equipment_type default_rem[] = { + EQ_CLOAK, EQ_HELMET, EQ_GLOVES, EQ_BOOTS, EQ_SHIELD, EQ_BODY_ARMOUR + }; + + std::set melded(default_rem, + default_rem + ARRAYSZ(default_rem)); + _init_equipment_removal(melded, old_form); + you.attribute[ ATTR_TRANSFORMATION ] = TRAN_NONE; you.duration[ DUR_TRANSFORMATION ] = 0; @@ -762,6 +793,8 @@ void untransform(void) break; } + _unmeld_equipment(melded); + // Re-check terrain now that be may no longer be flying. if (old_flight && you.flight_mode() == FL_NONE) move_player_to_grid(you.pos(), false, true, true); -- cgit v1.2.3-54-g00ecf