summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/acr.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/acr.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/acr.cc')
-rw-r--r--crawl-ref/source/acr.cc42
1 files changed, 38 insertions, 4 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index a548ec7d7b..58cc596549 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1332,6 +1332,34 @@ static bool _cmd_is_repeatable(command_type cmd, bool is_again = false)
return false;
}
+static void _check_lava_water_in_sight()
+{
+ // Check the player's vision for lava or deep water,
+ // to avoid unnecessary pathfinding later.
+ you.lava_in_sight = you.water_in_sight = false;
+ coord_def gp;
+ for (gp.y = (you.y_pos - 8); (gp.y <= you.y_pos + 8); gp.y++)
+ for (gp.x = (you.x_pos - 8); (gp.x <= you.x_pos + 8); gp.x++)
+ {
+ if (!in_bounds(gp))
+ continue;
+
+ const coord_def ep = gp - you.pos() + coord_def(9, 9);
+ if (env.show(ep))
+ {
+ dungeon_feature_type feat = grd[gp.x][gp.y];
+ if (feat == DNGN_LAVA)
+ you.lava_in_sight = true;
+ else if (feat == DNGN_DEEP_WATER)
+ you.water_in_sight = true;
+
+ if (you.lava_in_sight && you.water_in_sight)
+ break;
+ }
+ }
+}
+
+
// Used to determine whether to apply the berserk penalty at end of round.
bool apply_berserk_penalty = false;
@@ -1361,9 +1389,11 @@ static void _input()
Options.tut_just_triggered = false;
+ bool player_feels_safe = i_feel_safe();
+
// He, we don't want those "Whew, it's safe to rest now" messages when
// you were just cast into the Abyss. Right?
- if (i_feel_safe() && you.level_type != LEVEL_ABYSS)
+ if (player_feels_safe && you.level_type != LEVEL_ABYSS)
{
if (Options.tutorial_left)
{
@@ -1416,7 +1446,8 @@ static void _input()
// XXX: Is there some smart way to avoid autoswitching back if we're
// just about to continue butchering?
- if (i_feel_safe() && you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED])
+ if (!you.turn_is_over && player_feels_safe
+ && you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED])
{
int weap = you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED];
if (weap == ENDOFPACK)
@@ -1429,18 +1460,21 @@ static void _input()
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
+ if (!you.turn_is_over)
+ _check_lava_water_in_sight();
+
handle_delay();
const coord_def cwhere = grid2view(you.pos());
cgotoxy(cwhere.x, cwhere.y);
- if ( you_are_delayed() )
+ if (you_are_delayed())
{
_world_reacts();
return;
}
- if ( you.turn_is_over )
+ if (you.turn_is_over)
{
_world_reacts();
return;