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
AZ2RCXNVULJUSCBDBK3VARTUCTPEJXHTA7ALP73S4EXLJB6YYB5QC
MDAJYB6STTZPNHRQ2X66MMMSONMKXTESLHJSFPGN7H3D3TOVBAVAC
5PTCSQA4RA7CRCIFQQROQZUJHVNWCS33ZWCSGYSBXSJUAKGVCO4QC
RIIO4BI64ECFXSRLBP3RA24QOPYXJVWMSFHLNTKUZS5YCLISLVJQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
K27R6ZMYMKVNXIV7K3QU2NXRVOGQRLMR6TI6ZQQSVKXVKS76NLSQC
6INGHIA3J7XER4L7OZHGU4RR3QTRWISMXHD3AZQK6MQ3VDADBVAAC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
6ZZO2QBB46RZM6OXVS7OIKC5M3SEAULSSJFXW5PJG556JDKKUHWAC
CE6FLTWU5PYFBSGVTIJXQXRMHOIHQ3VJCKHQVIMUUAIFHQ73X7NAC
CIPVRZGLOZHCERK6YPOBV3P2E4IAB4H6D5EHLRQE2O5E4P4VCBUAC
KFULGQQOHWUTXOM3BXCCYPGGVGGY4Z6265XUFRCBPNLTZAEHJZSQC
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);
}
// 95% chance: full healing.
else
// 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))
{
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;
}
}
// 90% chance: full healing, optionally adding one or two extra hit
// points.
if (item_slot == PROMPT_ABORT)
{
canned_msg( MSG_OK );
return (false);
}
item_def& arm(you.inv[item_slot]);
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))
}
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;