summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/item_use.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-22 03:40:22 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-22 03:40:22 +0000
commiteff015ae7d0253abd240981b17ddf27008d1accd (patch)
tree18cec5a3fb880a66e7a98b8701eaf36af9270292 /crawl-ref/source/item_use.cc
parent47af3ed3cb6d78f36392830c352c0172f5a51776 (diff)
downloadcrawl-ref-eff015ae7d0253abd240981b17ddf27008d1accd.tar.gz
crawl-ref-eff015ae7d0253abd240981b17ddf27008d1accd.zip
Add a blessing to improve AC by enchanting armor or shields by one or
two points, or at least uncursing them (5% chance, to discourage killings for armor; the probability of healing has been dropped to 90%). In the process, split out and generalize the code to enchant armor to not be so player-specific; now, handle_enchant_armour() contains the player-specific portion, and enchant_armour() contains the rest. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3798 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/item_use.cc')
-rw-r--r--crawl-ref/source/item_use.cc92
1 files changed, 50 insertions, 42 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index d843830b9d..a3206ca0a6 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -81,7 +81,7 @@
#include "xom.h"
static bool drink_fountain();
-static bool enchant_armour(int item_slot = -1);
+static bool handle_enchant_armour( int item_slot = -1 );
static int _fire_prompt_for_item(std::string& err);
static bool _fire_validate_item(int selected, std::string& err);
@@ -3915,51 +3915,31 @@ bool enchant_weapon( enchant_stat_type which_stat, bool quiet, int wpn )
return (true);
}
-static bool enchant_armour( int item_slot )
+bool enchant_armour( int &ac_change, bool quiet, item_def &arm )
{
- if (item_slot == -1)
- item_slot = prompt_invent_item( "Enchant which item?", MT_INVLIST,
- OSEL_ENCH_ARM, true, true, false );
-
- if (item_slot == PROMPT_ABORT)
- {
- canned_msg( MSG_OK );
- return (false);
- }
-
- item_def& arm(you.inv[item_slot]);
+ ac_change = 0;
// cannot be enchanted nor uncursed
if (!is_enchantable_armour(arm, true))
- {
- canned_msg( MSG_NOTHING_HAPPENS );
return (false);
- }
bool is_cursed = item_cursed(arm);
-
+
// Turn hides into mails where applicable.
// NOTE: It is assumed that armour which changes in this way does
// not change into a form of armour with a different evasion modifier.
- if (arm.sub_type == ARM_DRAGON_HIDE
- || arm.sub_type == ARM_ICE_DRAGON_HIDE
- || arm.sub_type == ARM_STEAM_DRAGON_HIDE
- || arm.sub_type == ARM_MOTTLED_DRAGON_HIDE
- || arm.sub_type == ARM_STORM_DRAGON_HIDE
- || arm.sub_type == ARM_GOLD_DRAGON_HIDE
- || arm.sub_type == ARM_SWAMP_DRAGON_HIDE
- || arm.sub_type == ARM_TROLL_HIDE)
+ if (armour_is_hide(arm, false))
{
mprf("%s glows purple and changes!",
arm.name(DESC_CAP_YOUR).c_str());
-
+
+ ac_change = arm.plus;
hide2armour(arm);
+ ac_change = arm.plus - ac_change;
if (is_cursed)
do_uncurse_item( arm );
- you.redraw_armour_class = 1;
-
// no additional enchantment
return (true);
}
@@ -3970,33 +3950,61 @@ static bool enchant_armour( int item_slot )
{
if (is_cursed)
{
- mprf("%s glows silver for a moment.",
- arm.name(DESC_CAP_YOUR).c_str());
-
+ if (!quiet)
+ {
+ mprf("%s glows silver for a moment.",
+ arm.name(DESC_CAP_YOUR).c_str());
+ }
+
do_uncurse_item( arm );
return (true);
}
else
- {
- canned_msg( MSG_NOTHING_HAPPENS );
return (false);
- }
}
// output message before changing enchantment and curse status
- mprf("%s glows green for a moment.",
- arm.name(DESC_CAP_YOUR).c_str());
+ if (!quiet)
+ {
+ mprf("%s glows green for a moment.",
+ arm.name(DESC_CAP_YOUR).c_str());
+ }
arm.plus++;
+ ac_change++;
if (is_cursed)
do_uncurse_item( arm );
-
- you.redraw_armour_class = 1;
+
xom_is_stimulated(16);
return (true);
}
+static bool handle_enchant_armour( int item_slot )
+{
+ if (item_slot == -1)
+ item_slot = prompt_invent_item( "Enchant which item?", MT_INVLIST,
+ OSEL_ENCH_ARM, true, true, false );
+
+ if (item_slot == PROMPT_ABORT)
+ {
+ canned_msg( MSG_OK );
+ return (false);
+ }
+
+ item_def& arm(you.inv[item_slot]);
+
+ int ac_change;
+ bool result = enchant_armour(ac_change, false, arm);
+
+ if (!result)
+ canned_msg( MSG_NOTHING_HAPPENS );
+ else if (ac_change)
+ you.redraw_armour_class = true;
+
+ return result;
+}
+
static void handle_read_book( int item_slot )
{
item_def& book(you.inv[item_slot]);
@@ -4047,7 +4055,7 @@ static bool scroll_modify_item(const scroll_type scroll)
{
int item_slot = prompt_invent_item( "Use on which item?", MT_INVLIST,
OSEL_ANY, true, true, false );
-
+
if (item_slot == PROMPT_ABORT)
{
canned_msg( MSG_OK );
@@ -4055,7 +4063,7 @@ static bool scroll_modify_item(const scroll_type scroll)
}
item_def &item = you.inv[item_slot];
-
+
switch (scroll)
{
case SCR_IDENTIFY:
@@ -4080,7 +4088,7 @@ static bool scroll_modify_item(const scroll_type scroll)
if (is_enchantable_armour(item, true))
{
// might still fail because of already high enchantment
- if (enchant_armour(item_slot))
+ if (handle_enchant_armour(item_slot))
return (true);
return (false);
}
@@ -4418,7 +4426,7 @@ void read_scroll( int slot )
if ( !item_type_known(scroll) )
id_the_scroll = scroll_modify_item(which_scroll);
else
- enchant_armour(-1);
+ handle_enchant_armour(-1);
break;
case SCR_CURSE_ARMOUR: