summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monplace.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-11 22:55:29 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-11 22:55:29 +0000
commit9fd7f5bc149e7fa7ae2597bc39ca7fd348997424 (patch)
treefa2bd181febcf019dad6e9d9987f3c01fa07436b /crawl-ref/source/monplace.cc
parentf200b503f68b2eb90fd9a5677c79e093df07544c (diff)
downloadcrawl-ref-9fd7f5bc149e7fa7ae2597bc39ca7fd348997424.tar.gz
crawl-ref-9fd7f5bc149e7fa7ae2597bc39ca7fd348997424.zip
Extend monster pathfinding to monsters circumventing pools of deep water
or lava. I've added some more checks to avoid hampering performance too much, but of course there's still space for improvement. Once per turn check whether the player can see water and/or lava, and only if this is the case run the additional checks (monster habitat, grid_see_grid) when a monster tries to move. Smart monsters that have a ranged attack won't use pathfinding either since they can directly fire at the player. (This is identical to their pre-pathfinding behaviour.) Also fix butterflies really not interrupting resting. (Setting it to 0 doesn't work for some reason.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5737 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monplace.cc')
-rw-r--r--crawl-ref/source/monplace.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 260cc4b573..e5f46985b6 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -135,7 +135,7 @@ bool monster_habitable_grid(int monster_class,
}
// Amphibious critters are happy in water or on land.
- if (mons_amphibious(monster_class)
+ if (mons_class_amphibious(monster_class)
&& (preferred_habitat == DNGN_FLOOR
&& grid_compatible(DNGN_DEEP_WATER, actual_grid)
|| preferred_habitat == DNGN_DEEP_WATER
@@ -2523,11 +2523,8 @@ std::vector<coord_def> monster_pathfind::calc_waypoints()
return path;
dungeon_feature_type can_move;
- if (mons_amphibious(mons_is_zombified(mons) ? mons->base_monster
- : mons->type))
- {
+ if (mons_amphibious(mons))
can_move = DNGN_DEEP_WATER;
- }
else
can_move = DNGN_SHALLOW_WATER;
@@ -2621,7 +2618,7 @@ int monster_pathfind::travel_cost(coord_def npos)
// Travelling through water, entering or leaving water is more expensive
// for non-amphibious monsters, so they'll avoid it where possible.
// Only tested for shallow water since they can't enter deep water anywa.
- if (!airborne && !mons_amphibious(montype)
+ if (!airborne && !mons_class_amphibious(montype)
&& (grd(pos) == DNGN_SHALLOW_WATER || grd(npos) == DNGN_SHALLOW_WATER))
{
return 2;