From 4f9a9aa77bc073af76876932dc0244b42eabfbff Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Tue, 24 Nov 2009 22:58:51 +0100 Subject: Make object targetting heed range and needs_path. Also simplify mimic handling by referring to map_knowledge. --- crawl-ref/source/directn.cc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'crawl-ref/source/directn.cc') diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 8a41fc96ef..24fc63c7f4 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -2077,25 +2077,16 @@ static bool _find_feature( const coord_def& where, int mode, } static bool _find_object(const coord_def& where, int mode, - bool /* need_path */, int /* range */) + bool need_path, int range) { - // First, check for mimics. - bool is_mimic = false; - const monsters* m = monster_at(where); - if (m - && m->visible_to(&you) - && mons_is_mimic(m->type) - && !(m->flags & MF_KNOWN_MIMIC)) - { - is_mimic = true; - } + // Don't target out of range. + if (!_is_target_in_range(where, range)) + return (false); - const int item = igrd(where); - if (item == NON_ITEM && !is_mimic) + if (need_path && (!you.see_cell(where) || _blocked_ray(where))) return (false); - return (in_los(where) || is_terrain_seen(where) - && (is_stash(where.x,where.y) || is_mimic)); + return (env.map_knowledge(where).item() != SHOW_ITEM_NONE); } static int _next_los(int dir, int los, bool wrap) -- cgit v1.2.3-54-g00ecf