From d4abb0d1e06a22934cc2b654b7753bb37473b8b1 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Sun, 17 Jan 2010 23:59:31 -0500 Subject: 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). --- crawl-ref/source/mon-behv.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'crawl-ref') 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; -- cgit v1.2.3