summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/item_use.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-10 21:51:19 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-10 21:51:19 +0000
commita24959dec217aab9e3e2ad440801811c21cec068 (patch)
tree44c85785be6a30cdec795bd0289d656bd2944687 /crawl-ref/source/item_use.cc
parent656ec74670b76a00e7e17854c27bc1aa2e6d3215 (diff)
downloadcrawl-ref-a24959dec217aab9e3e2ad440801811c21cec068.tar.gz
crawl-ref-a24959dec217aab9e3e2ad440801811c21cec068.zip
' will now swap to miscellaneous items (except for runes) but not
missiles. [1847482] git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3037 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/item_use.cc')
-rw-r--r--crawl-ref/source/item_use.cc27
1 files changed, 15 insertions, 12 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 894a1723bf..c9d4af14c7 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -179,8 +179,6 @@ bool can_wield(const item_def *weapon, bool say_reason,
bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
{
- int item_slot = 0;
-
if (inv_count() < 1)
{
canned_msg(MSG_NOTHING_CARRIED);
@@ -198,26 +196,31 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
you.duration[DUR_SURE_BLADE] = 0;
}
+ int item_slot = 0; // default is 'a'
+
if (auto_wield)
{
- if (you.equip[EQ_WEAPON] == 0) // ie. weapon is currently 'a'
- item_slot = 1;
- else
- item_slot = 0;
- if (slot != -1) item_slot = slot;
+ if ( item_slot == you.equip[EQ_WEAPON] )
+ item_slot = 1; // backup is 'b'
+
+ if (slot != -1) // allow external override
+ item_slot = slot;
}
- bool force_unwield =
- you.inv[item_slot].base_type != OBJ_WEAPONS
- && you.inv[item_slot].base_type != OBJ_MISSILES
- && you.inv[item_slot].base_type != OBJ_STAVES;
+ // If the swap slot has a bad (but valid) item in it,
+ // the swap will be to bare hands.
+ const bool good_swap =
+ you.inv[item_slot].base_type == OBJ_WEAPONS
+ || you.inv[item_slot].base_type == OBJ_STAVES
+ || (you.inv[item_slot].base_type == OBJ_MISCELLANY
+ && you.inv[item_slot].sub_type != MISC_RUNE_OF_ZOT);
// Reset the warning counter.
you.received_weapon_warning = false;
// Prompt if not using the auto swap command, or if the swap slot
// is empty.
- if (!auto_wield || !is_valid_item(you.inv[item_slot]) || force_unwield)
+ if (!auto_wield || !is_valid_item(you.inv[item_slot]) || !good_swap)
{
if (!auto_wield)
item_slot = prompt_invent_item(