summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-02 19:31:49 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-02 19:31:49 +0000
commit8030e3981a5ff0333ae659cbd08763c09ffdede0 (patch)
tree2ad1edbe91ecdd44c84aa746102b380a5f3398d0 /crawl-ref/source/monstuff.cc
parent67e107b864b7c28ca740234c1752bb961039f8c9 (diff)
downloadcrawl-ref-8030e3981a5ff0333ae659cbd08763c09ffdede0.tar.gz
crawl-ref-8030e3981a5ff0333ae659cbd08763c09ffdede0.zip
Improve pacified monsters' routines for leaving the level again. Remove
death by submersion for now, since it's too specific to certain monsters, and leaving the level long enough will make them disappear anyway. Also, have monsters sometimes cycle through previously unreachable areas again, in case things change on the level to make them reachable. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6346 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc42
1 files changed, 21 insertions, 21 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index dd199d01c0..aa3f09573f 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2405,15 +2405,7 @@ static void _mons_find_all_level_exits(const monsters *mon,
// Teleportation and shaft traps.
const trap_type tt = trap_type_at_xy(x, y);
- if ((tt == TRAP_TELEPORT || tt == TRAP_SHAFT)
- && (mons_is_native_in_branch(mon)
- || gridc != DNGN_UNDISCOVERED_TRAP))
- {
- e.push_back(level_exit(coord_def(x, y), false));
- }
-
- // Any place the monster can submerge.
- if (monster_can_submerge(mon, gridc))
+ if (tt == TRAP_TELEPORT || tt == TRAP_SHAFT)
e.push_back(level_exit(coord_def(x, y), false));
}
}
@@ -2421,7 +2413,8 @@ static void _mons_find_all_level_exits(const monsters *mon,
}
static int _mons_find_nearest_level_exit(const monsters *mon,
- std::vector<level_exit> &e)
+ std::vector<level_exit> &e,
+ bool restart)
{
if (e.empty())
@@ -2433,13 +2426,26 @@ static int _mons_find_nearest_level_exit(const monsters *mon,
for (unsigned int i = 0; i < e.size(); ++i)
{
if (e[i].unreachable)
- continue;
+ {
+ if (restart)
+ e[i].unreachable = false;
+ else
+ continue;
+ }
int dist = grid_distance(mon->x, mon->y, e[i].target.x,
e[i].target.y);
if (old_dist == -1 || old_dist >= dist)
{
+ // Ignore teleportation and shaft traps that the monster
+ // shouldn't know about.
+ if (!mons_is_native_in_branch(mon)
+ && grd(e[i].target) == DNGN_UNDISCOVERED_TRAP)
+ {
+ continue;
+ }
+
retval = i;
old_dist = dist;
}
@@ -2466,15 +2472,6 @@ static void _mons_indicate_level_exit(const monsters *mon)
}
else if (is_gate(gridc))
simple_monster_message(mon, " passes through the gate.");
- // Any place the monster can submerge.
- else if (monster_can_submerge(mon, gridc))
- {
- simple_monster_message(mon,
- make_stringf(" disappears into %s!",
- mons_habitat(mon) == HT_LAVA ? "the lava" :
- mons_habitat(mon) == HT_WATER ? "the water"
- : "thin air").c_str());
- }
}
void make_mons_leave_level(monsters *mon)
@@ -3043,7 +3040,10 @@ static void _handle_behaviour(monsters *mon)
new_foe = MHITNOT;
mon->travel_path.clear();
- e_index = _mons_find_nearest_level_exit(mon, e);
+ e_index = _mons_find_nearest_level_exit(mon, e, false);
+
+ if (e_index == -1 && one_chance_in(20))
+ e_index = _mons_find_nearest_level_exit(mon, e, true);
if (e_index != -1)
{