worn gear after polymorph alignment change [1 of 2] (trunk only)

Make polymorphing or changing alignment perform a touch check (as is
done when catching lycanthropy) on wielded weapon(s) to see whether the
hero can still use them in his new form.  Part [2 of 2] will update
retouch_equipment() to check all items in use rather than just weapon(s).
(A comment or two in part 1 already refers to expected behavior of part 2.)
This commit is contained in:
nethack.rankin
2007-03-20 03:58:27 +00:00
parent b410a0e514
commit c86f9ff008
9 changed files with 86 additions and 34 deletions
+1
View File
@@ -198,6 +198,7 @@ rephrase "<artifact> evades your grasp" message if artifact is already held
artifacts which subsequently evade your grasp/control after already being artifacts which subsequently evade your grasp/control after already being
worn or wielded become unworn/unwielded worn or wielded become unworn/unwielded
hero with lycanthropy is vulnerable to silver in human form as well as beast hero with lycanthropy is vulnerable to silver in human form as well as beast
changing alignment or shape triggers a check for equipment evading hero's grasp
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
+2
View File
@@ -85,6 +85,7 @@ E long FDECL(arti_cost, (struct obj *));
E struct obj *FDECL(what_gives, (long *)); E struct obj *FDECL(what_gives, (long *));
E void FDECL(Sting_effects, (int)); E void FDECL(Sting_effects, (int));
E int FDECL(retouch_object, (struct obj **,BOOLEAN_P)); E int FDECL(retouch_object, (struct obj **,BOOLEAN_P));
E void FDECL(retouch_equipment, (int));
/* ### attrib.c ### */ /* ### attrib.c ### */
@@ -108,6 +109,7 @@ E schar NDECL(acurrstr);
E void FDECL(adjalign, (int)); E void FDECL(adjalign, (int));
E int FDECL(is_innate, (int)); E int FDECL(is_innate, (int));
E char *FDECL(from_what, (int)); E char *FDECL(from_what, (int));
E void FDECL(uchangealign, (int,int));
/* ### ball.c ### */ /* ### ball.c ### */
+15 -2
View File
@@ -1622,8 +1622,8 @@ int orc_count;
} }
/* called when hero is wielding/applying/invoking a carried item, or /* called when hero is wielding/applying/invoking a carried item, or
after undergoing a transformation (alignment change, lycanthropy) after undergoing a transformation (alignment change, lycanthropy,
which might affect item access */ polymorph) which might affect item access */
int int
retouch_object(objp, loseit) retouch_object(objp, loseit)
struct obj **objp; /* might be destroyed or unintentionally dropped */ struct obj **objp; /* might be destroyed or unintentionally dropped */
@@ -1686,4 +1686,17 @@ boolean loseit; /* whether to drop it if hero can longer touch it */
return 0; return 0;
} }
void
retouch_equipment(dropflag)
int dropflag; /* 0==don't drop, 1==drop all, 2==drop weapon */
{
boolean dropit;
dropit = (dropflag > 0); /* drop all or drop weapon */
/* check secondary weapon first, before possibly unwielding primary */
if (u.twoweap) (void)retouch_object(&uswapwep, dropit);
/* check primary weapon next so that they're handled together */
if (uwep) (void)retouch_object(&uwep, dropit);
}
/*artifact.c*/ /*artifact.c*/
+32 -1
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)attrib.c 3.5 2006/05/20 */ /* SCCS Id: @(#)attrib.c 3.5 2007/03/19 */
/* Copyright 1988, 1989, 1990, 1992, M. Stephenson */ /* Copyright 1988, 1989, 1990, 1992, M. Stephenson */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -885,4 +885,35 @@ register int n;
} }
} }
/* change hero's alignment type, possibly losing use of artifacts */
void
uchangealign(newalign, reason)
int newalign;
int reason; /* 0==conversion, 1==helm-of-OA on, 2==helm-of-OA off */
{
aligntyp oldalign = u.ualign.type;
u.ublessed = 0; /* lose divine protection */
context.botl = 1; /* status line needs updating */
if (reason == 0) {
/* conversion via altar */
u.ualignbase[A_CURRENT] = (aligntyp)newalign;
/* worn helm of opposite alignment might block change */
if (!uarmh || uarmh->otyp != HELM_OF_OPPOSITE_ALIGNMENT)
u.ualign.type = u.ualignbase[A_CURRENT];
You("have a %ssense of a new direction.",
(u.ualign.type != oldalign) ? "sudden " : "");
} else {
/* putting on or taking off a helm of opposite alignment */
u.ualign.type = (aligntyp)newalign;
if (reason == 1)
Your("mind oscillates %s.", Hallucination ? "wildly" : "briefly");
else if (reason == 2)
Your("mind is %s.", Hallucination ? "much of a muchness" :
"back in sync with your body");
}
if (u.ualign.type != oldalign) retouch_equipment(0);
}
/*attrib.c*/ /*attrib.c*/
+13 -11
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)do_wear.c 3.5 2007/02/17 */ /* SCCS Id: @(#)do_wear.c 3.5 2007/03/19 */
/* 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. */
@@ -316,14 +316,15 @@ Helmet_on(VOID_ARGS)
makeknown(uarmh->otyp); makeknown(uarmh->otyp);
break; break;
case HELM_OF_OPPOSITE_ALIGNMENT: case HELM_OF_OPPOSITE_ALIGNMENT:
if (u.ualign.type == A_NEUTRAL) /* changing alignment can toggle off active artifact
u.ualign.type = rn2(2) ? A_CHAOTIC : A_LAWFUL; properties, including levitation; uarmh could get
else u.ualign.type = -(u.ualign.type); dropped or destroyed here */
u.ublessed = 0; /* lose your god's protection */ uchangealign((u.ualign.type != A_NEUTRAL) ? -u.ualign.type :
rn2(2) ? A_CHAOTIC : A_LAWFUL, 1);
/* makeknown(uarmh->otyp); -- moved below, after xname() */ /* makeknown(uarmh->otyp); -- moved below, after xname() */
/*FALLTHRU*/ /*FALLTHRU*/
case DUNCE_CAP: case DUNCE_CAP:
if (!uarmh->cursed) { if (uarmh && !uarmh->cursed) {
if (Blind) if (Blind)
pline("%s for a moment.", Tobjnam(uarmh, "vibrate")); pline("%s for a moment.", Tobjnam(uarmh, "vibrate"));
else else
@@ -334,12 +335,12 @@ Helmet_on(VOID_ARGS)
context.botl = 1; /* reveal new alignment or INT & WIS */ context.botl = 1; /* reveal new alignment or INT & WIS */
if (Hallucination) { if (Hallucination) {
pline("My brain hurts!"); /* Monty Python's Flying Circus */ pline("My brain hurts!"); /* Monty Python's Flying Circus */
} else if (uarmh->otyp == DUNCE_CAP) { } else if (uarmh && uarmh->otyp == DUNCE_CAP) {
You_feel("%s.", /* track INT change; ignore WIS */ You_feel("%s.", /* track INT change; ignore WIS */
ACURR(A_INT) <= (ABASE(A_INT) + ABON(A_INT) + ATEMP(A_INT)) ? ACURR(A_INT) <= (ABASE(A_INT) + ABON(A_INT) + ATEMP(A_INT)) ?
"like sitting in a corner" : "giddy"); "like sitting in a corner" : "giddy");
} else { } else {
Your("mind oscillates briefly."); /* [message moved to uchangealign()] */
makeknown(HELM_OF_OPPOSITE_ALIGNMENT); makeknown(HELM_OF_OPPOSITE_ALIGNMENT);
} }
break; break;
@@ -379,9 +380,10 @@ Helmet_off(VOID_ARGS)
if (!context.takeoff.cancelled_don) adj_abon(uarmh, -uarmh->spe); if (!context.takeoff.cancelled_don) adj_abon(uarmh, -uarmh->spe);
break; break;
case HELM_OF_OPPOSITE_ALIGNMENT: case HELM_OF_OPPOSITE_ALIGNMENT:
u.ualign.type = u.ualignbase[A_CURRENT]; /* changing alignment can toggle off active artifact
u.ublessed = 0; /* lose the other god's protection */ properties, including levitation; uarmh could get
context.botl = 1; dropped or destroyed here */
uchangealign(u.ualignbase[A_CURRENT], 2);
break; break;
default: impossible(unknown_type, c_helmet, uarmh->otyp); default: impossible(unknown_type, c_helmet, uarmh->otyp);
} }
+2 -5
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)eat.c 3.5 2007/02/05 */ /* SCCS Id: @(#)eat.c 3.5 2007/03/19 */
/* 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. */
@@ -1152,10 +1152,7 @@ register int pm;
break; break;
} }
if (catch_lycanthropy) { if (catch_lycanthropy) retouch_equipment(2);
if (u.twoweap) (void)retouch_object(&uswapwep, TRUE);
if (uwep) (void)retouch_object(&uwep, TRUE);
}
return; return;
} }
+1 -2
View File
@@ -1232,8 +1232,7 @@ dopois:
You_feel("feverish."); You_feel("feverish.");
exercise(A_CON, FALSE); exercise(A_CON, FALSE);
u.ulycn = monsndx(mdat); u.ulycn = monsndx(mdat);
if (u.twoweap) (void)retouch_object(&uswapwep, TRUE); retouch_equipment(2);
if (uwep) (void)retouch_object(&uwep, TRUE);
} }
break; break;
case AD_SGLD: case AD_SGLD:
+18 -3
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)polyself.c 3.5 2007/02/12 */ /* SCCS Id: @(#)polyself.c 3.5 2007/03/19 */
/* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */ /* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -8,6 +8,15 @@
* Note: the light source handling code assumes that both youmonst.m_id * Note: the light source handling code assumes that both youmonst.m_id
* and youmonst.mx will always remain 0 when it handles the case of the * and youmonst.mx will always remain 0 when it handles the case of the
* player polymorphed into a light-emitting monster. * player polymorphed into a light-emitting monster.
*
* Transformation sequences:
* /-> polymon poly into monster form
* polyself =
* \-> newman -> polyman fail to poly, get human form
*
* rehumanize -> polyman return to original form
*
* polymon (called directly) usually golem petrification
*/ */
#include "hack.h" #include "hack.h"
@@ -227,10 +236,14 @@ dead: /* we come directly here if their experience level went to 0 or less */
Your("body transforms, but there is still slime on you."); Your("body transforms, but there is still slime on you.");
make_slimed(10L, (const char*) 0); make_slimed(10L, (const char*) 0);
} }
(void) polysense(youmonst.data); (void) polysense(youmonst.data);
context.botl = 1; context.botl = 1;
see_monsters(); see_monsters();
(void) encumber_msg(); (void) encumber_msg();
retouch_equipment(2);
if (!uarmg) selftouch(no_longer_petrify_resistant);
} }
void void
@@ -352,7 +365,6 @@ int psflags;
} }
made_change: made_change:
if (!uarmg) selftouch(no_longer_petrify_resistant);
new_light = emits_light(youmonst.data); new_light = emits_light(youmonst.data);
if (old_light != new_light) { if (old_light != new_light) {
if (old_light) if (old_light)
@@ -602,6 +614,7 @@ int mntmp;
see_monsters(); see_monsters();
(void) encumber_msg(); (void) encumber_msg();
retouch_equipment(2);
/* this might trigger a recursize call to polymon() [stone golem /* this might trigger a recursize call to polymon() [stone golem
wielding cockatrice corpse and hit by stone-to-flesh, becomes wielding cockatrice corpse and hit by stone-to-flesh, becomes
flesh golem above, now gets transformed back into stone golem] */ flesh golem above, now gets transformed back into stone golem] */
@@ -780,12 +793,14 @@ rehumanize()
killer.format = KILLED_BY; killer.format = KILLED_BY;
done(DIED); done(DIED);
} }
if (!uarmg) selftouch(no_longer_petrify_resistant);
nomul(0); nomul(0);
context.botl = 1; context.botl = 1;
vision_full_recalc = 1; vision_full_recalc = 1;
(void) encumber_msg(); (void) encumber_msg();
retouch_equipment(2);
if (!uarmg) selftouch(no_longer_petrify_resistant);
} }
int int
+2 -10
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)pray.c 3.5 2006/08/21 */ /* SCCS Id: @(#)pray.c 3.5 2007/03/19 */
/* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */ /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1421,15 +1421,7 @@ verbalize("In return for thy service, I grant thee the gift of Immortality!");
consume_offering(otmp); consume_offering(otmp);
pline("%s accepts your allegiance.", a_gname()); pline("%s accepts your allegiance.", a_gname());
/* The player wears a helm of opposite alignment? */ uchangealign(altaralign, 0);
if (uarmh && uarmh->otyp == HELM_OF_OPPOSITE_ALIGNMENT)
u.ualignbase[A_CURRENT] = altaralign;
else
u.ualign.type = u.ualignbase[A_CURRENT] = altaralign;
u.ublessed = 0;
context.botl = 1;
You("have a sudden sense of a new direction.");
/* Beware, Conversion is costly */ /* Beware, Conversion is costly */
change_luck(-3); change_luck(-3);
u.ublesscnt += 300; u.ublesscnt += 300;