From fe88fa80d82779986df494a10df950aa93d79cd7 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 27 May 2020 16:18:12 -0700 Subject: [PATCH] refine the issue #349 fix Accept or ignore the in-hell-only and non-in-hell-only flags on a monster type by monster type basis instead of all or nothing for a given mkclass() call. Prevents demon summoning outside of Gehennom from bringing in only succubi and incubi 10 times out of 11 and mixture of demons the other time. --- src/makemon.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/makemon.c b/src/makemon.c index 4dd4221fe..4278d5a46 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 makemon.c $NHDT-Date: 1590613502 2020/05/27 21:05:02 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.170 $ */ +/* NetHack 3.6 makemon.c $NHDT-Date: 1590621476 2020/05/27 23:17:56 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.171 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1663,7 +1663,7 @@ aligntyp atyp; { register int first, last, num = 0; int k, nums[SPECIAL_PM + 1]; /* +1: insurance for final return value */ - int maxmlev, gmask; + int maxmlev, gmask, gehennom = Inhell != 0; (void) memset((genericptr_t) nums, 0, sizeof nums); maxmlev = level_difficulty() >> 1; @@ -1685,23 +1685,23 @@ aligntyp atyp; return (struct permonst *) 0; } - gmask = (G_NOGEN | G_UNIQ); - /* traditionally mkclass() ignored hell-only and never-in-hell; - now we usually honor those but not all the time, mostly so that - the majority of major demons aren't constrained to Gehennom; - arch- and master liches are always so constrained (for creation; - lesser liches might grow up into them elsewhere) */ - if (rn2(9) || class == S_LICH) - gmask |= (Inhell ? G_NOHELL : G_HELL); - gmask &= ~spc; - gmask |= (spc & G_IGNORE); - /* Assumption #2: monsters of a given class are presented in ascending * order of strength. */ for (last = first; last < SPECIAL_PM && mons[last].mlet == class; last++) { if (atyp != A_NONE && sgn(mons[last].maligntyp) != sgn(atyp)) continue; + /* traditionally mkclass() ignored hell-only and never-in-hell; + now we usually honor those but not all the time, mostly so that + the majority of major demons aren't constrained to Gehennom; + arch- and master liches are always so constrained (for creation; + lesser liches might grow up into them elsewhere) */ + gmask = (G_NOGEN | G_UNIQ); + if (rn2(9) || class == S_LICH) + gmask |= (gehennom ? G_NOHELL : G_HELL); + gmask &= ~spc; + gmask |= (spc & G_IGNORE); + if (mk_gen_ok(last, G_GONE, gmask)) { /* consider it; don't reject a toostrong() monster if we don't have anything yet (num==0) or if it is the same @@ -1757,6 +1757,8 @@ int class; return NON_PM; gmask = (G_NOGEN | G_UNIQ); + /* mkclass() does this on a per monster type basis, but doing that here + would make the two loops inconsistent with each other for non L */ if (rn2(9) || class == S_LICH) gmask |= (Inhell ? G_NOHELL : G_HELL);