mons_throw() should have been using the mslot of the weapon, not weapon's mitm index.
Introduces the new functions get_mon_equip_slot() and item_to_mslot().
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7530 c06c8d41-db1a-0410-9941-cceddc491573
MFP3WAGO2JIOT4QSEYPM4OJV5NVXMUOPL75OIE7YZ5RWOYQPIZ7AC
SH5BS5AJPUFPXQHM5MZPIY3CCVT4EAIRLSAQWZYL5WX2J7FPBSQQC
QS3ZRS3E6KL3YJHPKYEWCWJYRBJSXD5OOYF6Y25HZVECGPJRDB5QC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
T7CUIVICB74342RA32BR37T36FOX4RBSQIB5PNOHTGTGUYGDKSTQC
NVK2OISSU4XF2CGSK2BAWZE2OPCLTXYHNSE6UDJ5M54EHY2I7BLAC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
mon_inv_type item_to_mslot(const item_def &item)
{
switch(item.base_type)
{
case OBJ_WEAPONS:
return MSLOT_WEAPON;
case OBJ_MISSILES:
return MSLOT_MISSILE;
case OBJ_ARMOUR:
return equip_slot_to_mslot(get_armour_slot(item));
case OBJ_WANDS:
return MSLOT_WAND;
case OBJ_SCROLLS:
return MSLOT_SCROLL;
case OBJ_POTIONS:
return MSLOT_POTION;
case OBJ_MISCELLANY:
return MSLOT_MISCELLANY;
case OBJ_GOLD:
return MSLOT_GOLD;
default:
return NUM_MONSTER_SLOTS;
}
}
}
mon_inv_type get_mon_equip_slot(const monsters* mon, const item_def &item)
{
ASSERT(mon->alive());
mon_inv_type slot = item_to_mslot(item);
if (slot == NUM_MONSTER_SLOTS)
return NUM_MONSTER_SLOTS;
if (mon->mslot_item(slot) == &item)
return slot;
if (slot == MSLOT_WEAPON && mon->mslot_item(MSLOT_ALT_WEAPON) == &item)
return MSLOT_ALT_WEAPON;
return NUM_MONSTER_SLOTS;