summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-pathfind.cc
diff options
context:
space:
mode:
authorRaphael Langella <raphael.langella@gmail.com>2013-08-12 15:43:42 +0200
committerRaphael Langella <raphael.langella@gmail.com>2013-08-12 15:49:00 +0200
commit40eb210485ae15fdf5be7e96104197e26b3fa5f6 (patch)
treeaa733e21ad970922b2df54b48ec35ad218da434f /crawl-ref/source/mon-pathfind.cc
parentd993d8a94ebf88d624d434119000bc7293dafba9 (diff)
downloadcrawl-ref-40eb210485ae15fdf5be7e96104197e26b3fa5f6.tar.gz
crawl-ref-40eb210485ae15fdf5be7e96104197e26b3fa5f6.zip
Revert "Bye bye clinging."
Clinging might be a minor feature, but it's a distinguishing one, it's thematic and it's working quite well. Player/monster symmetry has never been a goal, so it seems dubious to invoke it as the reason to throw away all the work that has been put into clinging. We can always say that the player turns into a different kind of spider which is unable to cling for some reason. This reverts commit bdc56382eacf7af1b2330dc6444916d368741fec. This reverts commit d689486464fcaaac025a6f469ab69674a2f4d173. This reverts commit 1addaaf8ee92de5060fdb436f93251843abd2035.
Diffstat (limited to 'crawl-ref/source/mon-pathfind.cc')
-rw-r--r--crawl-ref/source/mon-pathfind.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/crawl-ref/source/mon-pathfind.cc b/crawl-ref/source/mon-pathfind.cc
index 9933cf3e04..f4c0ea807f 100644
--- a/crawl-ref/source/mon-pathfind.cc
+++ b/crawl-ref/source/mon-pathfind.cc
@@ -56,7 +56,9 @@ int mons_tracking_range(const monster* mon)
if (range)
{
- if (mons_is_native_in_branch(mon))
+ if (mon->can_cling_to_walls())
+ range += 4;
+ else if (mons_is_native_in_branch(mon))
range += 3;
else if (mons_class_flag(mon->type, M_BLOOD_SCENT))
range++;
@@ -380,7 +382,7 @@ vector<coord_def> monster_pathfind::calc_waypoints()
#endif
for (unsigned int i = 1; i < path.size(); i++)
{
- if (can_go_straight(mons, pos, path[i]) && mons_can_traverse(mons, path[i]))
+ if (can_go_straight(mons, pos, path[i]) && mons_traversable(path[i]))
continue;
else
{
@@ -427,11 +429,20 @@ bool monster_pathfind::traversable(const coord_def& p)
}
if (mons)
- return mons_can_traverse(mons, p);
+ return mons_traversable(p);
return feat_has_solid_floor(grd(p));
}
+// Checks whether a given monster can pass over a certain position, respecting
+// its preferred habit and capability of flight or opening doors.
+bool monster_pathfind::mons_traversable(const coord_def& p)
+{
+ return mons_can_traverse(mons, p) || mons->can_cling_to_walls()
+ && cell_is_clingable(pos)
+ && cell_can_cling_to(pos, p);
+}
+
int monster_pathfind::travel_cost(coord_def npos)
{
#ifdef EUCLIDEAN
@@ -464,6 +475,9 @@ int monster_pathfind::mons_travel_cost(coord_def npos)
return 2;
const monster_type mt = mons_base_type(mons);
+ const bool ground_level = !mons_airborne(mt, -1, false)
+ && !(mons->can_cling_to_walls()
+ && cell_is_clingable(npos));
// Travelling through water, entering or leaving water is more expensive
// for non-amphibious monsters, so they'll avoid it where possible.
@@ -491,7 +505,7 @@ int monster_pathfind::mons_travel_cost(coord_def npos)
// Mechanical traps can be avoided by flying, as can shafts, and
// tele traps are never traversable anyway.
- if (knows_trap && !mons_airborne(mt, -1, false))
+ if (knows_trap && ground_level)
return 2;
}