diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/items.cc | 77 | ||||
-rw-r--r-- | crawl-ref/source/items.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/travel.cc | 47 | ||||
-rw-r--r-- | crawl-ref/source/travel.h | 1 |
4 files changed, 77 insertions, 49 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index d4807bbd0f..207549ddbc 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1059,25 +1059,6 @@ bool origin_describable(const item_def &item) std::string article_it(const item_def &item) { - /* - bool them = false; - if (item.quantity > 1) - them = true; - else if (item.base_type == OBJ_ARMOUR && - item.sub_type == ARM_BOOTS) - { - if (item.plus2 != TBOOT_NAGA_BARDING && - item.plus2 != TBOOT_CENTAUR_BARDING) - them = true; - } - else if (item.base_type == OBJ_ARMOUR && - item.sub_type == ARM_GLOVES) - { - them = true; - } - - return them? "them" : "it"; - */ // "it" is always correct, since gloves and boots also come in pairs. return "it"; } @@ -1458,7 +1439,8 @@ static void got_item(item_def& item, int quant) int move_item_to_player( int obj, int quant_got, bool quiet ) { if (you.attribute[ATTR_HELD] && mitm[obj].base_type == OBJ_MISSILES - && mitm[obj].sub_type == MI_THROWING_NET && item_is_stationary(mitm[obj])) + && mitm[obj].sub_type == MI_THROWING_NET + && item_is_stationary(mitm[obj])) { mpr("You cannot pick up the net that holds you!"); return (1); @@ -1609,6 +1591,15 @@ int move_item_to_player( int obj, int quant_got, bool quiet ) return (retval); } // end move_item_to_player() +void mark_items_dropped_at(const coord_def &pos) +{ + int item = igrd(pos); + while (item != NON_ITEM) + { + mitm[item].flags |= ISFLAG_DROPPED; + item = mitm[item].link; + } +} // Moves mitm[obj] to (x,y)... will modify the value of obj to // be the index of the final object (possibly different). @@ -2972,8 +2963,8 @@ static void do_autopickup() { //David Loewenstern 6/99 int result, o, next; - bool did_pickup = false; - bool tried_pickup = false; + int n_did_pickup = 0; + int n_tried_pickup = 0; will_autopickup = false; @@ -2988,7 +2979,6 @@ static void do_autopickup() if (item_needs_autopickup(mitm[o])) { - int num_to_take = mitm[o].quantity; if ( Options.autopickup_no_burden && item_mass(mitm[o]) != 0) { @@ -2998,10 +2988,10 @@ static void do_autopickup() if ( num_can_take < num_to_take ) { - if (!tried_pickup) + if (!n_tried_pickup) mpr("You can't pick everything up without burdening " "yourself."); - tried_pickup = true; + n_tried_pickup++; num_to_take = num_can_take; } @@ -3012,49 +3002,40 @@ static void do_autopickup() } } + const unsigned long iflags(mitm[o].flags); mitm[o].flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED); result = move_item_to_player(o, num_to_take); - if (result == 0) + if (result == 0 || result == -1) { - tried_pickup = true; - mpr("You can't carry any more."); - break; - } - else if (result == -1) - { - tried_pickup = true; - mpr("Your pack is full."); + n_tried_pickup++; + if (result == 0) + mpr("You can't carry any more."); + else + mpr("Your pack is full."); + mitm[o].flags = iflags; break; } - did_pickup = true; + n_did_pickup++; } o = next; } - if (did_pickup) - { + if (n_did_pickup) you.turn_is_over = true; - const int estop = - you.running == RMODE_EXPLORE_GREEDY? - ES_GREEDY_PICKUP : ES_PICKUP; - if ((Options.explore_stop & estop) && prompt_stop_explore(estop)) - stop_delay(); - } - // Greedy explore has no good way to deal with an item that we can't - // pick up, so the only thing to do is to stop. - else if (tried_pickup && you.running == RMODE_EXPLORE_GREEDY) - stop_delay(); + + item_check(false); + + explore_pickup_event(n_did_pickup, n_tried_pickup); } void autopickup() { autoinscribe_floor_items(); do_autopickup(); - item_check(false); } int inv_count(void) diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h index 64b3d59131..05481e63b9 100644 --- a/crawl-ref/source/items.h +++ b/crawl-ref/source/items.h @@ -40,6 +40,7 @@ void inc_mitm_item_quantity( int obj, int amount ); bool move_item_to_grid( int *const obj, int x, int y ); void move_item_stack_to_grid( int x, int y, int targ_x, int targ_y ); int move_item_to_player( int obj, int quant_got, bool quiet = false ); +void mark_items_dropped_at(const coord_def &pos); bool is_stackable_item( const item_def &item ); bool items_stack( const item_def &item1, const item_def &item2, bool force = false ); diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index b2e12e140b..78ce892ea1 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -85,6 +85,9 @@ static level_id last_stair; // Where travel wants to get to. static travel_target level_target; +// Remember the last place explore stopped because autopickup failed. +static coord_def explore_stopped_pos; + // The place in the Vestibule of Hell where all portals to Hell land. static level_pos travel_hell_entry; @@ -512,10 +515,12 @@ void travel_init_new_level() // Zero out last travel coords you.travel_x = you.travel_y = 0; - traps_inited = false; + traps_inited = false; curr_excludes.clear(); travel_cache.set_level_excludes(); travel_cache.update_waypoints(); + + explore_stopped_pos.reset(); } /* @@ -896,6 +901,43 @@ static void explore_find_target_square() } } +void explore_pickup_event(int did_pickup, int tried_pickup) +{ + if (!did_pickup && !tried_pickup) + return; + + if (!you.running.is_explore()) + return; + + if (did_pickup) + { + const int estop = + you.running == RMODE_EXPLORE_GREEDY? + ES_GREEDY_PICKUP : ES_PICKUP; + if ((Options.explore_stop & estop) && prompt_stop_explore(estop)) + stop_delay(); + } + + // Greedy explore has no good way to deal with an item that we can't + // pick up, so the only thing to do is to stop. + if (tried_pickup && you.running == RMODE_EXPLORE_GREEDY) + { + stop_delay(); + if (explore_stopped_pos == you.pos() + && !Options.pickup_dropped) + { + const std::string prompt = + make_stringf( + "Could not pick up %s here, shall I ignore %s? ", + tried_pickup == 1? "an item" : "some items", + tried_pickup == 1? "it" : "them"); + if (yesno(prompt.c_str(), true, 'y')) + mark_items_dropped_at(you.pos()); + } + explore_stopped_pos = you.pos(); + } +} + /* * Top-level travel control (called from input() in acr.cc). * @@ -1006,7 +1048,10 @@ command_type travel() { if ((Options.explore_stop & ES_ITEM) && prompt_stop_explore(ES_ITEM)) + { + explore_stopped_pos = coord_def(new_x, new_y); stop_running(); + } return direction_to_command( *move_x, *move_y ); } } diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index 592c9f08f1..3f50591b5f 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -71,6 +71,7 @@ command_type direction_to_command( char x, char y ); bool is_resting( void ); bool can_travel_interlevel(); bool is_traversable(dungeon_feature_type grid); +void explore_pickup_event(int did_pickup, int tried_pickup); void find_travel_pos(int you_x, int you_y, char *move_x, char *move_y, std::vector<coord_def>* coords = NULL); |