summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/invent.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-05-02 17:50:19 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-05-02 17:50:19 +0000
commit1b49ddb74f8d39dd07b712602333fc28810a4f40 (patch)
tree8dd67f254ab14357aa312aeb47fe591df6d6367e /crawl-ref/source/invent.cc
parentfb58bd0b0b1ebc50a270c3fcd251631737d3c53c (diff)
downloadcrawl-ref-1b49ddb74f8d39dd07b712602333fc28810a4f40.tar.gz
crawl-ref-1b49ddb74f8d39dd07b712602333fc28810a4f40.zip
Add new command for evoking non-wielded items, placed on 'V'.
* Also applies to wand, and will soon replace 'Z'. * Decks, rods, and weapons of reaching still need to be wielded ('v'). * The tiles tooltips will need to be adjusted. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9718 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/invent.cc')
-rw-r--r--crawl-ref/source/invent.cc103
1 files changed, 103 insertions, 0 deletions
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index 9208943f4b..21c1390090 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -459,6 +459,8 @@ static std::string _no_selectables_message(int item_selector)
return("You aren't carrying any items that might be thrown or fired.");
case OSEL_BUTCHERY:
return("You aren't carrying any sharp implements.");
+ case OSEL_EVOKABLE:
+ return("You aren't carrying any items that can be evoked.");
}
return("You aren't carrying any such object.");
@@ -1017,6 +1019,9 @@ static bool _item_class_selected(const item_def &i, int selector)
case OSEL_RECHARGE:
return (item_is_rechargeable(i, true));
+ case OSEL_EVOKABLE:
+ return (item_is_evokable(i, true));
+
case OSEL_ENCH_ARM:
return (is_enchantable_armour(i, true, true));
@@ -1689,3 +1694,101 @@ bool prompt_failed(int retval, std::string msg)
return (true);
}
+
+bool item_is_evokable(const item_def &item, bool known, bool msg)
+{
+ const bool wielded = (you.equip[EQ_WEAPON] == item.link);
+
+ switch (item.base_type)
+ {
+ case OBJ_WANDS:
+ if (item.plus2 == ZAPCOUNT_EMPTY)
+ {
+ if (msg)
+ mpr("This wand has no charges.");
+ return (false);
+ }
+ return (true);
+
+ case OBJ_WEAPONS:
+ if (!wielded && !msg)
+ return (false);
+
+ if (get_weapon_brand(item) == SPWPN_REACHING
+ && item_type_known(item))
+ {
+ if (!wielded)
+ {
+ if (msg)
+ mpr("That item can only be evoked when wielded.");
+ return (false);
+ }
+ return (true);
+ }
+
+ if (is_fixed_artefact(item))
+ {
+ switch (item.special)
+ {
+ case SPWPN_SCEPTRE_OF_ASMODEUS:
+ case SPWPN_STAFF_OF_WUCAD_MU:
+ case SPWPN_STAFF_OF_DISPATER:
+ case SPWPN_STAFF_OF_OLGREB:
+ if (!wielded)
+ {
+ if (msg)
+ mpr("That item can only be evoked when wielded.");
+ return (false);
+ }
+ return (true);
+
+ default:
+ return (false);
+ }
+ }
+ if (msg)
+ mpr("That item cannot be evoked!");
+ return (false);
+
+ case OBJ_STAVES:
+ if (item_is_rod(item)
+ || !known && !item_type_known(item)
+ || item.sub_type == STAFF_CHANNELING
+ && item_type_known(item))
+ {
+ if (!wielded)
+ {
+ if (msg)
+ mpr("That item can only be evoked when wielded.");
+ return (false);
+ }
+ return (true);
+ }
+ if (msg)
+ mpr("That item cannot be evoked!");
+ return (false);
+
+ case OBJ_MISCELLANY:
+ if (is_deck(item))
+ {
+ if (!wielded)
+ {
+ if (msg)
+ mpr("That item can only be evoked when wielded.");
+ return (false);
+ }
+ return (true);
+ }
+
+ if (item.sub_type != MISC_LANTERN_OF_SHADOWS
+ && item.sub_type != MISC_EMPTY_EBONY_CASKET)
+ {
+ return (true);
+ }
+ // else fall through
+ default:
+ if (msg)
+ mpr("That item cannot be evoked!");
+ return (false);
+ }
+}