polymorphing worn items (trunk only)

From a bug report.  That's hard to fix in the general case because armor
and tools might not fit back into the same equipment slot, but most other
types of worn items can be re-worn after being transformed.  This makes
any transformed worn item stay worn if it is wearable in the same slot.
This commit is contained in:
nethack.rankin
2006-11-28 05:06:13 +00:00
parent 59354953cc
commit 8d86a87a7b
6 changed files with 116 additions and 44 deletions

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)worn.c 3.5 2005/04/06 */
/* SCCS Id: @(#)worn.c 3.5 2005/11/27 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -128,6 +128,68 @@ register struct obj *obj;
update_inventory();
}
/* return a bitmask of the equipment slot(s) a given item might be worn in */
long
wearslot(obj)
struct obj *obj;
{
int otyp = obj->otyp;
/* practically any item can be wielded or quivered; it's up to
our caller to handle such things--we assume "normal" usage */
long res = 0L; /* default: can't be worn anywhere */
switch (obj->oclass) {
case AMULET_CLASS:
res = W_AMUL; /* WORN_AMUL */
break;
case RING_CLASS:
res = W_RINGL|W_RINGR; /* W_RING, BOTH_SIDES */
break;
case ARMOR_CLASS:
switch (objects[otyp].oc_armcat) {
case ARM_SUIT: res = W_ARM; break; /* WORN_ARMOR */
case ARM_SHIELD: res = W_ARMS; break; /* WORN_SHIELD */
case ARM_HELM: res = W_ARMH; break; /* WORN_HELMET */
case ARM_GLOVES: res = W_ARMG; break; /* WORN_GLOVES */
case ARM_BOOTS: res = W_ARMF; break; /* WORN_BOOTS */
case ARM_CLOAK: res = W_ARMC; break; /* WORN_CLOAK */
#ifdef TOURIST
case ARM_SHIRT: res = W_ARMU; break; /* WORN_SHIRT */
#endif
}
break;
case WEAPON_CLASS:
res = W_WEP|W_SWAPWEP;
if (objects[otyp].oc_merge) res |= W_QUIVER;
break;
case TOOL_CLASS:
if (otyp == BLINDFOLD || otyp == TOWEL || otyp == LENSES)
res = W_TOOL; /* WORN_BLINDF */
else if (is_weptool(obj) || otyp == TIN_OPENER)
res = W_WEP|W_SWAPWEP;
#ifdef STEED
else if (otyp == SADDLE)
res = W_SADDLE;
#endif
break;
case FOOD_CLASS:
if (obj->otyp == MEAT_RING) res = W_RINGL|W_RINGR;
break;
case GEM_CLASS:
res = W_QUIVER;
break;
case BALL_CLASS:
res = W_BALL;
break;
case CHAIN_CLASS:
res = W_CHAIN;
break;
default:
break;
}
return res;
}
void
mon_set_minvis(mon)
struct monst *mon;