From 5c7064085c546eeeaecb43267806c0058345f865 Mon Sep 17 00:00:00 2001 From: haranp Date: Mon, 4 Aug 2008 16:42:54 +0000 Subject: Fix 2037105: amulet of controlled flight not autoIDing. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6773 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/it_use2.cc | 13 +++++++++++++ crawl-ref/source/player.cc | 46 ++++++++++++++++++++++----------------------- crawl-ref/source/player.h | 2 ++ 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index 542e9adbf1..d0d2a67ef9 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -188,6 +188,19 @@ bool potion_effect( potion_type pot_eff, int pow, bool was_known ) if (!player_is_airborne()) mpr("You gently float upwards from the floor."); + // Amulets can auto-ID. + // FIXME: should also happen when putting on/removing amulet + // while levitating. + if (!you.duration[DUR_LEVITATION] + && wearing_amulet(AMU_CONTROLLED_FLIGHT) + && !extrinsic_amulet_effect(AMU_CONTROLLED_FLIGHT)) + { + item_def& amu(you.inv[you.equip[EQ_AMULET]]); + set_ident_type(amu.base_type, amu.sub_type, ID_KNOWN_TYPE); + set_ident_flags(amu, ISFLAG_KNOW_PROPERTIES); + mprf("You are wearing: %s", amu.name(DESC_INVENTORY_EQUIP).c_str()); + } + you.duration[DUR_LEVITATION] += 25 + random2(pow); if (you.duration[DUR_LEVITATION] > 100) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index f2d4c89162..b3187aa42a 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -4212,37 +4212,37 @@ int player_mental_clarity(bool calc_unid, bool items) return ((ret > 3) ? 3 : ret); } -bool wearing_amulet(jewellery_type amulet, bool calc_unid) +// Returns whether the player has the effect of the amulet +// from a non-amulet source. +bool extrinsic_amulet_effect(jewellery_type amulet) { - if (amulet == AMU_CONTROLLED_FLIGHT - && (you.duration[DUR_CONTROLLED_FLIGHT] - || player_genus(GENPC_DRACONIAN) - || you.attribute[ATTR_TRANSFORMATION] == TRAN_DRAGON - || you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT)) + switch ( amulet ) { - return (true); + case AMU_CONTROLLED_FLIGHT: + return (you.duration[DUR_CONTROLLED_FLIGHT] + || player_genus(GENPC_DRACONIAN) + || you.attribute[ATTR_TRANSFORMATION] == TRAN_DRAGON + || you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT); + case AMU_CLARITY: + return (player_mutation_level(MUT_CLARITY) > 0); + case AMU_RESIST_CORROSION: + case AMU_CONSERVATION: + return (player_equip_ego_type(EQ_CLOAK, SPARM_PRESERVATION) > 0); + default: + return false; } +} - if (amulet == AMU_CLARITY && player_mutation_level(MUT_CLARITY)) +bool wearing_amulet(jewellery_type amulet, bool calc_unid) +{ + if ( extrinsic_amulet_effect(amulet) ) return (true); - - if (amulet == AMU_RESIST_CORROSION || amulet == AMU_CONSERVATION) - { - // XXX: this is hackish {dlb} - if (player_equip_ego_type( EQ_CLOAK, SPARM_PRESERVATION )) - return (true); - } - + if (you.equip[EQ_AMULET] == -1) return (false); - if (you.inv[you.equip[EQ_AMULET]].sub_type == amulet - && ( calc_unid || item_type_known(you.inv[you.equip[EQ_AMULET]]) )) - { - return (true); - } - - return (false); + const item_def& amu(you.inv[you.equip[EQ_AMULET]]); + return (amu.sub_type == amulet && (calc_unid || item_type_known(amu))); } bool player_is_airborne(void) diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 7103018c47..6cef3c124f 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -75,6 +75,8 @@ int player_wielded_item(); * called from: ability - acr - fight - food - it_use2 - item_use - items - * misc - mutation - ouch * *********************************************************************** */ + +bool extrinsic_amulet_effect(jewellery_type amulet); bool wearing_amulet(jewellery_type which_am, bool calc_unid = true); -- cgit v1.2.3-54-g00ecf