Skip to content

Commit

Permalink
refine the issue #349 fix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PatR committed May 27, 2020
1 parent c29ffe1 commit fe88fa8
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions 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. */
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit fe88fa8

Please sign in to comment.