From 8297dab824509212898f9107b648101222f6c3c5 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Fri, 1 May 2009 16:54:46 +0000 Subject: [2781617] Fixing issue where targets in LOS but with no valid beam (i.e. through a statue) were being picked for firing targets. This could have been fixed by changing see_grid_no_trans to treat statues like clear walls (and then changing the reach code appropriately), but this still allows you to blink through a statue. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9716 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/directn.cc | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/directn.cc') diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 831b0ec089..6ce2cd4fb0 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -995,6 +995,20 @@ bool _dist_ok(const dist& moves, int range, targ_mode_type mode, return (true); } +static bool _blocked_ray(const coord_def &where) +{ + ray_def ray; + find_ray(you.pos(), where, true, ray, 0, true); + ray.advance_through(where); + + while (ray.pos() != where) + { + if (grd(ray.pos()) <= DNGN_MINMOVE) + return (true); + ray.advance_through(where); + } + return (false); +} void direction(dist& moves, targeting_type restricts, targ_mode_type mode, int range, bool just_looking, @@ -1665,9 +1679,9 @@ void direction(dist& moves, targeting_type restricts, #ifdef USE_TILE // Tiles always need a beam redraw if show_beam is true (and valid...) - if (need_beam_redraw - || show_beam && find_ray(you.pos(), moves.target, - true, ray, 0, true) ) + bool _draw_beam = find_ray(you.pos(), moves.target, true, ray, 0, true) + && show_beam && !_blocked_ray(moves.target); + if (need_beam_redraw || _draw_beam) { #else if (need_beam_redraw) @@ -1969,6 +1983,9 @@ static bool _find_mlist( const coord_def& where, int idx, bool need_path, if (!_mons_is_valid_target(mon, TARG_ANY, range)) return (false); + if (need_path && _blocked_ray(mon->pos())) + return (false); + const monsters *monl = mlist[real_idx].m_mon; extern mon_attitude_type mons_attitude(const monsters *m); @@ -2019,6 +2036,9 @@ static bool _find_monster( const coord_def& where, int mode, bool need_path, if (!_mons_is_valid_target(mon, mode, range)) return (false); + if (need_path && _blocked_ray(mon->pos())) + return (false); + // Now compare target modes. if (mode == TARG_ANY) return (true); -- cgit v1.2.3-54-g00ecf