From 8fe0fae874a09acfbd56f3d2d6e68627a2eea732 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 4 Dec 2006 07:10:27 +0000 Subject: Minor greedy-explore tweaks: * It now stops when reaching a pile of stuff so that the player can examine the stuff even if autopickup does not kick in. * Fixed the bug where it would remember its old explore target even if the player subsequently moved halfway across the level from it. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@548 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/travel.cc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source/travel.cc') diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 6e16d71834..f48c910371 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -915,6 +915,29 @@ command_type travel() // we turn off travel (find_travel_pos does that automatically). find_travel_pos(you.x_pos, you.y_pos, move_x, move_y); + if ((*move_x || *move_y) && you.running == RMODE_EXPLORE_GREEDY) + { + // Greedy explore should cut off on reaching an item. We can't + // check after reaching the item, because at that point the stash + // tracker will have verified the stash and say "false" to + // needs_visit. + const int new_x = you.x_pos + *move_x; + const int new_y = you.y_pos + *move_y; + + if (new_x == you.running.x && new_y == you.running.y) + { + const LevelStashes *lev = stashes.find_current_level(); + if (lev && lev->needs_visit(new_x, new_y) + && !lev->shop_needs_visit(new_x, new_y)) + { + if ((Options.explore_stop & ES_ITEM) + && prompt_stop_explore(ES_ITEM)) + stop_running(); + return direction_to_command( *move_x, *move_y ); + } + } + } + if (!*move_x && !*move_y) { // If we've reached the square we were traveling towards, travel @@ -985,10 +1008,10 @@ command_type travel() redraw_screen(); if (!you.running) - return CMD_NO_CMD; + return CMD_NO_CMD; if ( result != CMD_NO_CMD ) - return result; + return result; return direction_to_command( *move_x, *move_y ); } @@ -2327,6 +2350,7 @@ void start_explore(bool grab_items) // Clone shadow array off map copy(env.map, mapshadow); + you.running.x = you.running.y = 0; start_running(); } -- cgit v1.2.3-54-g00ecf