From 4b1116f4d0b2ebfd186acee0e3f1bdfdd176a519 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sat, 15 Nov 2008 20:38:02 +0000 Subject: [PATCH] fix #H1755 - feedback for clerical summoning when blind (trunk only) From a bug report, the feedback you get when a monster summons insects or snakes is the same when blind as when you can see. A comment in the code stated as much, but fixing it is relatively straightforward. (Or not; there are actually a lot of cases to be handled; this covers enough of them, I hope.) --- doc/fixes35.0 | 1 + include/extern.h | 2 +- src/mcastu.c | 64 +++++++++++++++++++++++++++++++----------------- src/minion.c | 10 +++++--- src/wizard.c | 6 ++--- 5 files changed, 53 insertions(+), 30 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 44edbacbe..0ebe06601 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -295,6 +295,7 @@ monsters who ate green slime corpses weren't turned into green slime "hand slip" while naming an object would never pick 'z' as a substitute letter hero would "gladly take off " for nymph or succubus even while asleep concealed mimic wasn't revealed if kicking attmpt yielded a clumsy miss +too accurate feedback given to a blinded hero when a monster summons insects Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index 190a3308f..6d525b2c3 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1126,7 +1126,7 @@ E int FDECL(doseduce, (struct monst *)); E void FDECL(newemin, (struct monst *)); E void FDECL(free_emin, (struct monst *)); -E int NDECL(monster_census); +E int FDECL(monster_census, (BOOLEAN_P)); E int FDECL(msummon, (struct monst *)); E void FDECL(summon_minion, (ALIGNTYP_P,BOOLEAN_P)); E int FDECL(demon_talk, (struct monst *)); diff --git a/src/mcastu.c b/src/mcastu.c index 022c76977..59be55f0c 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -537,46 +537,66 @@ int spellnum; struct permonst *pm = mkclass(S_ANT,0); struct monst *mtmp2 = (struct monst *)0; char let = (pm ? S_ANT : S_SNAKE); - boolean success; - int i; + boolean success = FALSE, seecaster; + int i, quan, oldseen, newseen; coord bypos; - int quan; + const char *fmt; + oldseen = monster_census(TRUE); quan = (mtmp->m_lev < 2) ? 1 : rnd((int)mtmp->m_lev / 2); if (quan < 3) quan = 3; - success = pm ? TRUE : FALSE; for (i = 0; i <= quan; i++) { if (!enexto(&bypos, mtmp->mux, mtmp->muy, mtmp->data)) break; if ((pm = mkclass(let,0)) != 0 && - (mtmp2 = makemon(pm, bypos.x, bypos.y, NO_MM_FLAGS)) != 0) { + (mtmp2 = makemon(pm, bypos.x, bypos.y, MM_ANGRY)) != 0) { success = TRUE; mtmp2->msleeping = mtmp2->mpeaceful = mtmp2->mtame = 0; set_malign(mtmp2); } } - /* Not quite right: - * -- message doesn't always make sense for unseen caster (particularly - * the first message) - * -- message assumes plural monsters summoned (non-plural should be - * very rare, unlike in nasty()) - * -- message assumes plural monsters seen - */ - if (!success) - pline("%s casts at a clump of sticks, but nothing happens.", - Monnam(mtmp)); + newseen = monster_census(TRUE); + + /* not canspotmon(), which includes unseen things sensed via warning */ + seecaster = canseemon(mtmp) || tp_sensemon(mtmp) || Detect_monsters; + + fmt = 0; + if (!seecaster) { + char *arg; /* [not const: upstart(N==1 ? an() : makeplural())] */ + const char *what = (let == S_SNAKE) ? "snake" : "insect"; + + if (newseen <= oldseen || Unaware) { + /* unseen caster fails or summons unseen critters, + or unconscious hero ("You dream that you hear...") */ + You_hear("someone summoning %s.", makeplural(what)); + } else { + /* unseen caster summoned seen critter(s) */ + arg = (newseen == oldseen + 1) ? an(what) : makeplural(what); + if (!Deaf) + You_hear("someone summoning something, and %s %s.", + arg, vtense(arg, "appear")); + else + pline("%s %s.", upstart(arg), vtense(arg, "appear")); + } + + /* seen caster, possibly producing unseen--or just one--critters; + hero is told what the caster is doing and doesn't necessarily + observe complete accuracy of that caster's results (in other + words, no need to fuss with visibility or singularization; + player is told what's happening even if hero is unconscious) */ + } else if (!success) + fmt = "%s casts at a clump of sticks, but nothing happens."; else if (let == S_SNAKE) - pline("%s transforms a clump of sticks into snakes!", - Monnam(mtmp)); + fmt = "%s transforms a clump of sticks into snakes!"; else if (Invisible && !perceives(mtmp->data) && (mtmp->mux != u.ux || mtmp->muy != u.uy)) - pline("%s summons insects around a spot near you!", - Monnam(mtmp)); + fmt = "%s summons insects around a spot near you!"; else if (Displaced && (mtmp->mux != u.ux || mtmp->muy != u.uy)) - pline("%s summons insects around your displaced image!", - Monnam(mtmp)); + fmt = "%s summons insects around your displaced image!"; else - pline("%s summons insects!", Monnam(mtmp)); + fmt = "%s summons insects!"; + if (fmt) pline(fmt, Monnam(mtmp)); + dmg = 0; break; } diff --git a/src/minion.c b/src/minion.c index c56f8d3b1..e320cd048 100644 --- a/src/minion.c +++ b/src/minion.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)minion.c 3.5 2007/04/15 */ +/* SCCS Id: @(#)minion.c 3.5 2008/11/14 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -28,13 +28,15 @@ struct monst *mtmp; /* count the number of monsters on the level */ int -monster_census() +monster_census(spotted) +boolean spotted; /* seen|sensed vs all */ { struct monst *mtmp; int count = 0; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; + if (spotted && !canspotmon(mtmp)) continue; ++count; } return count; @@ -108,7 +110,7 @@ struct monst *mon; /* some candidates can generate a group of monsters, so simple count of non-null makemon() result is not sufficient */ - census = monster_census(); + census = monster_census(FALSE); while (cnt > 0) { mtmp = makemon(&mons[dtype], u.ux, u.uy, MM_EMIN); @@ -128,7 +130,7 @@ struct monst *mon; } /* how many monsters exist now compared to before? */ - if (result) result = monster_census() - census; + if (result) result = monster_census(FALSE) - census; return result; } diff --git a/src/wizard.c b/src/wizard.c index 73d184c9b..33646c8fd 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)wizard.c 3.5 2007/08/26 */ +/* SCCS Id: @(#)wizard.c 3.5 2008/11/14 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -431,7 +431,7 @@ nasty(mcast) /* some candidates may be created in groups, so simple count of non-null makemon() return is inadequate */ - census = monster_census(); + census = monster_census(FALSE); if(!rn2(10) && Inhell) { count = msummon((struct monst *) 0); /* summons like WoY */ @@ -472,7 +472,7 @@ nasty(mcast) } } - if (count) count = monster_census() - census; + if (count) count = monster_census(FALSE) - census; return count; }