diff options
Diffstat (limited to 'crawl-ref/source/monplace.cc')
-rw-r--r-- | crawl-ref/source/monplace.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 4a00052e01..438e03b9d2 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -2297,8 +2297,9 @@ monster_type summon_any_dragon(dragon_class_type dct) ///////////////////////////////////////////////////////////////////////////// // monster_pathfind +//#define DEBUG_PATHFIND monster_pathfind::monster_pathfind() - : mons(), target(), min_length(0), dist(), prev() + : mons(), target(), range(0), min_length(0), max_length(0), dist(), prev() { } @@ -2306,6 +2307,12 @@ monster_pathfind::~monster_pathfind() { } +void monster_pathfind::set_range(int r) +{ + if (r >= 0) + range = r; +} + // Returns true if a path was found, else false. bool monster_pathfind::start_pathfind(monsters *mon, coord_def dest, bool msg) { @@ -2386,6 +2393,10 @@ bool monster_pathfind::calc_path_to_neighbours() if (!traversable(npos)) continue; + // Ignore this grid if it takes us above the allowed distance. + if (range && estimated_cost(npos) > range) + continue; + distance = dist[pos.x][pos.y] + travel_cost(npos); old_dist = dist[npos.x][npos.y]; #ifdef DEBUG_PATHFIND |