loss. Now take to-be-removed equipment in account and don't transform in the removed equipment or the stat loss or both in combination would decrease one of your stats to (below) 0. For the vampire bat transformation, this check only happens after the ability failure check, so this could be improved. In any case, it's better than dying.
Also, fix wrongly treating armour as worn when checking for stat loss by wearing.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5294 c06c8d41-db1a-0410-9941-cceddc491573
H5BVKRORNXTCJKFXQPTFWDURKSUFW24CGSJXBGZCJUP4DHMSVDBQC
JCWJWGMQIKQGSSFJUQRKNIWW3HBOJSHYDTOPPE5BWOJTIJTDYUTAC
QEEJFAETO6B2J4IWDIDCJ5UNIFNNHHG22IWF2CUJRTJJBNE47CWQC
SHSIZVHSB4RPTLGMFJXUDVHF3FTEZZYCRIH4CBZP4MXOBR3HC4QAC
QLMCSREGK2UUAPXZSZQKLZOLM4BCB7PAVCSR3DLFQS3EW3IMWQSQC
EEZCC5GUYHETFQV4KSZJSJ6BTTWZHKS7RXQ25XQ6ODGKLDD4XFRAC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
6CZYPP67SB2M3SQS3QIPJWHZY7PJIRTTBH5CLORV3AALVTJIL5MQC
J7KCPTGASQNRAKVKQ5FCXZ75E75PK7I2BB6MFSI3COWU6HRKTWSAC
P2ZCF3BBG523ZEOD6XQA4X5YEHBTWH3IM33YVHXP2SQ5POXZIH4QC
CLIEHAE2PP7ZIGLLIMYCWM4FC54KBOAN5AILOLAZJ5S26GTJM4RQC
BZMLXBTB63CXPZZPFXM4VLE7IBXPBEZ6YLM4MSNQGJR4L5IBM3OAC
TRZAZJJA5VQBJ65SO5H5DNSILIZEJHIZCBYEBHEATCT6ZSMWIFKQC
P3BAFR6LTI7HANQCRLZWJ7LRJYFPFYIG7OVZV4RZM5EAMODRJKZAC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
ASLW3Z5PAVZSWJEMMMVZT226P44EKSAD47QS72JIFJESAI3RPN3AC
CHUJFZ7HBTS6IC46OJQEMWSQV5QLF7LCPBYW5NPSEM4L6OT3PJVQC
RT56MRPFK5ISZOZMZWTXYM4H25GSVKPL7RZ3RTSWVW2TZCD2U3CQC
JEWGBHOQGDSWMLT4FZTQWUKTBJJWY5CSRAQQUOWIZ7U4QBJ6ZLBQC
O6ZMFKDI3XO2SWPNEYHIPYFDWJR4TVDP5BAATK6LVCVETQID6E7AC
KBNY5FWKTEAKABFCLPC3QFKFSVZKAGXINPCIFV6WDSWFO4VCKNTAC
I2B33Z7NZGC33AMDSSK446AZZYWKPHWLAGULVHKKZU4MVB4BNJOAC
TRCCLE5RJ4VJULBOWOI2WC3RJU7WTEGS7RRQTDQL6W5UU246LKTQC
WXSNNK2RXP3DQFAEQGQUZJHFWXJC7ZKG2WURZGL566UDM4YXFSWQC
static void _init_equipment_removal(std::set<equipment_type> &rem_stuff,
int which_trans)
{
switch (which_trans)
{
case TRAN_SPIDER:
// Spiders CAN wear soft helmets
if (you.equip[EQ_HELMET] == -1
|| !is_hard_helmet(you.inv[you.equip[EQ_HELMET]]))
{
rem_stuff.erase(EQ_HELMET);
}
break;
case TRAN_BAT:
// Bats CAN wear soft helmets.
if (you.equip[EQ_HELMET] == -1
|| !is_hard_helmet(you.inv[you.equip[EQ_HELMET]]))
{
rem_stuff.erase(EQ_HELMET);
}
break;
case TRAN_ICE_BEAST:
rem_stuff.erase(EQ_CLOAK);
// Ice beasts CAN wear soft helmets.
if (you.equip[EQ_HELMET] == -1
|| !is_hard_helmet(you.inv[you.equip[EQ_HELMET]]))
{
rem_stuff.erase(EQ_HELMET);
}
break;
case TRAN_BLADE_HANDS:
rem_stuff.erase(EQ_CLOAK);
rem_stuff.erase(EQ_HELMET);
rem_stuff.erase(EQ_BOOTS);
rem_stuff.erase(EQ_BODY_ARMOUR);
break;
case TRAN_STATUE:
rem_stuff.erase(EQ_WEAPON); // can still hold a weapon
rem_stuff.erase(EQ_CLOAK);
rem_stuff.erase(EQ_HELMET);
break;
case TRAN_AIR:
// Can't wear anything at all!
rem_stuff.insert(EQ_LEFT_RING);
rem_stuff.insert(EQ_RIGHT_RING);
rem_stuff.insert(EQ_AMULET);
break;
default:
break;
}
}
// Count the stat boosts yielded by all items to be removed, and count
// future losses (caused by the transformation) like a current stat boost,
// as well. If the sum of all bosts of a stat is equal to or greater than
// the current stat, give a message and return true.
bool check_transformation_stat_loss(const std::set<equipment_type> &remove,
int str_loss, int dex_loss, int int_loss,
bool quiet)
{
// Initialize with additional losses, if any.
int prop_str = str_loss;
int prop_dex = dex_loss;
int prop_int = int_loss;
// Check over all items to be removed.
std::set<equipment_type>::const_iterator iter;
for (iter = remove.begin(); iter != remove.end(); ++iter)
{
equipment_type e = *iter;
if (you.equip[e] == -1)
continue;
item_def item = you.inv[you.equip[e]];
if (item.base_type == OBJ_JEWELLERY)
{
if (!item_ident( item, ISFLAG_KNOW_PLUSES ))
continue;
switch (item.sub_type)
{
case RING_STRENGTH:
if (item.plus != 0)
prop_str += item.plus;
break;
case RING_DEXTERITY:
if (item.plus != 0)
prop_dex += item.plus;
break;
case RING_INTELLIGENCE:
if (item.plus != 0)
prop_int += item.plus;
break;
default:
break;
}
}
if (is_random_artefact( item ))
{
prop_str += randart_known_wpn_property(item, RAP_STRENGTH);
prop_int += randart_known_wpn_property(item, RAP_INTELLIGENCE);
prop_dex += randart_known_wpn_property(item, RAP_DEXTERITY);
}
// Since there might be multiple items whose effects cancel each other
// out while worn, if at any point in the order of checking this list
// (which is the same order as when removing items) one of your stats
// would reach 0, return true.
if (prop_str >= you.strength || prop_int >= you.intel
|| prop_dex >= you.dex)
{
if (!quiet)
{
mpr("This transformation would result in fatal stat loss!",
MSGCH_WARN);
}
return (true);
}
}
return (false);
}
rem_stuff.erase(EQ_CLOAK);
// ice beasts CAN wear soft helmets
if ( you.equip[EQ_HELMET] == -1
|| !is_hard_helmet(you.inv[you.equip[EQ_HELMET]]))
{
rem_stuff.erase(EQ_HELMET);
}
/*
* Check squares adjacent to player for given feature and return how
* many there are. If there's only one, return the dx and dy.
*/
// Check squares adjacent to player for given feature and return how
// many there are. If there's only one, return the dx and dy.
/*
Opens doors and handles some aspects of untrapping. If either move_x or
move_y are non-zero, the pair carries a specific direction for the door
to be opened (eg if you type ctrl - dir).
*/
// Opens doors and handles some aspects of untrapping. If either move_x or
// move_y are non-zero, the pair carries a specific direction for the door
// to be opened (eg if you type ctrl - dir).