diff options
author | Raphael Langella <raphael.langella@gmail.com> | 2011-09-10 00:23:26 +0200 |
---|---|---|
committer | Raphael Langella <raphael.langella@gmail.com> | 2011-09-10 00:25:10 +0200 |
commit | ecda794cf5b5fbbaff43edda35e262c4ac172e2b (patch) | |
tree | 16a87f0bc4c6ba6d755808452af22e95f700b2de /crawl-ref/source/mon-movetarget.cc | |
parent | 114d259e5c2e37ed3bc6495939cf03c8ca930a04 (diff) | |
download | crawl-ref-ecda794cf5b5fbbaff43edda35e262c4ac172e2b.tar.gz crawl-ref-ecda794cf5b5fbbaff43edda35e262c4ac172e2b.zip |
New monster behaviour: retreating.
When a monster with an intelligence >= I_ANIMAL is attacked but cannot retaliate it
will retreat. This is similar to fleeing but the conditions for it to stop are
different (and a bit randomized).
Diffstat (limited to 'crawl-ref/source/mon-movetarget.cc')
-rw-r--r-- | crawl-ref/source/mon-movetarget.cc | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/crawl-ref/source/mon-movetarget.cc b/crawl-ref/source/mon-movetarget.cc index a3ccd1ee52..97e8766a22 100644 --- a/crawl-ref/source/mon-movetarget.cc +++ b/crawl-ref/source/mon-movetarget.cc @@ -110,7 +110,7 @@ static void _set_no_path_found(monster* mon) _mark_neighbours_target_unreachable(mon); } -static bool _target_is_unreachable(monster* mon) +bool target_is_unreachable(monster* mon) { return (mon->travel_target == MTRAV_UNREACHABLE || mon->travel_target == MTRAV_KNOWN_UNREACHABLE); @@ -170,9 +170,10 @@ bool try_pathfind(monster* mon) // If the target is "unreachable" (the monster already tried, // and failed, to find a path), there's a chance of trying again. // The chance is higher for wall clinging monsters to help them avoid - // shallow water. - if (_target_is_unreachable(mon) && !one_chance_in(12) - && !(mon->can_cling_to_walls() && one_chance_in(4))) + // shallow water. Retreating monsters retry every turn. + if (target_is_unreachable(mon) && !one_chance_in(12) + && !(mon->can_cling_to_walls() && one_chance_in(4)) + && !mon->behaviour == BEH_RETREAT) { return (false); } @@ -247,13 +248,10 @@ bool try_pathfind(monster* mon) mon->travel_target = MTRAV_PLAYER; return (true); } - else - _set_no_path_found(mon); } - else - _set_no_path_found(mon); // We didn't find a path. + _set_no_path_found(mon); return (false); } |