summaryrefslogtreecommitdiffstats
path: root/crawl-ref
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
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')
-rw-r--r--crawl-ref/source/item_use.cc92
-rw-r--r--crawl-ref/source/item_use.h1
-rw-r--r--crawl-ref/source/religion.cc66
3 files changed, 109 insertions, 50 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:
diff --git a/crawl-ref/source/item_use.h b/crawl-ref/source/item_use.h
index 64d33e00e2..1c79a93ecc 100644
--- a/crawl-ref/source/item_use.h
+++ b/crawl-ref/source/item_use.h
@@ -162,6 +162,7 @@ bool puton_item(int slot, bool prompt_finger = true);
bool enchant_weapon( enchant_stat_type which_stat, bool quiet = false,
int wpn = -1 );
+bool enchant_armour( int &ac_change, bool quiet, item_def &arm );
bool throw_it(bolt &pbolt, int throw_2, bool teleport=false, int acc_bonus=0,
dist *target = NULL);
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 7cff471e50..6c2bcb33c5 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -754,7 +754,7 @@ static void give_nemelex_gift()
}
}
-static bool promote_to_priest(monsters* mon)
+static bool blessing_priesthood(monsters* mon)
{
monster_type priest_type = MONS_PROGRAM_BUG;
@@ -775,6 +775,32 @@ static bool promote_to_priest(monsters* mon)
return false;
}
+static bool blessing_ac(monsters* mon)
+{
+ // Pick either the armour or the shield.
+ const int armour = mon->inv[MSLOT_ARMOUR];
+ const int shield = mon->inv[MSLOT_SHIELD];
+
+ if (armour == NON_ITEM && shield == NON_ITEM)
+ return false;
+
+ int slot;
+
+ if (armour == NON_ITEM)
+ slot = shield;
+ else if (shield == NON_ITEM)
+ slot = armour;
+ else
+ slot = (coinflip()) ? armour : shield;
+
+ item_def& arm(mitm[slot]);
+
+ int ac_change;
+
+ // And enchant it.
+ return enchant_armour(ac_change, true, arm);
+}
+
void bless_follower(god_type god,
bool (*suitable)(const monsters* mon))
{
@@ -792,13 +818,38 @@ void bless_follower(god_type god,
// 5% chance: Turn a monster into a priestly monster, if possible.
// This is currently only used for Beogh and ordinary orcs.
- if (god == GOD_BEOGH && one_chance_in(20) && mon->type == MONS_ORC)
+ if (one_chance_in(20))
+ {
+ if (god == GOD_BEOGH && mon->type == MONS_ORC
+ && blessing_priesthood(mon))
+ {
+ result = "priesthood";
+ goto blessing_done;
+ }
+ }
+
+ // 5% chance: Enchant a monster's armour or shield by one or two
+ // points, or at least uncurse it, if possible. The message doesn't
+ // make a distinction.
+ if (one_chance_in(20))
{
- promote_to_priest(mon);
- result = "priesthood";
+ bool ac_effect = blessing_ac(mon);
+
+ if (!ac_effect || coinflip())
+ {
+ if (blessing_ac(mon))
+ ac_effect = true;
+ }
+
+ if (ac_effect)
+ {
+ result = "extra defence";
+ goto blessing_done;
+ }
}
- // 95% chance: full healing.
- else
+
+ // 90% chance: full healing, optionally adding one or two extra hit
+ // points.
{
bool healing = false;
bool vigour = true;
@@ -807,11 +858,9 @@ void bless_follower(god_type god,
if (!healing || coinflip())
{
- // Full healing, plus one added hit point.
heal_monster(mon, mon->max_hit_points, true);
if (coinflip())
- // Full healing, plus another added hit point.
heal_monster(mon, mon->max_hit_points, true);
vigour = true;
@@ -825,6 +874,7 @@ void bless_follower(god_type god,
result = "extra vigour";
}
+blessing_done:
mprf(MSGCH_GOD, "%s blesses %s with %s.", god_name(god).c_str(),
blessed, result);
}