diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-02 16:33:46 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-02 16:33:46 +0000 |
commit | f2f0708daa9dddde8ef36c59d2c38d0649805add (patch) | |
tree | 5212307d1f8eac51a04b2f881f4a0cbce65e2031 /crawl-ref/source/monstuff.cc | |
parent | e40ab62d5ac6d71bf3e2a1be0a4e2b389a3f8b66 (diff) | |
download | crawl-ref-f2f0708daa9dddde8ef36c59d2c38d0649805add.tar.gz crawl-ref-f2f0708daa9dddde8ef36c59d2c38d0649805add.zip |
Actually handle cases of unreachable exits for pacified monsters leaving
the level.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6342 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r-- | crawl-ref/source/monstuff.cc | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 9b70b5e7a0..cb652fbf45 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -3035,39 +3035,33 @@ static void _handle_behaviour(monsters *mon) { // If a pacified monster isn't travelling toward // someplace from which it can leave the level, make it - // start doing so. - if (mon->travel_target != MTRAV_PATROL - && mon->travel_target != MTRAV_UNREACHABLE) + // start doing so. If there's no such place, travel + // randomly. + if (mon->travel_target != MTRAV_PATROL) { new_foe = MHITNOT; - patrolling = true; mon->travel_path.clear(); e_index = _mons_find_nearest_level_exit(mon, e); if (e_index != -1) { + mon->travel_target = MTRAV_PATROL; + patrolling = true; mon->patrol_point = e[e_index].target; mon->target_x = e[e_index].target.x; mon->target_y = e[e_index].target.y; - mon->travel_target = MTRAV_PATROL; } else { - mon->patrol_point = coord_def(0, 0); - mon->target_x = mon->x; - mon->target_y = mon->y; mon->travel_target = MTRAV_NONE; + patrolling = false; + mon->patrol_point = coord_def(0, 0); + mon->target_x = 10 + random2(GXM - 10); + mon->target_y = 10 + random2(GYM - 10); } } - // If the level exit is unreachable, find a new one. - if (mon->travel_target == MTRAV_UNREACHABLE) - { - e[e_index].unreachable = true; - mon->travel_target = MTRAV_NONE; - } - // If a pacified monster is leaving the level, and has // reached its goal, handle it here. if (isPacified && e_index != -1 @@ -3108,7 +3102,7 @@ static void _handle_behaviour(monsters *mon) // wandering monsters at least appear to have some sort of // attention span. -- bwr if (mon->x == mon->target_x && mon->y == mon->target_y - || mons_is_batty(mon) || one_chance_in(isPacified ? 40 : 20)) + || mons_is_batty(mon) || (!isPacified && one_chance_in(20))) { bool need_target = true; if (travelling) @@ -3325,9 +3319,16 @@ static void _handle_behaviour(monsters *mon) if (need_target) { - // The monster is travelling randomly. - mon->target_x = 10 + random2(GXM - 10); - mon->target_y = 10 + random2(GYM - 10); + // If a monster that's been pacified and is leaving + // the level can't reach its target, mark its target + // as unreachable. + if (isPacified) + e[e_index].unreachable = true; + else + { + mon->target_x = 10 + random2(GXM - 10); + mon->target_y = 10 + random2(GYM - 10); + } } } |