summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/directn.cc
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-05-01 16:54:46 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-05-01 16:54:46 +0000
commit8297dab824509212898f9107b648101222f6c3c5 (patch)
tree5ef4284f608228d010a9a626a34026d3fe519ff3 /crawl-ref/source/directn.cc
parent31561ffda694a406ca06325685a1f0a998de0abf (diff)
downloadcrawl-ref-8297dab824509212898f9107b648101222f6c3c5.tar.gz
crawl-ref-8297dab824509212898f9107b648101222f6c3c5.zip
[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
Diffstat (limited to 'crawl-ref/source/directn.cc')
-rw-r--r--crawl-ref/source/directn.cc26
1 files changed, 23 insertions, 3 deletions
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);