From 054c713cec71c3010b1ac3eb0848f2b601db982f Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Wed, 15 Aug 2007 21:32:33 +0000 Subject: More stuff for the tutorial: - Enhanced handling of spellbooks and artefacts. - Feature descriptions now cover altars. - Added monster descriptions (out of depth and brands). Also: - space-only inscription counts as no inscription - ring of teleportation autoID's if no teleport randart In my last commit I forgot to mention that the descriptions were suggested by Richard Gould, and I'd like to give credit where credit is due. :) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2005 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/itemprop.cc | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'crawl-ref/source/itemprop.cc') diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 65f87c3a50..46dea61357 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -1918,6 +1918,82 @@ int property( const item_def &item, int prop_type ) return (0); } +bool gives_ability( const item_def &item ) +{ + if (!item_type_known(item)) + return false; + + switch (item.base_type) + { + case OBJ_WEAPONS: + { + // unwielded weapon + item_def *weap = you.slot_item(EQ_WEAPON); + if (!weap || (*weap).slot != item.slot) + return false; + break; + } + case OBJ_JEWELLERY: + { + if (item.sub_type < NUM_RINGS) + { + // unworn ring + item_def *lring = you.slot_item(EQ_LEFT_RING); + item_def *rring = you.slot_item(EQ_RIGHT_RING); + if ((!lring || (*lring).slot != item.slot) + && (!rring || (*rring).slot != item.slot)) + { + return false; + } + + if (item.sub_type == RING_TELEPORTATION + || item.sub_type == RING_LEVITATION + || item.sub_type == RING_INVISIBILITY) + { + return true; + } + } + else + { + // unworn amulet + item_def *amul = you.slot_item(EQ_AMULET); + if (!amul || (*amul).slot != item.slot) + return false; + + if (item.sub_type == AMU_RAGE) + return true; + } + break; + } + case OBJ_ARMOUR: + { + const equipment_type eq = get_armour_slot(item); + if (eq == EQ_NONE) + return false; + + // unworn armour + item_def *arm = you.slot_item(eq); + if (!arm || (*arm).slot != item.slot) + return false; + break; + } + default: + return false; + } + + if (!is_random_artefact(item)) + return false; + + // check for evokable randart properties + for (int rap = RAP_INVISIBLE; rap <= RAP_MAPPING; rap++) + { + if (randart_wpn_property( item, rap )) + return true; + } + + return false; +} + int item_mass( const item_def &item ) { int unit_mass = 0; -- cgit v1.2.3-54-g00ecf