fix issue #351 - summoned critters while Hallu

If a monster uses the 'summon insects' spell (which will resort to
snakes if all 'a' class critters are genocided or extinct) while the
hero is hallucinating, report the summoning of something unusual
rather than of insects or snakes.  I bypassed "random creature"
direct to "hallucinatory creature" for the something unusual.

Fixes #351
This commit is contained in:
PatR
2020-05-30 22:48:18 -07:00
parent 54bea16f0e
commit 8a91a22df9
3 changed files with 32 additions and 26 deletions
+2 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1590870784 2020/05/30 20:33:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.844 $ */ /* NetHack 3.6 extern.h $NHDT-Date: 1590904081 2020/05/31 05:48:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.847 $ */
/* Copyright (c) Steve Creps, 1988. */ /* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -464,6 +464,7 @@ E char *FDECL(mon_nam_too, (struct monst *, struct monst *));
E char *FDECL(monverbself, (struct monst *, char *, E char *FDECL(monverbself, (struct monst *, char *,
const char *, const char *)); const char *, const char *));
E char *FDECL(minimal_monnam, (struct monst *, BOOLEAN_P)); E char *FDECL(minimal_monnam, (struct monst *, BOOLEAN_P));
E char *FDECL(bogusmon, (char *, char *));
E char *FDECL(rndmonnam, (char *)); E char *FDECL(rndmonnam, (char *));
E const char *FDECL(hcolor, (const char *)); E const char *FDECL(hcolor, (const char *));
E const char *NDECL(rndcolor); E const char *NDECL(rndcolor);
+2 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 do_name.c $NHDT-Date: 1586940208 2020/04/15 08:43:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.178 $ */ /* NetHack 3.6 do_name.c $NHDT-Date: 1590904090 2020/05/31 05:48:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.181 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Pasi Kallinen, 2018. */ /*-Copyright (c) Pasi Kallinen, 2018. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -22,7 +22,6 @@ static boolean FDECL(alreadynamed, (struct monst *, char *, char *));
static void FDECL(do_oname, (struct obj *)); static void FDECL(do_oname, (struct obj *));
static char *FDECL(docall_xname, (struct obj *)); static char *FDECL(docall_xname, (struct obj *));
static void NDECL(namefloorobj); static void NDECL(namefloorobj);
static char *FDECL(bogusmon, (char *,char *));
extern const char what_is_an_unknown_object[]; /* from pager.c */ extern const char what_is_an_unknown_object[]; /* from pager.c */
@@ -2059,7 +2058,7 @@ boolean ckloc;
} }
/* fake monsters used to be in a hard-coded array, now in a data file */ /* fake monsters used to be in a hard-coded array, now in a data file */
static char * char *
bogusmon(buf, code) bogusmon(buf, code)
char *buf, *code; char *buf, *code;
{ {
+28 -22
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mcastu.c $NHDT-Date: 1580633721 2020/02/02 08:55:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.64 $ */ /* NetHack 3.6 mcastu.c $NHDT-Date: 1590904092 2020/05/31 05:48:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.67 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -584,11 +584,11 @@ int spellnum;
left, go for (sticks to) snakes. -3. */ left, go for (sticks to) snakes. -3. */
struct permonst *pm = mkclass(S_ANT, 0); struct permonst *pm = mkclass(S_ANT, 0);
struct monst *mtmp2 = (struct monst *) 0; struct monst *mtmp2 = (struct monst *) 0;
char let = (pm ? S_ANT : S_SNAKE); char whatbuf[QBUFSZ], let = (pm ? S_ANT : S_SNAKE);
boolean success = FALSE, seecaster; boolean success = FALSE, seecaster;
int i, quan, oldseen, newseen; int i, quan, oldseen, newseen;
coord bypos; coord bypos;
const char *fmt; const char *fmt, *what;
oldseen = monster_census(TRUE); oldseen = monster_census(TRUE);
quan = (mtmp->m_lev < 2) ? 1 : rnd((int) mtmp->m_lev / 2); quan = (mtmp->m_lev < 2) ? 1 : rnd((int) mtmp->m_lev / 2);
@@ -606,22 +606,26 @@ int spellnum;
} }
newseen = monster_census(TRUE); newseen = monster_census(TRUE);
/* not canspotmon(), which includes unseen things sensed via warning /* not canspotmon() which includes unseen things sensed via warning */
*/
seecaster = canseemon(mtmp) || tp_sensemon(mtmp) || Detect_monsters; seecaster = canseemon(mtmp) || tp_sensemon(mtmp) || Detect_monsters;
what = (let == S_SNAKE) ? "snakes" : "insects";
if (Hallucination)
what = makeplural(bogusmon(whatbuf, (char *) 0));
fmt = 0; fmt = 0;
if (!seecaster) { if (!seecaster) {
char *arg; /* [not const: upstart(N==1 ? an() : makeplural())] */
const char *what = (let == S_SNAKE) ? "snake" : "insect";
if (newseen <= oldseen || Unaware) { if (newseen <= oldseen || Unaware) {
/* unseen caster fails or summons unseen critters, /* unseen caster fails or summons unseen critters,
or unconscious hero ("You dream that you hear...") */ or unconscious hero ("You dream that you hear...") */
You_hear("someone summoning %s.", makeplural(what)); You_hear("someone summoning %s.", what);
} else { } else {
char *arg;
if (what != whatbuf)
what = strcpy(whatbuf, what);
/* unseen caster summoned seen critter(s) */ /* unseen caster summoned seen critter(s) */
arg = (newseen == oldseen + 1) ? an(what) : makeplural(what); arg = (newseen == oldseen + 1) ? an(makesingular(what))
: whatbuf;
if (!Deaf) if (!Deaf)
You_hear("someone summoning something, and %s %s.", arg, You_hear("someone summoning something, and %s %s.", arg,
vtense(arg, "appear")); vtense(arg, "appear"));
@@ -634,19 +638,21 @@ int spellnum;
observe complete accuracy of that caster's results (in other observe complete accuracy of that caster's results (in other
words, no need to fuss with visibility or singularization; words, no need to fuss with visibility or singularization;
player is told what's happening even if hero is unconscious) */ player is told what's happening even if hero is unconscious) */
} else if (!success) } else if (!success) {
fmt = "%s casts at a clump of sticks, but nothing happens."; fmt = "%s casts at a clump of sticks, but nothing happens.%s";
else if (let == S_SNAKE) what = "";
fmt = "%s transforms a clump of sticks into snakes!"; } else if (let == S_SNAKE) {
else if (Invis && !perceives(mtmp->data) fmt = "%s transforms a clump of sticks into %s!";
&& (mtmp->mux != u.ux || mtmp->muy != u.uy)) } else if (Invis && !perceives(mtmp->data)
fmt = "%s summons insects around a spot near you!"; && (mtmp->mux != u.ux || mtmp->muy != u.uy)) {
else if (Displaced && (mtmp->mux != u.ux || mtmp->muy != u.uy)) fmt = "%s summons %s around a spot near you!";
fmt = "%s summons insects around your displaced image!"; } else if (Displaced && (mtmp->mux != u.ux || mtmp->muy != u.uy)) {
else fmt = "%s summons %s around your displaced image!";
fmt = "%s summons insects!"; } else {
fmt = "%s summons %s!";
}
if (fmt) if (fmt)
pline(fmt, Monnam(mtmp)); pline(fmt, Monnam(mtmp), what);
dmg = 0; dmg = 0;
break; break;