diff --git a/src/apply.c b/src/apply.c index a7cc2d82c..daa2b9c4b 100644 --- a/src/apply.c +++ b/src/apply.c @@ -2945,6 +2945,9 @@ static const char cant_see_spot[] = "won't hit anything if you can't see that spot.", cant_reach[] = "can't reach that spot from here."; +#define glyph_is_poleable(G) \ + (glyph_is_monster(G) || glyph_is_invisible(G) || glyph_is_statue(G)) + /* find pos of monster in range, if only one monster */ static boolean find_poleable_mon(pos, min_range, max_range) @@ -2956,8 +2959,6 @@ int min_range, max_range; boolean impaired; int x, y, lo_x, hi_x, lo_y, hi_y, rt, glyph; - if (Blind) - return FALSE; /* must be able to see target location */ impaired = (Confusion || Stunned || Hallucination); mpos.x = mpos.y = 0; /* no candidate location yet */ rt = isqrt(max_range); @@ -2974,10 +2975,8 @@ int min_range, max_range; && (mtmp = m_at(x, y)) != 0 && (mtmp->mtame || (mtmp->mpeaceful && flags.confirm))) continue; - if (glyph_is_monster(glyph) - || glyph_is_warning(glyph) - || glyph_is_invisible(glyph) - || (glyph_is_statue(glyph) && impaired)) { + if (glyph_is_poleable(glyph) + && (!glyph_is_statue(glyph) || impaired)) { if (mpos.x) return FALSE; /* more than one candidate location */ mpos.x = x, mpos.y = y; @@ -2994,9 +2993,14 @@ static boolean get_valid_polearm_position(x, y) int x, y; { - return (isok(x, y) && ACCESSIBLE(levl[x][y].typ) - && distu(x, y) >= g.polearm_range_min - && distu(x, y) <= g.polearm_range_max); + int glyph; + + glyph = glyph_at(x, y); + + return (isok(x, y) && distu(x, y) >= g.polearm_range_min + && distu(x, y) <= g.polearm_range_max + && (cansee(x, y) || (couldsee(x, y) + && glyph_is_poleable(glyph)))); } static void @@ -3076,7 +3080,7 @@ struct obj *obj; cc.x = u.ux; cc.y = u.uy; if (!find_poleable_mon(&cc, min_range, max_range) && hitm - && !DEADMONSTER(hitm) && cansee(hitm->mx, hitm->my) + && !DEADMONSTER(hitm) && sensemon(hitm) && distu(hitm->mx, hitm->my) <= max_range && distu(hitm->mx, hitm->my) >= min_range) { cc.x = hitm->mx; @@ -3093,8 +3097,7 @@ struct obj *obj; } else if (distu(cc.x, cc.y) < min_range) { pline("Too close!"); return res; - } else if (!cansee(cc.x, cc.y) && !glyph_is_monster(glyph) - && !glyph_is_invisible(glyph) && !glyph_is_statue(glyph)) { + } else if (!cansee(cc.x, cc.y) && !glyph_is_poleable(glyph)) { You(cant_see_spot); return res; } else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */