fix pull request #367 - mind flayer psychic blast

hitting a hidden monster didn't reveal that monster.  It stayed
hidden despite the feedback describing it as if it could be seen.

The pull request's two line fix handled a monster's blast hitting
another monster but left two related issues as-is:  monster's blast
hitting hidden poly'd hero left hero unrevealed and poly'd hero's
blast left hidden monster unrevealed.  Same code, different bug:
poly'd hero's blast affected mindless monsters.

This unhides an affected target before the message about it being
hit rather than after.  That would look better if preceded by a
message describing the object (mimic or hides-under) or furniture
(mimic) or empty spot (ceiling hider) as being or concealing a
monster but I didn't put in sufficient effort to accomplish that.

Fixes #367
Fixes #362
This commit is contained in:
PatR
2020-07-14 04:55:53 -07:00
parent 12498ffa44
commit a37975b625
4 changed files with 46 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mon.c $NHDT-Date: 1594630713 2020/07/13 08:58:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.339 $ */
/* NetHack 3.6 mon.c $NHDT-Date: 1594727746 2020/07/14 11:55:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.340 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3235,8 +3235,11 @@ register struct monst *mtmp;
boolean via_attack;
{
mtmp->msleeping = 0;
if (M_AP_TYPE(mtmp)) {
seemimic(mtmp);
if (M_AP_TYPE(mtmp) != M_AP_NOTHING) {
/* mimics come out of hiding, but disguised Wizard doesn't
have to lose his disguise */
if (M_AP_TYPE(mtmp) != M_AP_MONSTER)
seemimic(mtmp);
} else if (g.context.forcefight && !g.context.mon_moving
&& mtmp->mundetected) {
mtmp->mundetected = 0;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 monmove.c $NHDT-Date: 1586091452 2020/04/05 12:57:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.137 $ */
/* NetHack 3.6 monmove.c $NHDT-Date: 1594727747 2020/07/14 11:55:47 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.141 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */
@@ -562,13 +562,27 @@ register struct monst *mtmp;
&& (!Conflict || resist(mtmp, RING_CLASS, 0, 0))) {
pline("It feels quite soothing.");
} else if (!u.uinvulnerable) {
register boolean m_sen = sensemon(mtmp);
int dmg;
boolean m_sen = sensemon(mtmp);
if (m_sen || (Blind_telepat && rn2(2)) || !rn2(10)) {
int dmg;
/* hiding monsters are brought out of hiding when hit by
a psychic blast, so do the same for hiding poly'd hero */
if (u.uundetected) {
u.uundetected = 0;
newsym(u.ux, u.uy);
} else if (U_AP_TYPE != M_AP_NOTHING
/* hero has no way to hide as monster but
check for that theoretical case anyway */
&& U_AP_TYPE != M_AP_MONSTER) {
g.youmonst.m_ap_type = M_AP_NOTHING;
g.youmonst.mappearance = 0;
newsym(u.ux, u.uy);
}
pline("It locks on to your %s!",
m_sen ? "telepathy" : Blind_telepat ? "latent telepathy"
: "mind");
m_sen ? "telepathy"
: Blind_telepat ? "latent telepathy"
: "mind"); /* note: hero is never mindless */
dmg = rnd(15);
if (Half_spell_damage)
dmg = (dmg + 1) / 2;
@@ -587,13 +601,13 @@ register struct monst *mtmp;
continue;
if ((telepathic(m2->data) && (rn2(2) || m2->mblinded))
|| !rn2(10)) {
/* wake it up first, to bring hidden monster out of hiding */
wakeup(m2, FALSE);
if (cansee(m2->mx, m2->my))
pline("It locks on to %s.", mon_nam(m2));
m2->mhp -= rnd(15);
if (DEADMONSTER(m2))
monkilled(m2, "", AD_DRIN);
else
m2->msleeping = 0;
}
}
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 polyself.c $NHDT-Date: 1583073991 2020/03/01 14:46:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.152 $ */
/* NetHack 3.6 polyself.c $NHDT-Date: 1594727748 2020/07/14 11:55:48 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.154 $ */
/* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
@@ -1581,10 +1581,12 @@ dopoly()
return 1;
}
/* #monster for hero-as-mind_flayer giving psychic blast */
int
domindblast()
{
struct monst *mtmp, *nmon;
int dmg;
if (u.uen < 10) {
You("concentrate but lack the energy to maintain doing so.");
@@ -1605,12 +1607,21 @@ domindblast()
continue;
if (mtmp->mpeaceful)
continue;
if (mindless(mtmp->data))
continue;
u_sen = telepathic(mtmp->data) && !mtmp->mcansee;
if (u_sen || (telepathic(mtmp->data) && rn2(2)) || !rn2(10)) {
dmg = rnd(15);
/* wake it up first, to bring hidden monster out of hiding;
but in case it is currently peaceful, don't make it hostile
unless it will survive the psychic blast, otherwise hero
would avoid the penalty for killing it while peaceful */
wakeup(mtmp, (dmg > mtmp->mhp) ? TRUE : FALSE);
You("lock in on %s %s.", s_suffix(mon_nam(mtmp)),
u_sen ? "telepathy"
: telepathic(mtmp->data) ? "latent telepathy" : "mind");
mtmp->mhp -= rnd(15);
: telepathic(mtmp->data) ? "latent telepathy"
: "mind");
mtmp->mhp -= dmg;
if (DEADMONSTER(mtmp))
killed(mtmp);
}