diff options
author | Charles Otto <ottochar@gmail.com> | 2010-01-17 23:59:31 -0500 |
---|---|---|
committer | Charles Otto <ottochar@gmail.com> | 2010-01-17 23:59:31 -0500 |
commit | d4abb0d1e06a22934cc2b654b7753bb37473b8b1 (patch) | |
tree | 1e2d8ce842be8b973c1b652eee1c5960c8f11c40 /crawl-ref/source/mon-behv.cc | |
parent | 856be18105f4eb6e0639cef9475a322ad7832d27 (diff) | |
download | crawl-ref-d4abb0d1e06a22934cc2b654b7753bb37473b8b1.tar.gz crawl-ref-d4abb0d1e06a22934cc2b654b7753bb37473b8b1.zip |
Fix allies making a beeline for the map origin when out of LOS
Fix a bug introduced in commit 8e49c668 which caused the movement
target of friendly monsters outside the players LOS to be set to (0,0).
monsters::get_foe() returns NULL for friendly monsters with foe equal
to MHITYOU, so it was not being used correctly in handle_behaviour
(since this part of it is just concerned with where monsters are trying
to move rather than what they will actually attack).
Diffstat (limited to 'crawl-ref/source/mon-behv.cc')
-rw-r--r-- | crawl-ref/source/mon-behv.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc index c48e01301a..642b9baed1 100644 --- a/crawl-ref/source/mon-behv.cc +++ b/crawl-ref/source/mon-behv.cc @@ -253,12 +253,19 @@ void handle_behaviour(monsters *mon) actor* afoe = mon->get_foe(); proxFoe = afoe && mon->can_see(afoe); + if (mon->foe == MHITYOU) + { + // monsters::get_foe returns NULL for friendly monsters with + // foe == MHITYOU, so make afoe point to the player here. + // -cao + afoe = &you; + proxFoe = proxPlayer; // Take invis into account. + } + coord_def foepos = coord_def(0,0); if (afoe) foepos = afoe->pos(); - if (mon->foe == MHITYOU) - proxFoe = proxPlayer; // Take invis into account. // Track changes to state; attitude never changes here. beh_type new_beh = mon->behaviour; |