From aef49cb2fba2d6707c1d2d591ffbe3f35cd6e939 Mon Sep 17 00:00:00 2001 From: haranp Date: Thu, 23 Nov 2006 16:10:21 +0000 Subject: Implemented 1601227, pickup_mode. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@484 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/crawl_options.txt | 12 +++++++++++- crawl-ref/init.txt | 1 + crawl-ref/source/externs.h | 2 ++ crawl-ref/source/initfile.cc | 10 ++++++++++ crawl-ref/source/items.cc | 23 +++++++++++++++-------- 5 files changed, 39 insertions(+), 9 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/docs/crawl_options.txt b/crawl-ref/docs/crawl_options.txt index 505dbb0e49..0b7bb2bae8 100644 --- a/crawl-ref/docs/crawl_options.txt +++ b/crawl-ref/docs/crawl_options.txt @@ -20,7 +20,7 @@ The contents of this text are: 4-a Dropping and Picking up. autopickup, default_autopickup, safe_autopickup, safe_zero_exp, pickup_thrown, pickup_dropped, assign_item_slot, ban_pickup, - drop_mode, drop_filter; + drop_mode, pickup_mode, drop_filter; lua: ch_autopickup (advanced autopickup exceptions) 4-b Targeting. target_zero_exp, target_wrap, target_oos, target_los_first, @@ -279,6 +279,16 @@ drop_mode = (multi | single) The order in which items get dropped is always from top to bottom in the inventory listing. +pickup_mode = (multi | single | auto:X) + Single is the classical behaviour (and default): when picking up + items, you are prompted for them one by one. Multi makes a menu + appear, where you can choose which items to pick up. Note that + no matter how many items you choose, picking up will always take + one turn. + If pickup_mode is auto:X, where X is some number (for example, + auto:5), then pickup will give a menu if there are at least X + items on your square, and will prompt one by one otherwise. + drop_filter = When selecting items using the global (de)select keys (',' or '-') in a multidrop listing, you can choose to apply a filter: only items diff --git a/crawl-ref/init.txt b/crawl-ref/init.txt index 7214e8687f..f96c0e8dfb 100644 --- a/crawl-ref/init.txt +++ b/crawl-ref/init.txt @@ -77,6 +77,7 @@ ban_pickup = scrolls? of paper,immolation,curse armor,curse weapon ban_pickup = forgetfulness,uselessness,noise,torment # drop_mode = multi +pickup_mode = auto:5 # drop_filter = skeleton, rotting, corpse ##### 4-b Targetting ############################ diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 7ff9054ed6..ba69a74475 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -836,6 +836,8 @@ public: int drop_mode; // Controls whether single or multidrop // is the default. + int pickup_mode; // -1 for single, 0 for menu, + // X for 'if at least X items present' bool easy_exit_menu; // Menus are easier to get out of diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 61e05b9aa6..1846407171 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -612,6 +612,7 @@ void game_options::reset_options() dump_item_origin_price = -1; drop_mode = DM_SINGLE; + pickup_mode = -1; flush_input[ FLUSH_ON_FAILURE ] = true; flush_input[ FLUSH_BEFORE_COMMAND ] = false; @@ -1919,6 +1920,15 @@ void game_options::read_option_line(const std::string &str, bool runscript) else drop_mode = DM_SINGLE; } + else if (key == "pickup_mode") + { + if (field.find("multi") != std::string::npos) + pickup_mode = 0; + else if (field.find("single") != std::string::npos) + pickup_mode = -1; + else + pickup_mode = read_bool_or_number(field, pickup_mode, "auto:"); + } // Catch-all else, copies option into map else { diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 678c94fa82..d0d9310494 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -697,13 +697,15 @@ static bool invisible_to_player( const item_def& item ) { return strstr(item.inscription.c_str(), "=k") != 0; } -static bool has_nonsquelched_items( int obj ) { - while ( obj != NON_ITEM ) { +static int count_nonsquelched_items( int obj ) { + int result = 0; + while ( obj != NON_ITEM ) + { if ( !invisible_to_player(mitm[obj]) ) - return true; + ++result; obj = mitm[obj].link; } - return false; + return result; } /* Fill items with the items on a square. @@ -716,7 +718,7 @@ static void item_list_on_square( std::vector& items, int obj, bool force_squelch ) { const bool have_nonsquelched = (force_squelch || - has_nonsquelched_items(obj)); + count_nonsquelched_items(obj)); /* loop through the items */ while ( obj != NON_ITEM ) { @@ -1204,6 +1206,7 @@ void pickup() } int o = igrd[you.x_pos][you.y_pos]; + const int num_nonsquelched = count_nonsquelched_items(o); if (o == NON_ITEM) { @@ -1214,18 +1217,22 @@ void pickup() // deliberately allowing the player to pick up // a killed item here pickup_single_item(o, mitm[o].quantity); - } // end of if items_here + } + else if (Options.pickup_mode != -1 && + num_nonsquelched >= Options.pickup_mode) + { + pickup_menu(o); + } else { int next; mpr("There are several objects here."); - const bool hide_squelched = has_nonsquelched_items(o); while ( o != NON_ITEM ) { // must save this because pickup can destroy the item next = mitm[o].link; - if ( hide_squelched && invisible_to_player(mitm[o]) ) { + if ( num_nonsquelched && invisible_to_player(mitm[o]) ) { o = next; continue; } -- cgit v1.2.3-54-g00ecf