busy hero ignoring monster threat
Fix the problem reported by entrez of a zombie corpse reviving and crawling out of the ground while the hero was busy doing something (searching, digging, &c) and having the hero fail to react and just keep doing whatever the thing was because the zombie was already inside the range where a monster changes from no-threat to threat. Done in the monster creation routine so any new monster (including one revived from a corpse) that is visible,&c will cause the hero's action to be interrupted. Teleport arrival probably needs this too. Only interrupts an occupation, not other voluntary multi-turn actitivy such as running or traveling. That would be trivial to change ['if (g.occupation...' to 'if ((g.occupation || multi > 0)...'] but I'm not sure whether it ought to be extended to that.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 makemon.c $NHDT-Date: 1646694721 2022/03/07 23:12:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.199 $ */
|
||||
/* NetHack 3.7 makemon.c $NHDT-Date: 1651886995 2022/05/07 01:29:55 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.204 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1456,6 +1456,10 @@ makemon(
|
||||
: "",
|
||||
exclaim ? '!' : '.');
|
||||
}
|
||||
/* if discernable and a threat, stop fiddling while Rome burns */
|
||||
if (g.occupation)
|
||||
(void) dochugw(mtmp, TRUE);
|
||||
|
||||
/* TODO: unify with teleport appears msg */
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 mon.c $NHDT-Date: 1650836671 2022/04/24 21:44:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.423 $ */
|
||||
/* NetHack 3.7 mon.c $NHDT-Date: 1651886997 2022/05/07 01:29:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.424 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1064,7 +1064,7 @@ movemon(void)
|
||||
&& fightm(mtmp))
|
||||
continue; /* mon might have died */
|
||||
}
|
||||
if (dochugw(mtmp)) /* otherwise just move the monster */
|
||||
if (dochugw(mtmp, FALSE)) /* otherwise just move the monster */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 monmove.c $NHDT-Date: 1603507386 2020/10/24 02:43:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.146 $ */
|
||||
/* NetHack 3.7 monmove.c $NHDT-Date: 1651886999 2022/05/07 01:29:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.179 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2006. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -109,14 +109,25 @@ watch_on_duty(register struct monst* mtmp)
|
||||
}
|
||||
}
|
||||
|
||||
/* move a monster; if a threat to busy hero, stop doing whatever it is */
|
||||
int
|
||||
dochugw(register struct monst* mtmp)
|
||||
dochugw(
|
||||
register struct monst *mtmp,
|
||||
boolean dontchug) /* True: monster was just created, or maybe it has
|
||||
* teleported; perform stop-what-you're-doing-if-close-
|
||||
* enough-to-be-a-threat check but don't move mtmp */
|
||||
{
|
||||
int x = mtmp->mx, y = mtmp->my;
|
||||
boolean already_saw_mon = !g.occupation ? 0 : canspotmon(mtmp);
|
||||
int rd = dochug(mtmp);
|
||||
boolean already_saw_mon = ((dontchug || !g.occupation) ? 0
|
||||
: canspotmon(mtmp));
|
||||
int rd = dontchug ? 0 : dochug(mtmp);
|
||||
|
||||
/*
|
||||
* A similar check is in monster_nearby() in hack.c.
|
||||
* [The two checks have a lot of differences and chances are high
|
||||
* that some of those are unintentional.]
|
||||
*/
|
||||
|
||||
/* a similar check is in monster_nearby() in hack.c */
|
||||
/* check whether hero notices monster and stops current activity */
|
||||
if (g.occupation && !rd
|
||||
/* monster is hostile and can attack (or hallu distorts knowledge) */
|
||||
|
||||
Reference in New Issue
Block a user