fix monster summoning message

From a bug report:
> If the Summon Nasties monster spell gates in two minions instead of one,
> the message still says "A monster appears from nowhere!"

The code wasn't counting any summoned monsters who had an opposite alignment
to the summoner.  It also assumed that the 10% chance for demon summoning
in Gehennom always yielded exactly one monster even though that can produce
zero or more than one.
This commit is contained in:
nethack.rankin
2004-12-21 04:27:34 +00:00
parent 38f9ba9a91
commit 3f2aa875bb
5 changed files with 24 additions and 20 deletions
+1
View File
@@ -78,6 +78,7 @@ co-aligned unicorns in bones could be hostile
finding "something" posing as a statue while Blind should map_invisible() finding "something" posing as a statue while Blind should map_invisible()
adding more candles than required to total 7 to a candelabrum which adding more candles than required to total 7 to a candelabrum which
already had between 1 and 6 gave an ungrammatical message already had between 1 and 6 gave an ungrammatical message
give correct message when a spellcasting monster summons other monsters
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
+1 -1
View File
@@ -1019,7 +1019,7 @@ E int FDECL(doseduce, (struct monst *));
/* ### minion.c ### */ /* ### minion.c ### */
E void FDECL(msummon, (struct monst *)); E int FDECL(msummon, (struct monst *));
E void FDECL(summon_minion, (ALIGNTYP_P,BOOLEAN_P)); E void FDECL(summon_minion, (ALIGNTYP_P,BOOLEAN_P));
E int FDECL(demon_talk, (struct monst *)); E int FDECL(demon_talk, (struct monst *));
E long FDECL(bribe, (struct monst *)); E long FDECL(bribe, (struct monst *));
+2 -2
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)mhitu.c 3.4 2004/11/11 */ /* SCCS Id: @(#)mhitu.c 3.4 2004/12/20 */
/* 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. */
@@ -471,7 +471,7 @@ mattacku(mtmp)
&& mtmp->data != &mons[PM_BALROG] && mtmp->data != &mons[PM_BALROG]
&& mtmp->data != &mons[PM_SUCCUBUS] && mtmp->data != &mons[PM_SUCCUBUS]
&& mtmp->data != &mons[PM_INCUBUS]) && mtmp->data != &mons[PM_INCUBUS])
if(!mtmp->mcan && !rn2(13)) msummon(mtmp); if (!mtmp->mcan && !rn2(13)) (void)msummon(mtmp);
/* Special lycanthrope handling code */ /* Special lycanthrope handling code */
if((mtmp->cham == CHAM_ORDINARY) && is_were(mdat) && !range2) { if((mtmp->cham == CHAM_ORDINARY) && is_were(mdat) && !range2) {
+11 -9
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)minion.c 3.4 2003/01/09 */ /* SCCS Id: @(#)minion.c 3.4 2004/12/20 */
/* 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. */
@@ -6,12 +6,12 @@
#include "emin.h" #include "emin.h"
#include "epri.h" #include "epri.h"
void int
msummon(mon) /* mon summons a monster */ msummon(mon) /* mon summons a monster */
struct monst *mon; struct monst *mon;
{ {
register struct permonst *ptr; struct permonst *ptr;
register int dtype = NON_PM, cnt = 0; int dtype = NON_PM, cnt = 0, result = 0;
aligntyp atyp; aligntyp atyp;
struct monst *mtmp; struct monst *mtmp;
@@ -60,7 +60,7 @@ struct monst *mon;
cnt = (!rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1; cnt = (!rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1;
} }
if (dtype == NON_PM) return; if (dtype == NON_PM) return 0;
/* sanity checks */ /* sanity checks */
if (cnt > 1 && (mons[dtype].geno & G_UNIQ)) cnt = 1; if (cnt > 1 && (mons[dtype].geno & G_UNIQ)) cnt = 1;
@@ -70,17 +70,19 @@ struct monst *mon;
*/ */
if (mvitals[dtype].mvflags & G_GONE) { if (mvitals[dtype].mvflags & G_GONE) {
dtype = ndemon(atyp); dtype = ndemon(atyp);
if (dtype == NON_PM) return; if (dtype == NON_PM) return 0;
} }
while (cnt > 0) { while (cnt > 0) {
mtmp = makemon(&mons[dtype], u.ux, u.uy, NO_MM_FLAGS); mtmp = makemon(&mons[dtype], u.ux, u.uy, NO_MM_FLAGS);
if (mtmp && (dtype == PM_ANGEL)) { if (mtmp) {
/* alignment should match the summoner */ result++;
EPRI(mtmp)->shralign = atyp; /* an angel's alignment should match the summoner */
if (dtype == PM_ANGEL) EPRI(mtmp)->shralign = atyp;
} }
cnt--; cnt--;
} }
return result;
} }
void void
+9 -8
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)wizard.c 3.4 2003/02/18 */ /* SCCS Id: @(#)wizard.c 3.4 2004/12/20 */
/* 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. */
@@ -416,14 +416,14 @@ nasty(mcast)
{ {
register struct monst *mtmp; register struct monst *mtmp;
register int i, j, tmp; register int i, j, tmp;
int castalign = (mcast ? mcast->data->maligntyp : -1); int castalign = (mcast ? sgn(mcast->data->maligntyp) : -1);
coord bypos; coord bypos;
int count=0; int count;
if(!rn2(10) && Inhell) { if(!rn2(10) && Inhell) {
msummon((struct monst *) 0); /* summons like WoY */ count = msummon((struct monst *) 0); /* summons like WoY */
count++;
} else { } else {
count = 0;
tmp = (u.ulevel > 3) ? u.ulevel/3 : 1; /* just in case -- rph */ tmp = (u.ulevel > 3) ? u.ulevel/3 : 1; /* just in case -- rph */
/* if we don't have a casting monster, the nasties appear around you */ /* if we don't have a casting monster, the nasties appear around you */
bypos.x = u.ux; bypos.x = u.ux;
@@ -450,10 +450,11 @@ nasty(mcast)
} else /* GENOD? */ } else /* GENOD? */
mtmp = makemon((struct permonst *)0, mtmp = makemon((struct permonst *)0,
bypos.x, bypos.y, NO_MM_FLAGS); bypos.x, bypos.y, NO_MM_FLAGS);
if(mtmp && (mtmp->data->maligntyp == 0 || if (mtmp) {
sgn(mtmp->data->maligntyp) == sgn(castalign)) ) {
count++; count++;
break; if (mtmp->data->maligntyp == 0 ||
sgn(mtmp->data->maligntyp) == castalign)
break;
} }
} }
} }