E int NDECL(openit);
E boolean FDECL(detecting, (void (*)(int, int, genericptr)));
E void FDECL(find_trap, (struct trap *));
+E void NDECL(warnreveal);
E int FDECL(dosearch0, (int));
E int NDECL(dosearch);
E void NDECL(sokoban_detect);
E int FDECL(glyph_at, (XCHAR_P, XCHAR_P));
E void NDECL(set_wall_state);
E void FDECL(unset_seenv, (struct rm *, int, int, int, int));
+E int FDECL(warning_of, (struct monst *));
/* ### do.c ### */
STATIC_DCL void FDECL(show_map_spot, (int, int));
STATIC_PTR void FDECL(findone, (int, int, genericptr_t));
STATIC_PTR void FDECL(openone, (int, int, genericptr_t));
+STATIC_DCL int FDECL(mfind0, (struct monst *, BOOLEAN_P));
/* Recursively search obj for an object in class oclass and return 1st found
*/
}
}
+STATIC_OVL int
+mfind0(mtmp, via_warning)
+struct monst *mtmp;
+boolean via_warning;
+{
+ xchar x = mtmp->mx,
+ y = mtmp->my;
+
+ if (via_warning && !warning_of(mtmp))
+ return -1;
+
+ if (mtmp->m_ap_type) {
+ seemimic(mtmp);
+ find:
+ exercise(A_WIS, TRUE);
+ if (!canspotmon(mtmp)) {
+ if (glyph_is_invisible(levl[x][y].glyph)) {
+ /* found invisible monster in a square
+ * which already has an 'I' in it.
+ * Logically, this should still take
+ * time and lead to a return(1), but
+ * if we did that the player would keep
+ * finding the same monster every turn.
+ */
+ return -1;
+ } else {
+ You_feel("an unseen monster!");
+ map_invisible(x, y);
+ }
+ } else if (!sensemon(mtmp))
+ You("find %s.", mtmp->mtame
+ ? y_monnam(mtmp)
+ : a_monnam(mtmp));
+ return 1;
+ }
+ if (!canspotmon(mtmp)) {
+ if (mtmp->mundetected
+ && (is_hider(mtmp->data)
+ || mtmp->data->mlet == S_EEL))
+ if (via_warning) {
+ Your("warning senses cause you to take a second %s.",
+ Blind ? "to check nearby" : "look close by");
+ display_nhwindow(WIN_MESSAGE, FALSE); /* flush messages */
+ }
+ mtmp->mundetected = 0;
+ newsym(x, y);
+ goto find;
+ }
+ return 0;
+}
+
int
dosearch0(aflag)
register int aflag; /* intrinsic autosearch vs explicit searching */
} else {
/* Be careful not to find anything in an SCORR or SDOOR */
if ((mtmp = m_at(x, y)) != 0 && !aflag) {
- if (mtmp->m_ap_type) {
- seemimic(mtmp);
- find:
- exercise(A_WIS, TRUE);
- if (!canspotmon(mtmp)) {
- if (glyph_is_invisible(levl[x][y].glyph)) {
- /* found invisible monster in a square
- * which already has an 'I' in it.
- * Logically, this should still take
- * time and lead to a return(1), but
- * if we did that the player would keep
- * finding the same monster every turn.
- */
- continue;
- } else {
- You_feel("an unseen monster!");
- map_invisible(x, y);
- }
- } else if (!sensemon(mtmp))
- You("find %s.", mtmp->mtame
- ? y_monnam(mtmp)
- : a_monnam(mtmp));
- return 1;
- }
- if (!canspotmon(mtmp)) {
- if (mtmp->mundetected
- && (is_hider(mtmp->data)
- || mtmp->data->mlet == S_EEL))
- mtmp->mundetected = 0;
- newsym(x, y);
- goto find;
- }
+ int mfres = mfind0(mtmp, 0);
+
+ if (mfres == -1)
+ continue;
+ else if (mfres > 0)
+ return mfres;
}
/* see if an invisible monster has moved--if Blind,
return dosearch0(0);
}
+void
+warnreveal()
+{
+ xchar x, y;
+ struct monst *mtmp;
+
+ for (x = u.ux - 1; x < u.ux + 2; x++)
+ for (y = u.uy - 1; y < u.uy + 2; y++) {
+ if (!isok(x, y))
+ continue;
+ if (x == u.ux && y == u.uy)
+ continue;
+
+ if ((mtmp = m_at(x, y)) != 0
+ && warning_of(mtmp) && mtmp->mundetected)
+ (void) mfind0(mtmp, 1); /* via_warning */
+ }
+}
+
/* Pre-map the sokoban levels */
void
sokoban_detect()
register struct monst *mon;
{
int x = mon->mx, y = mon->my;
- int wl = (int) (mon->m_lev / 4);
int glyph;
if (mon_warning(mon)) {
- if (wl > WARNCOUNT - 1)
- wl = WARNCOUNT - 1;
- /* 3.4.1: this really ought to be rn2(WARNCOUNT), but value "0"
- isn't handled correctly by the what_is routine so avoid it */
- if (Hallucination)
- wl = rn1(WARNCOUNT - 1, 1);
+ int wl = Hallucination ? rn1(WARNCOUNT - 1, 1) : warning_of(mon);
glyph = warning_to_glyph(wl);
} else if (MATCH_WARN_OF_MON(mon)) {
glyph = mon_to_glyph(mon);
show_glyph(x, y, glyph);
}
+int
+warning_of(mon)
+struct monst *mon;
+{
+ int wl = 0, tmp = 0;
+ if (mon_warning(mon)) {
+ tmp = (int) (mon->m_lev / 4); /* match display.h */
+ wl = (tmp > WARNCOUNT - 1) ? WARNCOUNT - 1 : tmp;
+ }
+ return wl;
+}
+
/*
* feel_newsym()