buglist entry: hobbits and elven mithril armour

<Someone> wrote: "Also, hobbits can't wear armour,
at least, you can't wear armour when polymorphed into a hobbit, even
though hobbits do tend to be carrying elven mithril-coats.
It's tempting to suggest adding an explicit exception in
sliparm() for elven mithril just to keep the Tolkienness."

- added a general routine for adding race-based /object
combination exceptions.
- hobbits can wear elven mithril-coats
This commit is contained in:
nethack.allison
2002-12-29 23:55:58 +00:00
parent df07fd4b90
commit e8ca725e92
7 changed files with 93 additions and 20 deletions

View File

@@ -1177,7 +1177,8 @@ boolean noisy;
is_suit(otmp) ? c_suit : 0;
if (which && cantweararm(youmonst.data) &&
/* same exception for cloaks as used in m_dowear() */
(which != c_cloak || youmonst.data->msize != MZ_SMALL)) {
(which != c_cloak || youmonst.data->msize != MZ_SMALL) &&
(racial_exception(&youmonst, otmp) < 1)) {
if (noisy) pline_The("%s will not fit on your body.", which);
return 0;
} else if (otmp->owornmask & W_ARMOR) {

View File

@@ -590,7 +590,7 @@ break_armor()
}
#endif
} else if (sliparm(youmonst.data)) {
if ((otmp = uarm) != 0) {
if (((otmp = uarm) != 0) && (racial_exception(&youmonst, otmp) < 1)) {
if (donning(otmp)) cancel_don();
Your("armor falls around you!");
(void) Armor_gone();

View File

@@ -17,13 +17,6 @@
#ifdef OVLB
/* elven armor vibrates warningly when enchanted beyond a limit */
#define is_elven_armor(optr) ((optr)->otyp == ELVEN_LEATHER_HELM\
|| (optr)->otyp == ELVEN_MITHRIL_COAT\
|| (optr)->otyp == ELVEN_CLOAK\
|| (optr)->otyp == ELVEN_SHIELD\
|| (optr)->otyp == ELVEN_BOOTS)
boolean known;
static NEARDATA const char readable[] =
@@ -711,6 +704,7 @@ register struct obj *sobj;
}
break;
}
/* elven armor vibrates warningly when enchanted beyond a limit */
special_armor = is_elven_armor(otmp) ||
(Role_if(PM_WIZARD) && otmp->otyp == CORNUTHAUM);
if (sobj->cursed)

View File

@@ -5,7 +5,7 @@
#include "hack.h"
STATIC_DCL void FDECL(m_lose_armor, (struct monst *,struct obj *));
STATIC_DCL void FDECL(m_dowear_type, (struct monst *,long,BOOLEAN_P));
STATIC_DCL void FDECL(m_dowear_type, (struct monst *,long, BOOLEAN_P, BOOLEAN_P));
STATIC_DCL int FDECL(extra_pref, (struct monst *, struct obj *));
const struct worn {
@@ -360,6 +360,7 @@ m_dowear(mon, creation)
register struct monst *mon;
boolean creation;
{
#define RACE_EXCEPTION TRUE
/* Note the restrictions here are the same as in dowear in do_wear.c
* except for the additional restriction on intelligence. (Players
* are always intelligent, even if polymorphed).
@@ -372,31 +373,34 @@ boolean creation;
(mon->data->mlet != S_MUMMY && mon->data != &mons[PM_SKELETON])))
return;
m_dowear_type(mon, W_AMUL, creation);
m_dowear_type(mon, W_AMUL, creation, FALSE);
#ifdef TOURIST
/* can't put on shirt if already wearing suit */
if (!cantweararm(mon->data) || (mon->misc_worn_check & W_ARM))
m_dowear_type(mon, W_ARMU, creation);
m_dowear_type(mon, W_ARMU, creation, FALSE);
#endif
/* treating small as a special case allows
hobbits, gnomes, and kobolds to wear cloaks */
if (!cantweararm(mon->data) || mon->data->msize == MZ_SMALL)
m_dowear_type(mon, W_ARMC, creation);
m_dowear_type(mon, W_ARMH, creation);
m_dowear_type(mon, W_ARMC, creation, FALSE);
m_dowear_type(mon, W_ARMH, creation, FALSE);
if (!MON_WEP(mon) || !bimanual(MON_WEP(mon)))
m_dowear_type(mon, W_ARMS, creation);
m_dowear_type(mon, W_ARMG, creation);
m_dowear_type(mon, W_ARMS, creation, FALSE);
m_dowear_type(mon, W_ARMG, creation, FALSE);
if (!slithy(mon->data) && mon->data->mlet != S_CENTAUR)
m_dowear_type(mon, W_ARMF, creation);
m_dowear_type(mon, W_ARMF, creation, FALSE);
if (!cantweararm(mon->data))
m_dowear_type(mon, W_ARM, creation);
m_dowear_type(mon, W_ARM, creation, FALSE);
else
m_dowear_type(mon, W_ARM, creation, RACE_EXCEPTION);
}
STATIC_OVL void
m_dowear_type(mon, flag, creation)
m_dowear_type(mon, flag, creation, racialexception)
struct monst *mon;
long flag;
boolean creation;
boolean racialexception;
{
struct obj *old, *best, *obj;
int m_delay = 0;
@@ -439,6 +443,7 @@ boolean creation;
break;
case W_ARM:
if (!is_suit(obj)) continue;
if (racialexception && (racial_exception(mon, obj) < 1)) continue;
break;
}
if (obj->owornmask) continue;
@@ -491,6 +496,7 @@ outer_break:
best->owornmask |= flag;
update_mon_intrinsics(mon, best, TRUE, creation);
}
#undef RACE_EXCEPTION
struct obj *
which_armor(mon, flag)
@@ -742,4 +748,32 @@ struct obj *obj;
}
return 0;
}
/*
* Exceptions to things based on race. Correctly checks polymorphed player race.
* Returns:
* 0 No exception, normal rules apply.
* 1 If the race/object combination is acceptable.
* -1 If the race/object combination is unacceptable.
*/
int
racial_exception(mon, obj)
struct monst *mon;
struct obj *obj;
{
struct permonst *ptr;
if (mon == &youmonst && !Upolyd) ptr = &mons[urace.malenum];
else ptr = mon->data;
/* Acceptable Exceptions: */
/* Allow hobbits to wear elven armor - LoTR */
if (ptr == &mons[PM_HOBBIT] && is_elven_armor(obj))
return 1;
/* Unacceptable Exceptions: */
/* Checks for object that certain races should never use go here */
/* return -1; */
return 0;
}
/*worn.c*/