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

Function mfndpos

src/mon.c:2139–2382  ·  view source on GitHub ↗

return number of acceptable neighbour positions */

Source from the content-addressed store, hash-verified

2137
2138/* return number of acceptable neighbour positions */
2139int
2140mfndpos(
2141 struct monst *mon,
2142 struct mfndposdata *data,
2143 long flag)
2144{
2145 struct permonst *mdat = mon->data;
2146 struct trap *ttmp;
2147 coordxy x, y, nx, ny;
2148 int cnt = 0;
2149 uchar ntyp;
2150 uchar nowtyp;
2151 boolean wantpool, poolok, lavaok, nodiag;
2152 boolean rockok = FALSE, treeok = FALSE, thrudoor;
2153 int maxx, maxy;
2154 boolean poisongas_ok, in_poisongas;
2155 NhRegion *gas_reg;
2156 int gas_glyph = cmap_to_glyph(S_poisoncloud);
2157
2158 x = mon->mx;
2159 y = mon->my;
2160 nowtyp = levl[x][y].typ;
2161
2162 (void)memset((genericptr_t) data, 0, sizeof(struct mfndposdata));
2163
2164 nodiag = NODIAG(mdat - mons);
2165 wantpool = (mdat->mlet == S_EEL);
2166 poolok = ((!Is_waterlevel(&u.uz) && m_in_air(mon))
2167 || (is_swimmer(mdat) && !wantpool));
2168 lavaok = (m_in_air(mon) || likes_lava(mdat));
2169 if (mdat == &mons[PM_FLOATING_EYE]) /* prefers to avoid heat */
2170 lavaok = FALSE;
2171 thrudoor = ((flag & (ALLOW_WALL | BUSTDOOR)) != 0L);
2172 poisongas_ok = (m_poisongas_ok(mon) == M_POISONGAS_OK);
2173 in_poisongas = ((gas_reg = visible_region_at(x,y)) != 0
2174 && gas_reg->glyph == gas_glyph);
2175
2176 if (flag & ALLOW_DIG) {
2177 struct obj *mw_tmp;
2178
2179 /* need to be specific about what can currently be dug */
2180 if (!needspick(mdat)) {
2181 rockok = treeok = TRUE;
2182 } else if ((mw_tmp = MON_WEP(mon)) && mw_tmp->cursed
2183 && mon->weapon_check == NO_WEAPON_WANTED) {
2184 rockok = is_pick(mw_tmp);
2185 treeok = is_axe(mw_tmp);
2186 } else {
2187 rockok = (m_carrying(mon, PICK_AXE)
2188 || (m_carrying(mon, DWARVISH_MATTOCK)
2189 && !which_armor(mon, W_ARMS)));
2190 treeok = (m_carrying(mon, AXE) || (m_carrying(mon, BATTLE_AXE)
2191 && !which_armor(mon, W_ARMS)));
2192 }
2193 if (rockok || treeok)
2194 thrudoor = TRUE;
2195 }
2196

Callers 3

dog_moveFunction · 0.85
m_moveFunction · 0.85
move_specialFunction · 0.85

Calls 15

m_in_airFunction · 0.85
m_poisongas_okFunction · 0.85
visible_region_atFunction · 0.85
m_carryingFunction · 0.85
which_armorFunction · 0.85
may_passwallFunction · 0.85
may_digFunction · 0.85
in_roomsFunction · 0.85
dmgtypeFunction · 0.85
can_fogFunction · 0.85
worm_crossFunction · 0.85
is_poolFunction · 0.85

Tested by

no test coverage detected