From: Pasi Kallinen Date: Thu, 14 Jul 2022 11:04:24 +0000 (+0300) Subject: Blessed potion of polymorph asks user for monster to poly into X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=486ed290779a35d24b785a711d094194d3db8eaf;p=nethack Blessed potion of polymorph asks user for monster to poly into ... unless there's some other form that would override the choice, such as a worn dragon armor, lycanthropy, or vampirism. The polymorph will be in effect for 10-24 turns. --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index a4a6afd82..8f465807e 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -957,6 +957,7 @@ if #wizmakemap was used to generate a replacement level while any shopkeeper, temple priest, or vault guard from the level was off of it at the time, the monster's eshk, epri, or egd data became invalid and would cause trouble if the monster returned to its 'home' level +blessed potion of polymorph will prompt user for monster to poly into Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/include/hack.h b/include/hack.h index 7ed89d8bc..6b14d5e86 100644 --- a/include/hack.h +++ b/include/hack.h @@ -81,6 +81,15 @@ enum dismount_types { DISMOUNT_BYCHOICE = 6 }; +/* polyself flags */ +enum polyself_flags { + POLY_NOFLAGS = 0x00, + POLY_CONTROLLED = 0x01, + POLY_MONSTER = 0x02, + POLY_REVERT = 0x04, + POLY_LOW_CTRL = 0x08 +}; + /* sellobj_state() states */ #define SELL_NORMAL (0) #define SELL_DELIBERATE (1) diff --git a/src/allmain.c b/src/allmain.c index a10faacac..97af0626a 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -292,7 +292,7 @@ moveloop_core(void) if (g.multi >= 0) { stop_occupation(); if (mvl_change == 1) - polyself(0); + polyself(POLY_NOFLAGS); else you_were(); mvl_change = 0; diff --git a/src/cmd.c b/src/cmd.c index 2ce5e5b61..b7858d4f7 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1490,7 +1490,7 @@ wiz_panic(void) static int wiz_polyself(void) { - polyself(1); + polyself(POLY_CONTROLLED); return ECMD_OK; } diff --git a/src/eat.c b/src/eat.c index 5005ca7b9..5dfa8c597 100644 --- a/src/eat.c +++ b/src/eat.c @@ -1194,7 +1194,7 @@ cpostfx(int pm) You("%s.", (pm == PM_GENETIC_ENGINEER) ? "undergo a freakish metamorphosis" : "feel a change coming over you"); - polyself(0); + polyself(POLY_NOFLAGS); } break; case PM_DISPLACER_BEAST: diff --git a/src/fountain.c b/src/fountain.c index d7b62008a..13203b330 100644 --- a/src/fountain.c +++ b/src/fountain.c @@ -632,7 +632,7 @@ drinksink(void) pline("This %s contains toxic wastes!", hliquid("water")); if (!Unchanging) { You("undergo a freakish metamorphosis!"); - polyself(0); + polyself(POLY_NOFLAGS); } break; /* more odd messages --JJB */ diff --git a/src/mhitm.c b/src/mhitm.c index b9b2b5ac2..613e5ee0d 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -992,7 +992,7 @@ mon_poly(struct monst *magr, struct monst *mdef, int dmg) /* system shock might take place in polyself() */ if (u.ulycn == NON_PM) { You("are subjected to a freakish metamorphosis."); - polyself(0); + polyself(POLY_NOFLAGS); } else if (u.umonnum != u.ulycn) { You_feel("an unnatural urge coming on."); you_were(); diff --git a/src/polyself.c b/src/polyself.c index 5fae61254..7c00d5993 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -438,9 +438,10 @@ polyself(int psflags) { char buf[BUFSZ]; int old_light, new_light, mntmp, class, tryct, gvariant = NEUTRAL; - boolean forcecontrol = (psflags == 1), - monsterpoly = (psflags == 2), - formrevert = (psflags == 3), + boolean forcecontrol = ((psflags & POLY_CONTROLLED) != 0), + low_control = ((psflags & POLY_LOW_CTRL) != 0), + monsterpoly = ((psflags & POLY_MONSTER) != 0), + formrevert = ((psflags & POLY_REVERT) != 0), draconian = (uarm && Is_dragon_armor(uarm)), iswere = (u.ulycn >= LOW_PM), isvamp = (is_vampire(g.youmonst.data) @@ -469,6 +470,11 @@ polyself(int psflags) monsterpoly = TRUE; controllable_poly = FALSE; } + + if (forcecontrol && low_control + && (draconian || monsterpoly || isvamp || iswere)) + forcecontrol = FALSE; + if (monsterpoly && isvamp) goto do_vampyr; @@ -1681,7 +1687,7 @@ dopoly(void) struct permonst *savedat = g.youmonst.data; if (is_vampire(g.youmonst.data) || is_vampshifter(&g.youmonst)) { - polyself(2); + polyself(POLY_MONSTER); if (savedat != g.youmonst.data) { You("transform into %s.", an(pmname(g.youmonst.data, Ugender))); diff --git a/src/potion.c b/src/potion.c index 29769e861..aad297451 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1295,11 +1295,18 @@ peffect_acid(struct obj *otmp) } static void -peffect_polymorph(struct obj *otmp UNUSED) +peffect_polymorph(struct obj *otmp) { You_feel("a little %s.", Hallucination ? "normal" : "strange"); - if (!Unchanging) - polyself(0); + if (!Unchanging) { + if (!otmp->blessed || (u.umonnum != u.umonster)) + polyself(POLY_NOFLAGS); + else { + polyself(POLY_CONTROLLED|POLY_LOW_CTRL); + if (u.mtimedone && u.umonnum != u.umonster) + u.mtimedone = min(u.mtimedone, rn2(15) + 10); + } + } } int @@ -1654,7 +1661,7 @@ potionhit(struct monst *mon, struct obj *obj, int how) case POT_POLYMORPH: You_feel("a little %s.", Hallucination ? "normal" : "strange"); if (!Unchanging && !Antimagic) - polyself(0); + polyself(POLY_NOFLAGS); break; case POT_ACID: if (!Acid_resistance) { diff --git a/src/read.c b/src/read.c index 0404faa2b..f0bb880cc 100644 --- a/src/read.c +++ b/src/read.c @@ -2550,7 +2550,7 @@ do_class_genocide(void) if (Upolyd && vampshifted(&g.youmonst) /* current shifted form or base vampire form */ && (i == u.umonnum || i == g.youmonst.cham)) - polyself(3); /* vampshifter back to vampire */ + polyself(POLY_REVERT); /* vampshifter back to vampire */ if (Upolyd && i == u.umonnum) { u.mh = -1; if (Unchanging) { @@ -2673,7 +2673,7 @@ do_genocide(int how) /* first revert if current shifted form or base vampire form */ if (Upolyd && vampshifted(&g.youmonst) && (mndx == u.umonnum || mndx == g.youmonst.cham)) - polyself(3); /* vampshifter (bat, &c) back to vampire */ + polyself(POLY_REVERT); /* vampshifter (bat, &c) back to vampire */ /* Although "genus" is Latin for race, the hero benefits * from both race and role; thus genocide affects either. */ diff --git a/src/trap.c b/src/trap.c index ebff33dd7..d9ec22cf0 100644 --- a/src/trap.c +++ b/src/trap.c @@ -2162,7 +2162,7 @@ trapeffect_poly_trap( deltrap(trap); /* delete trap before polymorph */ newsym(u.ux, u.uy); /* get rid of trap symbol */ You_feel("a change coming over you."); - polyself(0); + polyself(POLY_NOFLAGS); } } else { boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed); diff --git a/src/zap.c b/src/zap.c index 70d275484..06db5a3c2 100644 --- a/src/zap.c +++ b/src/zap.c @@ -2572,7 +2572,7 @@ zapyourself(struct obj *obj, boolean ordinary) case SPE_POLYMORPH: if (!Unchanging) { learn_it = TRUE; - polyself(0); + polyself(POLY_NOFLAGS); } break;