diff options
-rw-r--r-- | crawl-ref/source/externs.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 16 | ||||
-rw-r--r-- | crawl-ref/source/mtransit.cc | 14 |
3 files changed, 17 insertions, 16 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 4b70506ba3..5f16a2ce79 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1353,7 +1353,8 @@ public: bool needs_transit() const; void set_transit(const level_id &destination); bool find_place_to_live(bool near_player = false); - bool find_place_near_player(); + bool find_home_near_place(const coord_def &c); + bool find_home_near_player(); bool find_home_around(const coord_def &c, int radius); bool find_home_anywhere(); diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index c7ee7c10eb..b9a64c6af2 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -6157,11 +6157,10 @@ bool monsters::check_set_valid_home(const coord_def &place, if (!in_bounds(place)) return (false); - if (place == you.pos()) + if (actor_at(place)) return (false); - // Don't drop on anything but vanilla floor right now. - if (mgrd(place) != NON_MONSTER || grd(place) != DNGN_FLOOR) + if (!monster_habitable_grid(this, grd(place))) return (false); if (one_chance_in(++nvalid)) @@ -6199,15 +6198,20 @@ bool monsters::find_home_around(const coord_def &c, int radius) return (false); } -bool monsters::find_place_near_player() +bool monsters::find_home_near_place(const coord_def &c) { for (int radius = 1; radius < 7; ++radius) - if (find_home_around(you.pos(), radius)) + if (find_home_around(c, radius)) return (true); return (false); } +bool monsters::find_home_near_player() +{ + return (find_home_near_place(you.pos())); +} + bool monsters::find_home_anywhere() { coord_def place(-1, -1); @@ -6226,7 +6230,7 @@ bool monsters::find_home_anywhere() bool monsters::find_place_to_live(bool near_player) { - if (near_player && find_place_near_player() + if (near_player && find_home_near_player() || find_home_anywhere()) { mgrd(pos()) = mindex(); diff --git a/crawl-ref/source/mtransit.cc b/crawl-ref/source/mtransit.cc index d43ad22022..5ce6d678a0 100644 --- a/crawl-ref/source/mtransit.cc +++ b/crawl-ref/source/mtransit.cc @@ -262,16 +262,12 @@ bool follower::place(bool near_player) dgn_find_nearby_stair(DNGN_ESCAPE_HATCH_DOWN, m.pos(), true); - if (monster_habitable_grid(&m, grd(where_to_go))) + if (where_to_go == you.pos()) + near_player = true; + else if (m.find_home_near_place(where_to_go)) { - if (where_to_go == you.pos()) - near_player = true; - else - { - m.moveto(where_to_go); - mgrd(where_to_go) = m.mindex(); - placed = true; - } + mgrd(m.pos()) = m.mindex(); + placed = true; } } |