MCPcopy Create free account
hub / github.com/NetHack/NetHack / mfind0

Function mfind0

src/detect.c:1964–2013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1962}
1963
1964staticfn int
1965mfind0(struct monst *mtmp, boolean via_warning)
1966{
1967 coordxy x = mtmp->mx, y = mtmp->my;
1968 boolean found_something = FALSE;
1969
1970 if (via_warning && !warning_of(mtmp))
1971 return -1;
1972
1973 if (M_AP_TYPE(mtmp)) {
1974 seemimic(mtmp);
1975 found_something = TRUE;
1976 } else {
1977 /* this used to only be executed if a !canspotmon() test passed
1978 but that failed to bring sensed monsters out of hiding */
1979 found_something = !canspotmon(mtmp);
1980 if (mtmp->mundetected && (is_hider(mtmp->data)
1981 || hides_under(mtmp->data)
1982 || mtmp->data->mlet == S_EEL)) {
1983 if (via_warning && found_something) {
1984 set_msg_xy(x, y);
1985 Your("danger sense causes you to take a second %s.",
1986 Blind ? "to check nearby" : "look close by");
1987 display_nhwindow(WIN_MESSAGE, FALSE); /* flush messages */
1988 }
1989 mtmp->mundetected = 0;
1990 found_something = TRUE;
1991 }
1992 newsym(x, y);
1993 }
1994
1995 if (found_something) {
1996 if (!canspotmon(mtmp) && glyph_is_invisible(levl[x][y].glyph))
1997 return -1; /* Found invisible monster in square which already has
1998 * 'I' in it. Logically, this should still take time
1999 * and lead to `return 1', but if we did that the hero
2000 * would keep finding the same monster every turn. */
2001 exercise(A_WIS, TRUE);
2002 if (!canspotmon(mtmp)) {
2003 map_invisible(x, y);
2004 set_msg_xy(x, y);
2005 You_feel("an unseen monster!");
2006 } else if (!sensemon(mtmp)) {
2007 set_msg_xy(x, y);
2008 You("find %s.", mtmp->mtame ? y_monnam(mtmp) : a_monnam(mtmp));
2009 }
2010 return 1;
2011 }
2012 return 0;
2013}
2014
2015int
2016dosearch0(int aflag) /* intrinsic autosearch vs explicit searching */

Callers 2

dosearch0Function · 0.85
warnrevealFunction · 0.85

Calls 12

warning_ofFunction · 0.85
seemimicFunction · 0.85
set_msg_xyFunction · 0.85
YourFunction · 0.85
newsymFunction · 0.85
exerciseFunction · 0.85
map_invisibleFunction · 0.85
You_feelFunction · 0.85
sensemonFunction · 0.85
YouFunction · 0.85
y_monnamFunction · 0.85
a_monnamFunction · 0.85

Tested by

no test coverage detected