W_WEAPON, W_ACCESSORY

Add macros W_WEAPON and W_ACCESSORY, similar to existing W_ARMOR, bitmask
of all the relevant worn bits.  Just for code readability; there should
be no change in behavior.

Also, reformat the "ugly checks" portion of getobj().  Slightly better
readability and fewer continuation lines, but only a modest improvement.
This commit is contained in:
PatR
2015-07-25 19:19:58 -07:00
parent 64dfb4fcc8
commit 9034e2a7e5
10 changed files with 152 additions and 153 deletions
+6 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 prop.h $NHDT-Date: 1432512777 2015/05/25 00:12:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */ /* NetHack 3.6 prop.h $NHDT-Date: 1437877163 2015/07/26 02:19:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.16 $ */
/* Copyright (c) 1989 Mike Threepoint */ /* Copyright (c) 1989 Mike Threepoint */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -100,14 +100,18 @@ struct prop {
#define W_WEP 0x00000100L /* Wielded weapon */ #define W_WEP 0x00000100L /* Wielded weapon */
#define W_QUIVER 0x00000200L /* Quiver for (f)iring ammo */ #define W_QUIVER 0x00000200L /* Quiver for (f)iring ammo */
#define W_SWAPWEP 0x00000400L /* Secondary weapon */ #define W_SWAPWEP 0x00000400L /* Secondary weapon */
#define W_WEAPON (W_WEP | W_SWAPWEP | W_QUIVER)
#define W_ART 0x00001000L /* Carrying artifact (not really worn) */ #define W_ART 0x00001000L /* Carrying artifact (not really worn) */
#define W_ARTI 0x00002000L /* Invoked artifact (not really worn) */ #define W_ARTI 0x00002000L /* Invoked artifact (not really worn) */
/* Amulets, rings, tools, and other items */ /* Amulets, rings, tools, and other items */
#define W_AMUL 0x00010000L /* Amulet */ #define W_AMUL 0x00010000L /* Amulet */
#define W_RINGL 0x00020000L /* Left ring */ #define W_RINGL 0x00020000L /* Left ring */
#define W_RINGR 0x00040000L /* Right ring */ #define W_RINGR 0x00040000L /* Right ring */
#define W_RING (W_RINGL | W_RINGR) #define W_RING (W_RINGL | W_RINGR)
#define W_TOOL 0x00080000L /* Eyewear */ #define W_TOOL 0x00080000L /* Eyewear */
#define W_ACCESSORY (W_RING | W_AMUL | W_TOOL)
/* historical note: originally in slash'em, 'worn' saddle stayed in
hero's inventory; in nethack, it's kept in the steed's inventory */
#define W_SADDLE 0x00100000L /* KMH -- For riding monsters */ #define W_SADDLE 0x00100000L /* KMH -- For riding monsters */
#define W_BALL 0x00200000L /* Punishment ball */ #define W_BALL 0x00200000L /* Punishment ball */
#define W_CHAIN 0x00400000L /* Punishment chain */ #define W_CHAIN 0x00400000L /* Punishment chain */
+2 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 do.c $NHDT-Date: 1436057350 2015/07/05 00:49:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.146 $ */ /* NetHack 3.6 do.c $NHDT-Date: 1437877173 2015/07/26 02:19:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.147 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -482,7 +482,7 @@ canletgo(obj, word)
struct obj *obj; struct obj *obj;
const char *word; const char *word;
{ {
if (obj->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) { if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
if (*word) if (*word)
Norep("You cannot %s %s you are wearing.", word, something); Norep("You cannot %s %s you are wearing.", word, something);
return (FALSE); return (FALSE);
+11 -13
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 do_wear.c $NHDT-Date: 1433289458 2015/06/02 23:57:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.82 $ */ /* NetHack 3.6 do_wear.c $NHDT-Date: 1437877177 2015/07/26 02:19:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.83 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1069,7 +1069,7 @@ register struct obj *otmp;
boolean already_blind = Blind, changed = FALSE; boolean already_blind = Blind, changed = FALSE;
/* blindfold might be wielded; release it for wearing */ /* blindfold might be wielded; release it for wearing */
if (otmp->owornmask & (W_WEP | W_SWAPWEP | W_QUIVER)) if (otmp->owornmask & W_WEAPON)
remove_worn_item(otmp, FALSE); remove_worn_item(otmp, FALSE);
setworn(otmp, W_TOOL); setworn(otmp, W_TOOL);
on_msg(otmp); on_msg(otmp);
@@ -1414,7 +1414,7 @@ doremring()
otmp = getobj(accessories, "remove"); otmp = getobj(accessories, "remove");
if (!otmp) if (!otmp)
return 0; return 0;
if (!(otmp->owornmask & (W_RING | W_AMUL | W_TOOL))) { if (!(otmp->owornmask & W_ACCESSORY)) {
You("are not wearing that."); You("are not wearing that.");
return 0; return 0;
} }
@@ -1742,7 +1742,7 @@ dowear()
otmp->known = 1; /* since AC is shown on the status line */ otmp->known = 1; /* since AC is shown on the status line */
/* if the armor is wielded, release it for wearing */ /* if the armor is wielded, release it for wearing */
if (otmp->owornmask & (W_WEP | W_SWAPWEP | W_QUIVER)) if (otmp->owornmask & W_WEAPON)
remove_worn_item(otmp, FALSE); remove_worn_item(otmp, FALSE);
setworn(otmp, mask); setworn(otmp, mask);
delay = -objects[otmp->otyp].oc_delay; delay = -objects[otmp->otyp].oc_delay;
@@ -1781,13 +1781,13 @@ doputon()
Your("%s%s are full, and you're already wearing an amulet and %s.", Your("%s%s are full, and you're already wearing an amulet and %s.",
humanoid(youmonst.data) ? "ring-" : "", humanoid(youmonst.data) ? "ring-" : "",
makeplural(body_part(FINGER)), makeplural(body_part(FINGER)),
ublindf->otyp == LENSES ? "some lenses" : "a blindfold"); (ublindf->otyp == LENSES) ? "some lenses" : "a blindfold");
return (0); return (0);
} }
otmp = getobj(accessories, "put on"); otmp = getobj(accessories, "put on");
if (!otmp) if (!otmp)
return (0); return (0);
if (otmp->owornmask & (W_RING | W_AMUL | W_TOOL)) { if (otmp->owornmask & W_ACCESSORY) {
already_wearing(c_that_); already_wearing(c_that_);
return (0); return (0);
} }
@@ -1795,12 +1795,10 @@ doputon()
weldmsg(otmp); weldmsg(otmp);
return (0); return (0);
} }
#if 0 #if 0 /* defer til Xxx_on(); various failures below now leave item wielded */
/* defer til Xxx_on(); various failures below now leave item wielded /* accessory might be wielded; release it for wearing */
*/ if (otmp->owornmask & W_WEAPON)
/* accessory might be wielded; release it for wearing */ remove_worn_item(otmp, FALSE);
if (otmp->owornmask & (W_WEP|W_SWAPWEP|W_QUIVER))
remove_worn_item(otmp, FALSE);
#endif #endif
if (otmp->oclass == RING_CLASS || otmp->otyp == MEAT_RING) { if (otmp->oclass == RING_CLASS || otmp->otyp == MEAT_RING) {
@@ -2406,7 +2404,7 @@ doddoremarm()
possibly combined with weapons */ possibly combined with weapons */
(void) strncpy(context.takeoff.disrobing, "disrobing", CONTEXTVERBSZ); (void) strncpy(context.takeoff.disrobing, "disrobing", CONTEXTVERBSZ);
/* specific activity when handling weapons only */ /* specific activity when handling weapons only */
if (!(context.takeoff.mask & ~(W_WEP | W_SWAPWEP | W_QUIVER))) if (!(context.takeoff.mask & ~W_WEAPON))
(void) strncpy(context.takeoff.disrobing, "disarming", (void) strncpy(context.takeoff.disrobing, "disarming",
CONTEXTVERBSZ); CONTEXTVERBSZ);
(void) take_off(); (void) take_off();
+98 -94
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 invent.c $NHDT-Date: 1436753515 2015/07/13 02:11:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.168 $ */ /* NetHack 3.6 invent.c $NHDT-Date: 1437877178 2015/07/26 02:19:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.169 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1014,26 +1014,26 @@ register const char *let, *word;
register int otyp = otmp->otyp; register int otyp = otmp->otyp;
bp[foo++] = otmp->invlet; bp[foo++] = otmp->invlet;
/* clang-format off */
/* *INDENT-OFF* */
/* ugly check: remove inappropriate things */ /* ugly check: remove inappropriate things */
if ((taking_off(word) if (
&& !(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))) (taking_off(word) /* exclude if not worn */
|| (putting_on(word) && !(otmp->owornmask & (W_ARMOR | W_ACCESSORY)))
&& (otmp->owornmask || (putting_on(word) /* exclude if already worn */
& (W_ARMOR | W_RING | W_AMUL | W_TOOL))) && (otmp->owornmask & (W_ARMOR | W_ACCESSORY)))
/* already worn */ #if 0 /* 3.4.1 -- include currently wielded weapon among 'wield' choices */
#if 0 /* 3.4.1 -- include currently wielded weapon among the choices */ || (!strcmp(word, "wield")
|| (!strcmp(word, "wield") && && (otmp->owornmask & W_WEP))
(otmp->owornmask & W_WEP))
#endif #endif
|| (!strcmp(word, "ready") || (!strcmp(word, "ready") /* exclude if wielded */
&& (otmp == uwep || (otmp == uswapwep && u.twoweap))) && (otmp == uwep || (otmp == uswapwep && u.twoweap)))
|| ((!strcmp(word, "dip") || !strcmp(word, "grease")) || ((!strcmp(word, "dip") || !strcmp(word, "grease"))
&& inaccessible_equipment(otmp, (const char *) 0, && inaccessible_equipment(otmp, (const char *) 0, FALSE))
FALSE))) { ) {
foo--; foo--;
foox++; foox++;
} }
/* Second ugly check; unlike the first it won't trigger an /* Second ugly check; unlike the first it won't trigger an
* "else" in "you don't have anything else to ___". * "else" in "you don't have anything else to ___".
*/ */
@@ -1042,89 +1042,93 @@ register const char *let, *word;
&& ((otmp->oclass == FOOD_CLASS && otmp->otyp != MEAT_RING) && ((otmp->oclass == FOOD_CLASS && otmp->otyp != MEAT_RING)
|| (otmp->oclass == TOOL_CLASS && otyp != BLINDFOLD || (otmp->oclass == TOOL_CLASS && otyp != BLINDFOLD
&& otyp != TOWEL && otyp != LENSES))) && otyp != TOWEL && otyp != LENSES)))
|| (!strcmp(word, "wield") || (!strcmp(word, "wield")
&& (otmp->oclass == TOOL_CLASS && !is_weptool(otmp))) && (otmp->oclass == TOOL_CLASS && !is_weptool(otmp)))
|| (!strcmp(word, "eat") && !is_edible(otmp)) || (!strcmp(word, "eat") && !is_edible(otmp))
|| (!strcmp(word, "sacrifice") || (!strcmp(word, "sacrifice")
&& (otyp != CORPSE && otyp != AMULET_OF_YENDOR && (otyp != CORPSE && otyp != AMULET_OF_YENDOR
&& otyp != FAKE_AMULET_OF_YENDOR)) && otyp != FAKE_AMULET_OF_YENDOR))
|| (!strcmp(word, "write with") || (!strcmp(word, "write with")
&& (otmp->oclass == TOOL_CLASS && otyp != MAGIC_MARKER && (otmp->oclass == TOOL_CLASS
&& otyp != TOWEL)) && otyp != MAGIC_MARKER && otyp != TOWEL))
|| (!strcmp(word, "tin") || (!strcmp(word, "tin")
&& (otyp != CORPSE || !tinnable(otmp))) && (otyp != CORPSE || !tinnable(otmp)))
|| (!strcmp(word, "rub") || (!strcmp(word, "rub")
&& ((otmp->oclass == TOOL_CLASS && otyp != OIL_LAMP && ((otmp->oclass == TOOL_CLASS && otyp != OIL_LAMP
&& otyp != MAGIC_LAMP && otyp != BRASS_LANTERN) && otyp != MAGIC_LAMP && otyp != BRASS_LANTERN)
|| (otmp->oclass == GEM_CLASS
&& !is_graystone(otmp))))
|| ((!strcmp(word, "use or apply")
|| !strcmp(word, "untrap with")) &&
/* Picks, axes, pole-weapons, bullwhips */
((otmp->oclass == WEAPON_CLASS && !is_pick(otmp)
&& !is_axe(otmp) && !is_pole(otmp) && otyp != BULLWHIP)
|| (otmp->oclass == POTION_CLASS &&
/* only applicable potion is oil, and it will only
be offered as a choice when already discovered */
(otyp != POT_OIL || !otmp->dknown
|| !objects[POT_OIL].oc_name_known))
|| (otmp->oclass == FOOD_CLASS && otyp != CREAM_PIE
&& otyp != EUCALYPTUS_LEAF)
|| (otmp->oclass == GEM_CLASS && !is_graystone(otmp)))) || (otmp->oclass == GEM_CLASS && !is_graystone(otmp))))
|| (!strcmp(word, "invoke") || (!strcmp(word, "use or apply")
&& (!otmp->oartifact && !objects[otyp].oc_unique /* Picks, axes, pole-weapons, bullwhips */
&& (otyp != FAKE_AMULET_OF_YENDOR || otmp->known) && ((otmp->oclass == WEAPON_CLASS
&& otyp != CRYSTAL_BALL && !is_pick(otmp) && !is_axe(otmp)
&& /* #invoke synonym for apply */ && !is_pole(otmp) && otyp != BULLWHIP)
/* note: presenting the possibility of invoking || (otmp->oclass == POTION_CLASS
non-artifact /* only applicable potion is oil, and it will only
mirrors and/or lamps is a simply a cruel be offered as a choice when already discovered */
deception... */ && (otyp != POT_OIL || !otmp->dknown
otyp != MIRROR || !objects[POT_OIL].oc_name_known))
&& otyp != MAGIC_LAMP || (otmp->oclass == FOOD_CLASS
&& (otyp != OIL_LAMP && otyp != CREAM_PIE && otyp != EUCALYPTUS_LEAF)
|| /* don't list known oil lamp */ || (otmp->oclass == GEM_CLASS && !is_graystone(otmp))))
(otmp->dknown || (!strcmp(word, "invoke")
&& objects[OIL_LAMP].oc_name_known)))) && !otmp->oartifact
|| (!strcmp(word, "untrap with") && !objects[otyp].oc_unique
&& (otmp->oclass == TOOL_CLASS && otyp != CAN_OF_GREASE)) && (otyp != FAKE_AMULET_OF_YENDOR || otmp->known)
|| (!strcmp(word, "tip") && !Is_container(otmp) && && otyp != CRYSTAL_BALL /* synonym for apply */
/* include horn of plenty if sufficiently discovered */ /* note: presenting the possibility of invoking non-artifact
(otmp->otyp != HORN_OF_PLENTY || !otmp->dknown mirrors and/or lamps is simply a cruel deception... */
&& otyp != MIRROR
&& otyp != MAGIC_LAMP
&& (otyp != OIL_LAMP /* don't list known oil lamp */
|| (otmp->dknown && objects[OIL_LAMP].oc_name_known)))
|| (!strcmp(word, "untrap with")
&& ((otmp->oclass == TOOL_CLASS && otyp != CAN_OF_GREASE)
|| (otmp->oclass == POTION_CLASS
/* only applicable potion is oil, and it will only
be offered as a choice when already discovered */
&& (otyp != POT_OIL || !otmp->dknown
|| !objects[POT_OIL].oc_name_known))))
|| (!strcmp(word, "tip") && !Is_container(otmp)
/* include horn of plenty if sufficiently discovered */
&& (otmp->otyp != HORN_OF_PLENTY || !otmp->dknown
|| !objects[HORN_OF_PLENTY].oc_name_known)) || !objects[HORN_OF_PLENTY].oc_name_known))
|| (!strcmp(word, "charge") && !is_chargeable(otmp)) || (!strcmp(word, "charge") && !is_chargeable(otmp))
|| (!strcmp(word, "call") && !objtyp_is_callable(otyp))) || (!strcmp(word, "call") && !objtyp_is_callable(otyp))
) {
foo--; foo--;
}
/* ugly check for unworn armor that can't be worn */ /* ugly check for unworn armor that can't be worn */
else if ((putting_on(word) && *let == ARMOR_CLASS else if (
&& !canwearobj(otmp, &dummymask, FALSE)) (putting_on(word) && *let == ARMOR_CLASS
/* or unsuitable items rubbed on known touchstone */ && !canwearobj(otmp, &dummymask, FALSE))
|| (!strncmp(word, "rub on the stone", 16) /* or unsuitable items rubbed on known touchstone */
&& *let == GEM_CLASS && otmp->dknown || (!strncmp(word, "rub on the stone", 16)
&& objects[otyp].oc_name_known) && *let == GEM_CLASS && otmp->dknown
/* suppress corpses on astral, amulets elsewhere */ && objects[otyp].oc_name_known)
|| (!strcmp(word, "sacrifice") && /* suppress corpses on astral, amulets elsewhere */
/* (!astral && amulet) || (astral && !amulet) */ || (!strcmp(word, "sacrifice") &&
(!Is_astralevel(&u.uz) /* (!astral && amulet) || (astral && !amulet) */
^ (otmp->oclass != AMULET_CLASS))) (!Is_astralevel(&u.uz) ^ (otmp->oclass != AMULET_CLASS)))
/* suppress container being stashed into */ /* suppress container being stashed into */
|| (!strcmp(word, "stash") && !ck_bag(otmp)) || (!strcmp(word, "stash") && !ck_bag(otmp))
/* worn armor or accessory covered by cursed worn armor /* worn armor or accessory covered by cursed worn armor */
*/ || (taking_off(word)
|| (taking_off(word) && inaccessible_equipment(otmp, (const char *) 0, TRUE))
&& inaccessible_equipment(otmp, (const char *) 0, ) {
TRUE))) {
/* acceptable but not listed as likely candidate */ /* acceptable but not listed as likely candidate */
foo--; foo--;
allowall = TRUE; allowall = TRUE;
*ap++ = otmp->invlet; *ap++ = otmp->invlet;
} }
/* *INDENT-ON* */
/* clang-format on */
} else { } else {
/* "ugly check" for reading fortune cookies, part 2 */ /* "ugly check" for reading fortune cookies, part 2 */
if ((!strcmp(word, "read") && is_readable(otmp))) if ((!strcmp(word, "read") && is_readable(otmp)))
allowall = usegold = TRUE; allowall = usegold = TRUE;
} }
} }
bp[foo] = 0; bp[foo] = 0;
if (foo == 0 && bp > buf && bp[-1] == ' ') if (foo == 0 && bp > buf && bp[-1] == ' ')
*--bp = 0; *--bp = 0;
@@ -1355,17 +1359,17 @@ register struct obj *otmp;
boolean boolean
wearing_armor() wearing_armor()
{ {
return ((boolean)(uarm || uarmc || uarmf || uarmg || uarmh || uarms return (boolean) (uarm || uarmc || uarmf || uarmg
|| uarmu)); || uarmh || uarms || uarmu);
} }
boolean boolean
is_worn(otmp) is_worn(otmp)
register struct obj *otmp; struct obj *otmp;
{ {
return ((boolean)( return (otmp->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE | W_WEAPON))
!!(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE ? TRUE
| W_WEP | W_SWAPWEP | W_QUIVER)))); : FALSE;
} }
/* extra xprname() input that askchain() can't pass through safe_qbuf() */ /* extra xprname() input that askchain() can't pass through safe_qbuf() */
@@ -2923,9 +2927,9 @@ register struct obj *otmp, *obj;
return FALSE; return FALSE;
if (obj->known == otmp->known || !objects[otmp->otyp].oc_uses_known) { if (obj->known == otmp->known || !objects[otmp->otyp].oc_uses_known) {
return ((boolean)(objects[obj->otyp].oc_merge)); return (boolean) objects[obj->otyp].oc_merge;
} else } else
return (FALSE); return FALSE;
} }
int int
@@ -3045,8 +3049,8 @@ struct obj *obj;
return TRUE; return TRUE;
if (obj->oclass != TOOL_CLASS) if (obj->oclass != TOOL_CLASS)
return FALSE; return FALSE;
return (boolean)(obj == uwep || obj->lamplit return (boolean) (obj == uwep || obj->lamplit
|| (obj->otyp == LEASH && obj->leashmon)); || (obj->otyp == LEASH && obj->leashmon));
} }
int int
+4 -4
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mhitu.c $NHDT-Date: 1432512772 2015/05/25 00:12:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.127 $ */ /* NetHack 3.6 mhitu.c $NHDT-Date: 1437877180 2015/07/26 02:19:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.128 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -813,7 +813,7 @@ struct monst *mon;
continue; continue;
/* omit W_SWAPWEP+W_QUIVER; W_ART+W_ARTI handled by protects() */ /* omit W_SWAPWEP+W_QUIVER; W_ART+W_ARTI handled by protects() */
wearmask = W_ARMOR | W_RING | W_AMUL | W_TOOL; wearmask = W_ARMOR | W_ACCESSORY;
if (o->oclass == WEAPON_CLASS || is_weptool(o)) if (o->oclass == WEAPON_CLASS || is_weptool(o))
wearmask |= W_WEP; wearmask |= W_WEP;
if (protects(o, ((o->owornmask & wearmask) != 0L) ? TRUE : FALSE)) if (protects(o, ((o->owornmask & wearmask) != 0L) ? TRUE : FALSE))
@@ -827,9 +827,9 @@ struct monst *mon;
} else if (mc < 1) { } else if (mc < 1) {
/* intrinsic Protection is weaker (play balance; obtaining divine /* intrinsic Protection is weaker (play balance; obtaining divine
protection is too easy); it confers minimum mc 1 instead of 0 */ protection is too easy); it confers minimum mc 1 instead of 0 */
if ((is_you && ((HProtection && u.ublessed) || u.uspellprot)) || if ((is_you && ((HProtection && u.ublessed) || u.uspellprot))
/* aligned priests and angels have innate intrinsic Protection */ /* aligned priests and angels have innate intrinsic Protection */
(mon->data == &mons[PM_ALIGNED_PRIEST] || is_minion(mon->data))) || (mon->data == &mons[PM_ALIGNED_PRIEST] || is_minion(mon->data)))
mc = 1; mc = 1;
} }
return mc; return mc;
+5 -4
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mkobj.c $NHDT-Date: 1436753518 2015/07/13 02:11:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.103 $ */ /* NetHack 3.6 mkobj.c $NHDT-Date: 1437877180 2015/07/26 02:19:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.104 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -2290,8 +2290,9 @@ struct obj *obj;
++n; ++n;
allmask |= wearbits[i]; allmask |= wearbits[i];
} }
if (n == 2 && carried(obj) && obj == uball && (owornmask & W_BALL) != 0L if (n == 2 && carried(obj)
&& (owornmask & (W_WEP | W_SWAPWEP | W_QUIVER)) != 0L) { && obj == uball && (owornmask & W_BALL) != 0L
&& (owornmask & W_WEAPON) != 0L) {
/* chained ball can be wielded/alt-wielded/quivered; if so, /* chained ball can be wielded/alt-wielded/quivered; if so,
pretend it's not chained in order to check the weapon pointer pretend it's not chained in order to check the weapon pointer
(we've already verified the ball pointer by successfully passing (we've already verified the ball pointer by successfully passing
@@ -2396,7 +2397,7 @@ struct obj *obj;
if (owornmask & W_ARMOR) { if (owornmask & W_ARMOR) {
if (obj->oclass != ARMOR_CLASS) if (obj->oclass != ARMOR_CLASS)
what = "armor"; what = "armor";
} else if (owornmask & (W_WEP | W_SWAPWEP | W_QUIVER)) { } else if (owornmask & W_WEAPON) {
/* monsters don't maintain alternate weapon or quiver */ /* monsters don't maintain alternate weapon or quiver */
if (mcarried(obj) && (owornmask & (W_SWAPWEP | W_QUIVER)) != 0L) if (mcarried(obj) && (owornmask & (W_SWAPWEP | W_QUIVER)) != 0L)
what = (owornmask & W_SWAPWEP) != 0L ? "monst alt weapon?" what = (owornmask & W_SWAPWEP) != 0L ? "monst alt weapon?"
+3 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mondata.c $NHDT-Date: 1433117881 2015/06/01 00:18:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.54 $ */ /* NetHack 3.6 mondata.c $NHDT-Date: 1437877181 2015/07/26 02:19:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.55 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -115,7 +115,7 @@ struct monst *mon;
return TRUE; return TRUE;
/* check for magic resistance granted by worn or carried items */ /* check for magic resistance granted by worn or carried items */
o = is_you ? invent : mon->minvent; o = is_you ? invent : mon->minvent;
slotmask = W_ARMOR | W_RING | W_AMUL | W_TOOL; slotmask = W_ARMOR | W_ACCESSORY;
if (!is_you || /* assumes monsters don't wield non-weapons */ if (!is_you || /* assumes monsters don't wield non-weapons */
(uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep)))) (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
slotmask |= W_WEP; slotmask |= W_WEP;
@@ -153,7 +153,7 @@ struct monst *mon;
if (o && o->oartifact && defends(AD_BLND, o)) if (o && o->oartifact && defends(AD_BLND, o))
return TRUE; return TRUE;
o = is_you ? invent : mon->minvent; o = is_you ? invent : mon->minvent;
slotmask = W_ARMOR | W_RING | W_AMUL | W_TOOL; slotmask = W_ARMOR | W_ACCESSORY;
if (!is_you || /* assumes monsters don't wield non-weapons */ if (!is_you || /* assumes monsters don't wield non-weapons */
(uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep)))) (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
slotmask |= W_WEP; slotmask |= W_WEP;
+7 -11
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 pickup.c $NHDT-Date: 1434507811 2015/06/17 02:23:31 $ $NHDT-Branch: master $:$NHDT-Revision: 1.159 $ */ /* NetHack 3.6 pickup.c $NHDT-Date: 1437877182 2015/07/26 02:19:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.160 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -437,9 +437,8 @@ boolean
is_worn_by_type(otmp) is_worn_by_type(otmp)
register struct obj *otmp; register struct obj *otmp;
{ {
return ((boolean)(!!(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL return (boolean) (!!(otmp->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON))
| W_WEP | W_SWAPWEP | W_QUIVER))) && index(valid_menu_classes, otmp->oclass) != 0);
&& (index(valid_menu_classes, otmp->oclass) != (char *) 0));
} }
/* /*
@@ -979,8 +978,7 @@ int how; /* type of query */
&& !(qflags & BILLED_TYPES)) { && !(qflags & BILLED_TYPES)) {
for (curr = olist; curr; curr = FOLLOW(curr, qflags)) { for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
if ((qflags & WORN_TYPES) if ((qflags & WORN_TYPES)
&& !(curr->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL && !(curr->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON)))
| W_WEP | W_SWAPWEP | W_QUIVER)))
continue; continue;
break; break;
} }
@@ -1012,8 +1010,7 @@ int how; /* type of query */
for (curr = olist; curr; curr = FOLLOW(curr, qflags)) { for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
if (curr->oclass == *pack) { if (curr->oclass == *pack) {
if ((qflags & WORN_TYPES) if ((qflags & WORN_TYPES)
&& !(curr->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL && !(curr->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON)))
| W_WEP | W_SWAPWEP | W_QUIVER)))
continue; continue;
if (!collected_type_name) { if (!collected_type_name) {
any = zeroany; any = zeroany;
@@ -1113,8 +1110,7 @@ int qflags;
for (curr = olist; curr; curr = FOLLOW(curr, qflags)) { for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
if (curr->oclass == *pack) { if (curr->oclass == *pack) {
if ((qflags & WORN_TYPES) if ((qflags & WORN_TYPES)
&& !(curr->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL && !(curr->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON)))
| W_WEP | W_SWAPWEP | W_QUIVER)))
continue; continue;
if (!counted_category) { if (!counted_category) {
ccount++; ccount++;
@@ -1938,7 +1934,7 @@ register struct obj *obj;
} else if (obj == current_container) { } else if (obj == current_container) {
pline("That would be an interesting topological exercise."); pline("That would be an interesting topological exercise.");
return 0; return 0;
} else if (obj->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) { } else if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
Norep("You cannot %s %s you are wearing.", Norep("You cannot %s %s you are wearing.",
Icebox ? "refrigerate" : "stash", something); Icebox ? "refrigerate" : "stash", something);
return 0; return 0;
+12 -14
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 steal.c $NHDT-Date: 1432512772 2015/05/25 00:12:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */ /* NetHack 3.6 steal.c $NHDT-Date: 1437877184 2015/07/26 02:19:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -24,11 +24,12 @@ register struct obj *otmp;
? cloak_simple_name(otmp) ? cloak_simple_name(otmp)
: (otmp == uarmh) : (otmp == uarmh)
? helm_simple_name(otmp) ? helm_simple_name(otmp)
: "armor"); : suit_simple_name(otmp));
} }
long /* actually returns something that fits in an int */ /* proportional subset of gold; return value actually fits in an int */
somegold(lmoney) long
somegold(lmoney)
long lmoney; long lmoney;
{ {
#ifdef LINT /* long conv. ok */ #ifdef LINT /* long conv. ok */
@@ -215,7 +216,7 @@ boolean unchain_ball; /* whether to unpunish or just unwield */
Ring_gone(obj); Ring_gone(obj);
} else if (obj->owornmask & W_TOOL) { } else if (obj->owornmask & W_TOOL) {
Blindf_off(obj); Blindf_off(obj);
} else if (obj->owornmask & (W_WEP | W_SWAPWEP | W_QUIVER)) { } else if (obj->owornmask & W_WEAPON) {
if (obj == uwep) if (obj == uwep)
uwepgone(); uwepgone();
if (obj == uswapwep) if (obj == uswapwep)
@@ -287,20 +288,17 @@ retry:
for (otmp = invent; otmp; otmp = otmp->nobj) for (otmp = invent; otmp; otmp = otmp->nobj)
if ((!uarm || otmp != uarmc) && otmp != uskin if ((!uarm || otmp != uarmc) && otmp != uskin
&& otmp->oclass != COIN_CLASS) && otmp->oclass != COIN_CLASS)
tmp += ((otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) tmp += (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) ? 5 : 1;
? 5
: 1);
if (!tmp) if (!tmp)
goto nothing_to_steal; goto nothing_to_steal;
tmp = rn2(tmp); tmp = rn2(tmp);
for (otmp = invent; otmp; otmp = otmp->nobj) for (otmp = invent; otmp; otmp = otmp->nobj)
if ((!uarm || otmp != uarmc) && otmp != uskin if ((!uarm || otmp != uarmc) && otmp != uskin
&& otmp->oclass != COIN_CLASS) && otmp->oclass != COIN_CLASS) {
if ((tmp -= tmp -= (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) ? 5 : 1;
((otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) if (tmp < 0)
? 5
: 1)) < 0)
break; break;
}
if (!otmp) { if (!otmp) {
impossible("Steal fails!"); impossible("Steal fails!");
return (0); return (0);
@@ -374,7 +372,7 @@ gotobj:
/* you're going to notice the theft... */ /* you're going to notice the theft... */
stop_occupation(); stop_occupation();
if ((otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))) { if (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) {
switch (otmp->oclass) { switch (otmp->oclass) {
case TOOL_CLASS: case TOOL_CLASS:
case AMULET_CLASS: case AMULET_CLASS:
+4 -6
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 wield.c $NHDT-Date: 1436753528 2015/07/13 02:12:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.43 $ */ /* NetHack 3.6 wield.c $NHDT-Date: 1437877186 2015/07/26 02:19:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.44 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -273,8 +273,7 @@ dowield()
return (doswapweapon()); return (doswapweapon());
else if (wep == uquiver) else if (wep == uquiver)
setuqwep((struct obj *) 0); setuqwep((struct obj *) 0);
else if (wep->owornmask else if (wep->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE)) {
& (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE)) {
You("cannot wield that!"); You("cannot wield that!");
return (0); return (0);
} }
@@ -370,8 +369,7 @@ dowieldquiver()
pline("%s already being used as a weapon!", pline("%s already being used as a weapon!",
!is_plural(uwep) ? "That is" : "They are"); !is_plural(uwep) ? "That is" : "They are");
return (0); return (0);
} else if (newquiver->owornmask } else if (newquiver->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE)) {
& (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE)) {
You("cannot ready that!"); You("cannot ready that!");
return (0); return (0);
} else { } else {
@@ -416,7 +414,7 @@ const char *verb; /* "rub",&c */
more_than_1 = (obj->quan > 1L || strstri(what, "pair of ") != 0 more_than_1 = (obj->quan > 1L || strstri(what, "pair of ") != 0
|| strstri(what, "s of ") != 0); || strstri(what, "s of ") != 0);
if (obj->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) { if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
You_cant("%s %s while wearing %s.", verb, yname(obj), You_cant("%s %s while wearing %s.", verb, yname(obj),
more_than_1 ? "them" : "it"); more_than_1 ? "them" : "it");
return FALSE; return FALSE;