summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/itemprop.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-16 19:20:45 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-16 19:20:45 +0000
commitcb1a4eab762f953396c49c15fb178e2f47d56105 (patch)
tree0baa86d5474f887f880a2cb447936cbb1668bd11 /crawl-ref/source/itemprop.cc
parent5fc6dd64feee1a620b1b5141ca3efa4ef51766f2 (diff)
downloadcrawl-ref-cb1a4eab762f953396c49c15fb178e2f47d56105.tar.gz
crawl-ref-cb1a4eab762f953396c49c15fb178e2f47d56105.zip
Yet another tutorial update
... and Sif Muna finally gets those other titles. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2007 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r--crawl-ref/source/itemprop.cc104
1 files changed, 104 insertions, 0 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index 46dea61357..a74090d5fb 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -1994,6 +1994,110 @@ bool gives_ability( const item_def &item )
return false;
}
+bool gives_resistance( 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_PROTECTION_FROM_FIRE
+ && item.sub_type <= RING_PROTECTION_FROM_COLD
+ || item.sub_type == RING_SEE_INVISIBLE
+ || item.sub_type >= RING_LIFE_PROTECTION
+ && item.sub_type <= RING_TELEPORT_CONTROL
+ || item.sub_type == RING_TELEPORTATION
+ || item.sub_type == RING_SUSTAIN_ABILITIES)
+ {
+ 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 && item.sub_type != AMU_INACCURACY)
+ 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;
+
+ const int ego = get_armour_ego_type( item );
+ if (ego >= SPARM_FIRE_RESISTANCE && ego <= SPARM_SEE_INVISIBLE
+ || ego == SPARM_RESISTANCE || ego == SPARM_POSITIVE_ENERGY)
+ {
+ return true;
+ }
+ }
+ case OBJ_STAVES:
+ {
+ // unwielded weapon
+ item_def *weap = you.slot_item(EQ_WEAPON);
+ if (!weap || (*weap).slot != item.slot)
+ return false;
+
+ if (item.sub_type >= STAFF_FIRE && item.sub_type <= STAFF_POISON
+ || item.sub_type == STAFF_AIR)
+ {
+ return true;
+ }
+ return false;
+ }
+ default:
+ return false;
+ }
+
+ if (!is_random_artefact(item))
+ return false;
+
+ // check for randart resistances
+ for (int rap = RAP_FIRE; rap <= RAP_CAN_TELEPORT; rap++)
+ {
+ if (rap == RAP_MAGIC || rap >= RAP_INVISIBLE && rap != RAP_CAN_TELEPORT)
+ continue;
+
+ if (randart_wpn_property( item, rap ))
+ return true;
+ }
+
+ return false;
+}
+
int item_mass( const item_def &item )
{
int unit_mass = 0;