dochugw(mon, X)

Reverse the sense of dochugw()'s new 'X' argument. Use True for the
usual case and False for the special case rather than the other way
around.

Call the special case variant when a monster teleports so that hero
stops occupation if the monster jumps to a position where it becomes
a threat.
This commit is contained in:
PatR
2022-05-07 09:11:09 -07:00
parent 0a171bb862
commit 4fbda9ea34
4 changed files with 18 additions and 12 deletions

View File

@@ -1458,7 +1458,7 @@ makemon(
} }
/* if discernable and a threat, stop fiddling while Rome burns */ /* if discernable and a threat, stop fiddling while Rome burns */
if (g.occupation) if (g.occupation)
(void) dochugw(mtmp, TRUE); (void) dochugw(mtmp, FALSE);
/* TODO: unify with teleport appears msg */ /* TODO: unify with teleport appears msg */
} }

View File

@@ -1064,7 +1064,7 @@ movemon(void)
&& fightm(mtmp)) && fightm(mtmp))
continue; /* mon might have died */ continue; /* mon might have died */
} }
if (dochugw(mtmp, FALSE)) /* otherwise just move the monster */ if (dochugw(mtmp, TRUE)) /* otherwise just move the monster */
continue; continue;
} }

View File

@@ -113,14 +113,15 @@ watch_on_duty(register struct monst* mtmp)
int int
dochugw( dochugw(
register struct monst *mtmp, register struct monst *mtmp,
boolean dontchug) /* True: monster was just created, or maybe it has boolean chug) /* True: monster is moving;
* teleported; perform stop-what-you're-doing-if-close- * False: monster was just created or has teleported
* enough-to-be-a-threat check but don't move mtmp */ * so 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; int x = mtmp->mx, y = mtmp->my; /* 'mtmp's location before dochug() */
boolean already_saw_mon = ((dontchug || !g.occupation) ? 0 /* skip canspotmon() if occupation is Null */
: canspotmon(mtmp)); boolean already_saw_mon = (chug && g.occupation) ? canspotmon(mtmp) : 0;
int rd = dontchug ? 0 : dochug(mtmp); int rd = chug ? dochug(mtmp) : 0;
/* /*
* A similar check is in monster_nearby() in hack.c. * A similar check is in monster_nearby() in hack.c.

View File

@@ -1324,15 +1324,16 @@ rloc_to_core(
Monnam(mtmp), Monnam(mtmp),
next2u(x, y) ? " next to you" next2u(x, y) ? " next to you"
: (distu(x, y) <= (BOLT_LIM * BOLT_LIM)) ? " close by" : (distu(x, y) <= (BOLT_LIM * BOLT_LIM)) ? " close by"
: (distu(x, y) < distu(oldx, oldy)) ? " closer to you" : (distu(x, y) < distu(oldx, oldy)) ? " closer to you"
: " further away"); : " further away");
} else { } else {
pline("%s %s%s%s!", pline("%s %s%s%s!",
appearmsg ? Amonnam(mtmp) : Monnam(mtmp), appearmsg ? Amonnam(mtmp) : Monnam(mtmp),
appearmsg ? "suddenly " : "", appearmsg ? "suddenly " : "",
!Blind ? "appears" : "arrives", !Blind ? "appears" : "arrives",
next2u(x, y) ? " next to you" next2u(x, y) ? " next to you"
: (distu(x, y) <= (BOLT_LIM * BOLT_LIM)) ? " close by" : ""); : (distu(x, y) <= (BOLT_LIM * BOLT_LIM)) ? " close by"
: "");
} }
} }
@@ -1342,6 +1343,10 @@ rloc_to_core(
if (resident_shk && !inhishop(mtmp)) if (resident_shk && !inhishop(mtmp))
make_angry_shk(mtmp, oldx, oldy); make_angry_shk(mtmp, oldx, oldy);
/* if hero is busy, maybe stop occupation */
if (g.occupation)
(void) dochugw(mtmp, FALSE);
/* trapped monster teleported away */ /* trapped monster teleported away */
if (mtmp->mtrapped && !mtmp->wormno) if (mtmp->mtrapped && !mtmp->wormno)
(void) mintrap(mtmp, NO_TRAP_FLAGS); (void) mintrap(mtmp, NO_TRAP_FLAGS);