by two points (either this or armor enchantment blessing can occur, with 5% rarity). Whether to-hit or to-damage is chosen is random. Split handling of weapon enchantment into enchant_weapon() for the generic item routines, and handle_enchant_weapon() for the player-specific routines. Furthermore, make enchant_weapon() and enchant_armour() more similar in terms of structure.
Also, in bless_follower(), store the blessing description and monster name in std::strings instead of const char*'s.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3839 c06c8d41-db1a-0410-9941-cceddc491573
VEPHAIXR3GSPHBLOW5DWFFU4ULEMVWRQG4G5PKSKRA2I6RHYROUAC
WTDOXPAB52K32FGR3Q5SFIR2UQLZ7KBJJW4WSYX5GUHZUY5NKEXAC
RAONQV2CVEGAZ66R4BZ2XB4YNM423NN3HDOA6I5YTHVLCN3I23CQC
UPNIIOG2FHJ4WFGGPZBFYK3GYONL3Z5LO4FEYRJPE7WHNI5R7UZQC
TPSWWHKYGM5IZZUBDWBH5RSD6W3F6H2F3Q4QDU2HSIXIRTDKX3QAC
RIIO4BI64ECFXSRLBP3RA24QOPYXJVWMSFHLNTKUZS5YCLISLVJQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
AZ2RCXNVULJUSCBDBK3VARTUCTPEJXHTA7ALP73S4EXLJB6YYB5QC
K27R6ZMYMKVNXIV7K3QU2NXRVOGQRLMR6TI6ZQQSVKXVKS76NLSQC
4F6JKMC5KRITQNYVYC7AAGAOSNDDXRBAXQTHWI5RDZT6LYNXQJQQC
6INGHIA3J7XER4L7OZHGU4RR3QTRWISMXHD3AZQK6MQ3VDADBVAAC
LKZLCEOXC54N7VPFQ7LCBBWKUABM2ETL35ZOJXWS7TXLPOI7ECKQC
M2EUGZPKR6XTZSLQYDO7CDBBR2WPPMCBIBKJSZW5P7KYUOUPZSZQC
HSJF2F2CBK3VSRVYJKMIIJNON67XULQVA4IPXUCPWY32QHDYW4CAC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
MDAJYB6STTZPNHRQ2X66MMMSONMKXTESLHJSFPGN7H3D3TOVBAVAC
6ZZO2QBB46RZM6OXVS7OIKC5M3SEAULSSJFXW5PJG556JDKKUHWAC
CIPVRZGLOZHCERK6YPOBV3P2E4IAB4H6D5EHLRQE2O5E4P4VCBUAC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
const char *blessed = (follower && !mons_near(follower))
? "your follower"
: mon->name(DESC_NOCAP_THE).c_str();
const char *result;
std::string blessed = (follower && !mons_near(follower))
? "your follower"
: mon->name(DESC_NOCAP_THE).c_str();
std::string result;
// only equipped items should be affected
// if (!item_is_equipped(wpn))
// return (false);
// artefacts cannot be enchanted (missiles can't be artefacts)
if (wpn.base_type == OBJ_WEAPONS
&& (is_fixed_artefact( wpn )
|| is_random_artefact( wpn )))
{
return (uncurse && item_cursed( wpn )); // ?EW may uncurse artefacts
}
// Nor can highly enchanted items (missiles only have one stat)
if ( wpn.plus >= 9 ||
(wpn.base_type == OBJ_WEAPONS && wpn.plus2 >= 9) )
{
return (uncurse && item_cursed( wpn )); // ?EW may uncurse items
}
return (true);
}
if (wpn == -1)
wpn = you.equip[ EQ_WEAPON ];
bool affected = true;
int enchant_level;
if (wpn == -1
|| (you.inv[ wpn ].base_type != OBJ_WEAPONS
&& you.inv[ wpn ].base_type != OBJ_MISSILES))
// cannot be enchanted nor uncursed
if (!is_enchantable_weapon(wpn, true))
if (which_stat == ENCHANT_TO_HIT)
enchant_level = item.plus;
else
enchant_level = item.plus2;
// artefacts can't be enchanted, but scrolls still remove curses
if (item.base_type == OBJ_WEAPONS
&& (is_fixed_artefact( you.inv[wpn] )
|| is_random_artefact( you.inv[wpn] )))
{
affected = false;
}
// if it isn't affected by the enchantment, it will still
// be uncursed.
if (!affected)
// Even if not affected, it may be uncursed.
if (!is_enchantable_weapon(wpn, false)
|| enchant_level >= 4 && random2(9) < enchant_level)
}
static bool handle_enchant_weapon( enchant_stat_type which_stat,
bool quiet, int item_slot )
{
if (item_slot == -1)
item_slot = you.equip[ EQ_WEAPON ];
if (item_slot == -1)
return (false);
item_def& wpn(you.inv[item_slot]);
bool result = enchant_weapon(which_stat, quiet, wpn);
you.wield_change = true;
return result;