From 843b0034d812492266b0aa07c812b9f54890feaa Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 9 Jan 2007 10:32:10 +0000 Subject: Tweaked travel/explore so that it doesn't cut off before trying to move to a square with an invisible monster/mimic. Travel now cuts off when the PC attempts to attack the invisible monster. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@813 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/travel.cc | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'crawl-ref/source/travel.cc') diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 8cdb247a1e..673e17db04 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -441,26 +441,18 @@ static bool is_travel_ok(int x, int y, bool ignore_hostile) } // Returns true if the location at (x,y) is monster-free and contains no clouds. -static bool is_safe(int x, int y) +static bool is_safe_move(int x, int y) { unsigned char mon = mgrd[x][y]; if (mon != NON_MONSTER) { - // If this is an invisible critter, say we're safe to get here, but - // turn off travel - the result should be that the player bashes into - // the monster and stops travelling right there. Same treatment applies - // to mimics. - if (!player_monster_visible(&menv[mon]) || - mons_is_mimic( menv[mon].type )) + // Stop before wasting energy on plants and fungi. + if (player_monster_visible(&menv[mon]) + && mons_class_flag( menv[mon].type, M_NO_EXP_GAIN )) { - you.running.stop(); - return true; + return (false); } - // Stop before wasting energy on plants and fungi. - if (mons_class_flag( menv[mon].type, M_NO_EXP_GAIN )) - return false; - // If this is any *other* monster, it'll be visible and // a) Friendly, in which case we'll displace it, no problem. // b) Unfriendly, in which case we're in deep trouble, since travel @@ -468,11 +460,11 @@ static bool is_safe(int x, int y) } const int cloud = env.cgrid[x][y]; if (cloud == EMPTY_CLOUD) - return true; + return (true); // We can also safely run through smoke. const cloud_type ctype = (cloud_type) env.cloud[ cloud ].type; - return !is_damaging_cloud(ctype); + return (!is_damaging_cloud(ctype)); } static bool player_is_permalevitating() @@ -1278,7 +1270,7 @@ void find_travel_pos(int youx, int youy, if (dx == dest_x && dy == dest_y) { // Hallelujah, we're home! - if (is_safe(x, y) && move_x && move_y) + if (is_safe_move(x, y) && move_x && move_y) { *move_x = sgn(x - dest_x); *move_y = sgn(y - dest_y); -- cgit v1.2.3-54-g00ecf