summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-02-18 15:51:08 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-02-18 15:51:08 +0000
commita59025b069d3d08cfa7c5ccd21d3b0ae116da71c (patch)
treec15ea1bf8d4491edc73efef473413ddfc30a09ff /crawl-ref/source
parente3c41fc21fc88f1e1edb67992a7cb0bbe68abe83 (diff)
downloadcrawl-ref-a59025b069d3d08cfa7c5ccd21d3b0ae116da71c.tar.gz
crawl-ref-a59025b069d3d08cfa7c5ccd21d3b0ae116da71c.zip
First batch of Paul's patches:
1896018: cycle ammo with '(' 1895278: no (v)iewing of unreadable books 1895075: cancel Ely's abilities without cost Fix 1894920: fix overly long dungeon overview Also fix 1884145: weapon swap ignoring {!w} git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3441 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/abl-show.cc6
-rw-r--r--crawl-ref/source/acr.cc15
-rw-r--r--crawl-ref/source/command.cc7
-rw-r--r--crawl-ref/source/describe.cc17
-rw-r--r--crawl-ref/source/enum.h1
-rw-r--r--crawl-ref/source/item_use.cc46
-rw-r--r--crawl-ref/source/overmap.cc7
-rw-r--r--crawl-ref/source/spl-book.cc2
-rw-r--r--crawl-ref/source/spl-book.h2
9 files changed, 72 insertions, 31 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index ecf933fe8f..e994554ca0 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -1603,7 +1603,7 @@ static bool do_ability(const ability_def& abil)
case ABIL_ELYVILON_LESSER_HEALING:
if (!cast_healing( 3 + (you.skills[SK_INVOCATIONS] / 6) ))
- break;
+ return false;
exercise( SK_INVOCATIONS, 1 );
break;
@@ -1615,7 +1615,7 @@ static bool do_ability(const ability_def& abil)
case ABIL_ELYVILON_HEALING:
if (!cast_healing( 10 + (you.skills[SK_INVOCATIONS] / 3) ))
- break;
+ return false;
exercise( SK_INVOCATIONS, 3 + random2(5) );
break;
@@ -1629,7 +1629,7 @@ static bool do_ability(const ability_def& abil)
case ABIL_ELYVILON_GREATER_HEALING:
if (!cast_healing( 20 + you.skills[SK_INVOCATIONS] * 2 ))
- break;
+ return false;
exercise( SK_INVOCATIONS, 6 + random2(10) );
break;
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index bea7f1e501..aa09db7636 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1222,6 +1222,7 @@ static bool cmd_is_repeatable(command_type cmd, bool is_again = false)
case CMD_INSCRIBE_ITEM:
case CMD_TOGGLE_AUTOPRAYER:
case CMD_MAKE_NOTE:
+ case CMD_CYCLE_QUIVER_FORWARD:
mpr("You can't repeat that command.");
return false;
@@ -2257,6 +2258,18 @@ void process_command( command_type cmd )
macro_add_query();
break;
+ case CMD_CYCLE_QUIVER_FORWARD:
+ {
+ const int cur = you.quiver[get_quiver_type()];
+ if (cur != ENDOFPACK)
+ {
+ const int next = get_fire_item_index((cur+1) % ENDOFPACK, true, false);
+ you.quiver[get_quiver_type()] = next;
+ you.quiver_change = true;
+ }
+ break;
+ }
+
case CMD_LIST_WEAPONS:
list_weapons();
break;
@@ -3302,8 +3315,8 @@ command_type keycode_to_command( keycode_type key )
case '{': return CMD_INSCRIBE_ITEM;
case '[': return CMD_LIST_ARMOUR;
case ']': return CMD_LIST_EQUIPMENT;
+ case '(': return CMD_CYCLE_QUIVER_FORWARD;
case ')': return CMD_LIST_WEAPONS;
- case '(': return CMD_LIST_WEAPONS;
case '\\': return CMD_DISPLAY_KNOWN_OBJECTS;
case '\'': return CMD_WEAPON_SWAP;
case '`': return CMD_PREV_CMD_AGAIN;
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index cb9ec35c6f..848ce8ebed 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -1593,7 +1593,8 @@ void list_commands(bool wizard, int hotkey, bool do_redraw_screen)
"<h>Player Character Information:\n"
"<w>@</w> : display character status\n"
"<w>[</w> : display worn armour\n"
- "<w>(</w> : display current weapons (also <w>)</w>)\n"
+ "<w>(</w> : cycle current ammunition\n"
+ "<w>)</w> : display current weapons\n"
"<w>\"</w> : display worn jewellery\n"
"<w>C</w> : display experience info\n"
"<w>^</w> : show religion screen\n"
@@ -1611,8 +1612,7 @@ void list_commands(bool wizard, int hotkey, bool do_redraw_screen)
"<w>;</w> : examine occupied tile\n"
"<w>x</w> : eXamine surroundings/targets\n"
"<w>X</w> : eXamine level map\n"
- "<w>O</w> : show dungeon Overview\n"
- " \n",
+ "<w>O</w> : show dungeon Overview\n",
true, true, cmdhelp_textfilter,45);
cols.add_formatted(
@@ -1677,7 +1677,6 @@ void list_commands(bool wizard, int hotkey, bool do_redraw_screen)
cols.add_formatted(
1,
" \n"
- " \n"
"Crawl usually considers every item it\n"
"sees as a stash. When using a value\n"
"different from <green>stash_tracking = all</green>, you\n"
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 829a04fe43..00edf93c78 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -1621,6 +1621,10 @@ std::string get_item_description( const item_def &item, bool verbose,
break;
case OBJ_BOOKS:
+ if (! player_can_read_spellbook( item ))
+ description << "This book is beyond your current level of understanding.$$";
+ break;
+
case OBJ_SCROLLS:
case OBJ_POTIONS:
case OBJ_ORBS:
@@ -1686,7 +1690,8 @@ void describe_feature_wide(int x, int y)
getch();
}
-static void show_item_description(const item_def &item)
+// Return true if spells can be shown to player
+static bool show_item_description(const item_def &item)
{
clrscr();
@@ -1697,6 +1702,8 @@ static void show_item_description(const item_def &item)
if (item.has_spells())
{
+ if (item.base_type == OBJ_BOOKS && !player_can_read_spellbook( item ))
+ return false;
formatted_string fs;
item_def dup = item;
spellbook_contents( dup,
@@ -1705,7 +1712,10 @@ static void show_item_description(const item_def &item)
: RBOOK_USE_STAFF,
&fs );
fs.display(2, -2);
+ return true;
}
+
+ return false;
}
static bool describe_spells(const item_def &item)
@@ -1739,8 +1749,9 @@ void describe_item( item_def &item, bool allow_inscribe )
{
for (;;)
{
- show_item_description(item);
- if (item.has_spells())
+ const bool spells_shown = show_item_description(item);
+
+ if (spells_shown)
{
cgotoxy(1, wherey());
textcolor(LIGHTGREY);
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 7eb992672c..cc598900ab 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -446,6 +446,7 @@ enum command_type
CMD_REMOVE_ARMOUR,
CMD_WEAR_JEWELLERY,
CMD_REMOVE_JEWELLERY,
+ CMD_CYCLE_QUIVER_FORWARD,
CMD_LIST_WEAPONS,
CMD_LIST_ARMOUR,
CMD_LIST_JEWELLERY,
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 34993cbd01..e0cbce7b0e 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -190,12 +190,6 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
if (!can_wield(NULL, true))
return (false);
- if (you.duration[DUR_SURE_BLADE])
- {
- mpr("The bond with your blade fades away.");
- you.duration[DUR_SURE_BLADE] = 0;
- }
-
int item_slot = 0; // default is 'a'
if (auto_wield)
@@ -215,9 +209,6 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
|| (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 (item_slot != PROMPT_GOT_SPECIAL &&
@@ -237,10 +228,35 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
canned_msg( MSG_OK );
return (false);
}
- else if (item_slot == PROMPT_GOT_SPECIAL) // '-' or bare hands
+ else if (item_slot == you.equip[EQ_WEAPON])
+ {
+ mpr("You are already wielding that!");
+ return (true);
+ }
+
+ // now we really change weapons (most likely, at least)
+ if (you.duration[DUR_SURE_BLADE])
+ {
+ mpr("The bond with your blade fades away.");
+ you.duration[DUR_SURE_BLADE] = 0;
+ }
+ // Reset the warning counter.
+ you.received_weapon_warning = false;
+
+ if (item_slot == PROMPT_GOT_SPECIAL) // '-' or bare hands
{
if (you.equip[EQ_WEAPON] != -1)
{
+ // can we safely unwield this item?
+ if (has_warning_inscription(you.inv[you.equip[EQ_WEAPON]], OPER_WIELD))
+ {
+ std::string prompt = "Really unwield ";
+ prompt += you.inv[you.equip[EQ_WEAPON]].name(DESC_INVENTORY);
+ prompt += '?';
+ if (!yesno(prompt.c_str(), false, 'n'))
+ return (false);
+ }
+
if (!unwield_item(show_weff_messages))
return (false);
@@ -256,15 +272,13 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
return (true);
}
- if (item_slot == you.equip[EQ_WEAPON])
- {
- mpr("You are already wielding that!");
- return (true);
- }
-
if (!can_wield(&you.inv[item_slot], true))
return (false);
+ // for non-auto_wield cases checked above
+ if (auto_wield && !check_warning_inscriptions(you.inv[item_slot], OPER_WIELD))
+ return (false);
+
if (!safe_to_remove_or_wear(you.inv[item_slot], false))
return (false);
diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc
index c1fb568ca8..121810fb29 100644
--- a/crawl-ref/source/overmap.cc
+++ b/crawl-ref/source/overmap.cc
@@ -325,7 +325,8 @@ std::string overview_description_string()
disp += shoptype_to_string(ci_shops->second);
++column_count;
}
- disp += "\n";
+ if (!shops_present.empty())
+ disp += "\n";
// print portals
if ( !portals_present.empty() )
@@ -420,13 +421,13 @@ std::string overview_description_string()
disp += depth_str;
disp += ":</white> ";
disp += get_level_annotation(li);
- disp += + "\n";
+ disp += "\n";
}
}
}
}
- return disp;
+ return disp.substr(0, disp.find_last_not_of('\n')+1);
}
template <typename Z, typename Key>
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index 33e842d477..839070e53a 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -1000,7 +1000,7 @@ static int which_spellbook( void )
// Returns false if the player cannot read/memorize from the book,
// and true otherwise. -- bwr
-static bool player_can_read_spellbook( const item_def &book )
+bool player_can_read_spellbook( const item_def &book )
{
if (book.base_type != OBJ_BOOKS)
return (true);
diff --git a/crawl-ref/source/spl-book.h b/crawl-ref/source/spl-book.h
index d67023eaeb..8558ebec32 100644
--- a/crawl-ref/source/spl-book.h
+++ b/crawl-ref/source/spl-book.h
@@ -51,6 +51,8 @@ int read_book( item_def &item, read_book_action_type action );
bool player_can_memorise(const item_def &book);
bool learn_spell(int book = -1);
+bool player_can_read_spellbook( const item_def &book );
+
spell_type which_spell_in_book(int sbook_type, int spl);
// returns amount practised (or -1 for abort)