Anonymous | Login | 2024-04-25 08:15 CEST |
Main | My View | View Issues | Change Log | Wiki | Tavern | News |
Viewing Issue Simple Details [ Jump to Notes ] [ Wiki ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||||||||
ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||||||
0004183 | [DCSS] Implementables | minor | have not tried | 2011-06-28 01:42 | 2011-07-10 16:45 | ||||||||
Reporter | dpeg | View Status | public | ||||||||||
Assigned To | galehar | ||||||||||||
Priority | normal | Resolution | done | ||||||||||
Status | resolved | Product Branch | 0.10 ancient branch | ||||||||||
Summary | 0004183: D command for dropping item last picked up | ||||||||||||
Description |
Very often, you pick up something you drop again right away. It would be good to use the 'D' key in order to do that. (The advantage is that you don't have to bother what item slot that item got.) If you picked up several items in that turn, drop them all. More advanced: * indicate the 'D' item in the inventory * have a stack so that you can keep 'D'ropping |
||||||||||||
Additional Information | |||||||||||||
Tags | No tags attached. | ||||||||||||
Attached Files |
0001-Added-basic-drop-last-functionality.-Still-need-erro.patch [^] (5,242 bytes) 2011-06-30 08:11 [Show Content] [Hide Content]From 771eea48e3e9faa9563a204188c046ba3ed5fa07 Mon Sep 17 00:00:00 2001 From: Gustaf Hallberg <ghallberg@gmail.com> Date: Thu, 30 Jun 2011 00:57:08 +0200 Subject: [PATCH 1/3] Added basic drop-last functionality. Still need error message if there's nothing to drop. --- crawl-ref/source/cmd-keys.h | 1 + crawl-ref/source/cmd-name.h | 1 + crawl-ref/source/command.cc | 7 +++++++ crawl-ref/source/enum.h | 1 + crawl-ref/source/items.cc | 16 ++++++++++++++++ crawl-ref/source/items.h | 1 + crawl-ref/source/main.cc | 7 +++++++ crawl-ref/source/player.cc | 1 + crawl-ref/source/player.h | 1 + 9 files changed, 36 insertions(+), 0 deletions(-) diff --git a/crawl-ref/source/cmd-keys.h b/crawl-ref/source/cmd-keys.h index 57a10e7..b75ef80 100644 --- a/crawl-ref/source/cmd-keys.h +++ b/crawl-ref/source/cmd-keys.h @@ -39,6 +39,7 @@ {'a', CMD_USE_ABILITY}, {'c', CMD_BUTCHER}, {'d', CMD_DROP}, +{'D', CMD_DROP_LAST}, {'e', CMD_EAT}, {'f', CMD_FIRE}, {'g', CMD_PICKUP}, diff --git a/crawl-ref/source/cmd-name.h b/crawl-ref/source/cmd-name.h index 9469ce5..9890213 100644 --- a/crawl-ref/source/cmd-name.h +++ b/crawl-ref/source/cmd-name.h @@ -36,6 +36,7 @@ {CMD_PICKUP, "CMD_PICKUP"}, {CMD_PICKUP_QUANTITY, "CMD_PICKUP_QUANTITY"}, {CMD_DROP, "CMD_DROP"}, +{CMD_DROP_LAST, "CMD_DROP_LAST"}, {CMD_BUTCHER, "CMD_BUTCHER"}, {CMD_INSPECT_FLOOR, "CMD_INSPECT_FLOOR"}, {CMD_SHOW_TERRAIN, "CMD_SHOW_TERRAIN"}, diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 510208e..ac76d15 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -282,6 +282,13 @@ void adjust(void) void swap_inv_slots(int from_slot, int to_slot, bool verbose) { + if (you.last_pickup->slot == you.inv[to_slot].slot || + you.last_pickup->slot == you.inv[from_slot].slot) + { + you.last_pickup = NULL; + } + + // Swap items. item_def tmp = you.inv[to_slot]; you.inv[to_slot] = you.inv[from_slot]; diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 5a671e6..9ad03ed 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -592,6 +592,7 @@ enum command_type CMD_PICKUP, CMD_PICKUP_QUANTITY, CMD_DROP, + CMD_DROP_LAST, CMD_BUTCHER, CMD_INSPECT_FLOOR, CMD_SHOW_TERRAIN, diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 3b9b48a..635782c 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1781,6 +1781,9 @@ int move_item_to_player(int obj, int quant_got, bool quiet, if (!item.slot) item.slot = index_to_letter(item.link); + you.last_pickup = &item; + + ash_id_item(item); note_inscribe_item(item); @@ -2228,6 +2231,19 @@ bool drop_item(int item_dropped, int quant_drop) return (true); } +bool drop_last() +{ + if (you.last_pickup != NULL) + { + if (drop_item(you.last_pickup->link, -1)) + { + you.last_pickup = NULL; + return true; + } + } + return false; +} + static std::string _drop_menu_invstatus(const Menu *menu) { const int cap = carrying_capacity(BS_UNENCUMBERED); diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h index b8899d3..1305540 100644 --- a/crawl-ref/source/items.h +++ b/crawl-ref/source/items.h @@ -103,6 +103,7 @@ int runes_in_pack(); bool pickup_single_item(int link, int qty); bool drop_item(int item_dropped, int quant_drop); +bool drop_last(void); int get_equip_slot(const item_def *item); mon_inv_type get_mon_equip_slot(const monster* mon, const item_def &item); diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index c665a2b..a1d3360 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -870,6 +870,7 @@ static bool _cmd_is_repeatable(command_type cmd, bool is_again = false) // Multi-turn commands case CMD_PICKUP: case CMD_DROP: + case CMD_DROP_LAST: case CMD_BUTCHER: case CMD_GO_UPSTAIRS: case CMD_GO_DOWNSTAIRS: @@ -1890,6 +1891,12 @@ void process_command(command_type cmd) StashTrack.add_stash(); break; + case CMD_DROP_LAST: + drop_last(); + if (Options.stash_tracking >= STM_DROPPED) + StashTrack.add_stash(); + break; + case CMD_EVOKE: if (!evoke_item()) flush_input_buffer(FLUSH_ON_FAILURE); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index dac1f87..8b0064a 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5202,6 +5202,7 @@ void player::init() stat_zero.init(0); stat_zero_cause.init(""); last_chosen = STAT_RANDOM; + last_pickup = NULL; hunger = 6000; hunger_state = HS_SATIATED; diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index e21c515..1ac0ea0 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -83,6 +83,7 @@ public: FixedVector< item_def, ENDOFPACK > inv; FixedBitArray<NUM_RUNE_TYPES> runes; int obtainable_runes; // can be != 15 in Sprint + item_def *last_pickup; int burden; burden_state_type burden_state; -- 1.7.6 0002-Added-Nothing-to-drop.-message-if-we-don-t-know-what.patch [^] (656 bytes) 2011-06-30 08:11 [Show Content] [Hide Content] From 42cb1f3123c65158ff702178551d28cf983ef1cd Mon Sep 17 00:00:00 2001 From: Gustaf Hallberg <ghallberg@gmail.com> Date: Thu, 30 Jun 2011 07:59:41 +0200 Subject: [PATCH 2/3] Added "Nothing to drop."-message if we don't know what to drop with drop-last. --- crawl-ref/source/items.cc | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 635782c..8d43328 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2241,6 +2241,7 @@ bool drop_last() return true; } } + mprf("Nothing to drop."); return false; } -- 1.7.6 0001-Added-drop_last-functionality.-D-drops-the-last-item.patch [^] (17,555 bytes) 2011-07-02 10:56 [Show Content] [Hide Content] From 6465801f9ba8a2a2549ff9614abc3129d7c48a06 Mon Sep 17 00:00:00 2001 From: Gustaf Hallberg <ghallberg@gmail.com> Date: Sat, 2 Jul 2011 10:54:39 +0200 Subject: [PATCH] Added 'drop_last' functionality. 'D' drops the last item(s) you picked up. --- crawl-ref/source/cmd-keys.h | 1 + crawl-ref/source/cmd-name.h | 1 + crawl-ref/source/command.cc | 6 +++ crawl-ref/source/dat/des/portals/spider.des | 52 +++++++++++++------------- crawl-ref/source/dat/des/variable/altar.des | 8 ++-- crawl-ref/source/enum.h | 1 + crawl-ref/source/fight.cc | 8 ++-- crawl-ref/source/initfile.cc | 4 +- crawl-ref/source/item_use.cc | 16 ++++---- crawl-ref/source/items.cc | 37 ++++++++++++++++++- crawl-ref/source/items.h | 1 + crawl-ref/source/main.cc | 7 ++++ crawl-ref/source/options.h | 2 +- crawl-ref/source/player.h | 2 + crawl-ref/source/spl-damage.cc | 2 +- 15 files changed, 101 insertions(+), 47 deletions(-) diff --git a/crawl-ref/source/cmd-keys.h b/crawl-ref/source/cmd-keys.h index 57a10e7..f3d1080 100644 --- a/crawl-ref/source/cmd-keys.h +++ b/crawl-ref/source/cmd-keys.h @@ -74,6 +74,7 @@ {'Y', CMD_RUN_UP_LEFT}, {'A', CMD_DISPLAY_MUTATIONS}, {'C', CMD_CLOSE_DOOR}, +{'D', CMD_DROP_LAST}, {'E', CMD_EXPERIENCE_CHECK}, {'F', CMD_THROW_ITEM_NO_QUIVER}, {CONTROL('G'), CMD_INTERLEVEL_TRAVEL}, diff --git a/crawl-ref/source/cmd-name.h b/crawl-ref/source/cmd-name.h index 9469ce5..9890213 100644 --- a/crawl-ref/source/cmd-name.h +++ b/crawl-ref/source/cmd-name.h @@ -36,6 +36,7 @@ {CMD_PICKUP, "CMD_PICKUP"}, {CMD_PICKUP_QUANTITY, "CMD_PICKUP_QUANTITY"}, {CMD_DROP, "CMD_DROP"}, +{CMD_DROP_LAST, "CMD_DROP_LAST"}, {CMD_BUTCHER, "CMD_BUTCHER"}, {CMD_INSPECT_FLOOR, "CMD_INSPECT_FLOOR"}, {CMD_SHOW_TERRAIN, "CMD_SHOW_TERRAIN"}, diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 510208e..fe73a56 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -318,6 +318,10 @@ void swap_inv_slots(int from_slot, int to_slot, bool verbose) } else // just to make sure you.redraw_quiver = true; + + // Remove the moved items from last_drop if they're there. + you.last_pickup.erase(to_slot); + you.last_pickup.erase(from_slot); } static void _adjust_item(void) @@ -2452,6 +2456,7 @@ static void _add_formatted_keyhelp(column_composer &cols) _add_command(cols, 1, CMD_DROP, "Drop an item", 2); _add_insert_commands(cols, 1, "<w>%#</w>: Drop exact number of items", CMD_DROP, 0); + _add_command(cols, 1, CMD_DROP_LAST, "Drop the last item(s) you picked up", 2); _add_command(cols, 1, CMD_BUTCHER, "Chop up a corpse", 2); { @@ -2639,6 +2644,7 @@ static void _add_formatted_hints_help(column_composer &cols) _add_command(cols, 1, CMD_DISPLAY_INVENTORY, "list inventory (select item to view it)", 2); _add_command(cols, 1, CMD_PICKUP, "pick up item from ground (also <w>g</w>)", 2); _add_command(cols, 1, CMD_DROP, "drop item", 2); + _add_command(cols, 1, CMD_DROP_LAST, "drop the last item(s) you picked up", 2); cols.add_formatted( 1, diff --git a/crawl-ref/source/dat/des/portals/spider.des b/crawl-ref/source/dat/des/portals/spider.des index e08e42f..57aa1c2 100644 --- a/crawl-ref/source/dat/des/portals/spider.des +++ b/crawl-ref/source/dat/des/portals/spider.des @@ -195,7 +195,7 @@ xxx...xx xWW.Wx xW....xxxxxx.2222.xx..xx.....Wxxxxx.<*x xxxx...xxxx...xx...x..x...xx..Wxxx....x xx...xx...xxxx........xxxx..Wx...xxx - xx......xxxxxx..44..xxxxxx.55..xx + xx......xxxxxx..44..xxxxxx.55..xx xx............4554.......5665xx xW..3........4554.......5665x xWW..xxxxxxxW.44.Wxxxxxx.55.x @@ -418,40 +418,40 @@ epilogue{{ spiders_nest_milestone(_G) }} MAP - xxxx xxxxx - xw6x x6wwx - xwxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwx6x - xxxxw..WWWW...7..7.WWWWWWWW.7.WWWWwxxx - xxwwyyx....7.WWWWWWW...7..7.WWW.7.WWxxx - xwwyww.WWWxxxxxxxxxxxxxxxxxxxWWWwW.7Wxx - xxwAwxxxwxxxx66xxxxxxxxxxxxxxxxxwxxxW.Wx + xxxx xxxxx + xw6x x6wwx + xwxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwx6x + xxxxw..WWWW...7..7.WWWWWWWW.7.WWWWwxxx + xxwwyyx....7.WWWWWWW...7..7.WWW.7.WWxxx + xwwyww.WWWxxxxxxxxxxxxxxxxxxxWWWwW.7Wxx + xxwAwxxxwxxxx66xxxxxxxxxxxxxxxxxwxxxW.Wx xw<wxxxxxwxx66xxxxxxxWWxxxxxx66wxxxxW.Wxx xw.wx x6xwwwxxxxxxWW.7.WWxxxxxw66xxxW7Wxx xxwWxx xxxxxxwxWW.7..WWW.7.WWWxxwxxxxxW.Wx - xWWWx xwW7..WWWXxxxWWW...7wxxxxxxW7Wxxx - xWwxx xxW.WwxxxxxxxxxxxXXWw.WxxxxxxW.Xxxx - xxwxx xxW.WxxwwxxxxxxxxxxxxwW.WxxxxxxW.W5xx + xWWWx xwW7..WWWXxxxWWW...7wxxxxxxW7Wxxx + xWwxx xxW.WwxxxxxxxxxxxXXWw.WxxxxxxW.Xxxx + xxwxx xxW.WxxwwxxxxxxxxxxxxwW.WxxxxxxW.W5xx xxwxx xxW.2xxxxxwwxxxxxxxxxwxxW.Wxxx5xxW.Wxx xxwxx xxxxx7.WxxxxxxxxwwxxxxxxwxxxxW7WxxxwwW7Wwxx xwxx x4xx.WWxxxxxxx2...w.22.wxxxxxxW.wwwx5xW.Wwx xxx xxw.WXxxxxxx2..2|x2w..w.xxxxwwwW.WxxxxW.Wxx xx7WXxxxxx2..2.x2www.w..2wwwxxxW7WxxxW7Wxx - xxW.Wxxxxx2.x...ww11wwxwww2xxxxxXW.xxxW.Wx - xxW.Wxxxxxxx..wwwww11www...2xxxxxXW.xxx.Wxx - xW.Wxxxxxxwwww.x..www.x.www.2xxxxXW7xxW.3x - xxxxxxxW.WWxxxwwxxxx....x........wxxxxXW.xxxW7xx - x4xx44wwW.<WWwxxxxxxxxx......xxxxxwxxxW.WxxW.Wx - xx34wwwxxWWW.7.WWWxxxxxxxxxxW.WWWWxwxxW7Wxxx.Wxx - x3ww44xxxxxxWWW.7.WWXxxxxxxxxW7.v.WWwWW.WxxW7Wx -xxwxxx2x xxxxWWW.WWWXXxxxxxxxxWW..<..Wxxx.WWx -xwxx xxx xxxxW.7WWW.7.xxxxxxxWWWWWxxx4.Wxx -xxx xxxx...WWW.7.xxxxxxxxwxxxW74x - xxwxxXXWWWW.Wxxxx55w5xW.Wxx + xxW.Wxxxxx2.x...ww11wwxwww2xxxxxXW.xxxW.Wx + xxW.Wxxxxxxx..wwwww11www...2xxxxxXW.xxx.Wxx + xW.Wxxxxxxwwww.x..www.x.www.2xxxxXW7xxW.3x + xxxxxxxW.WWxxxwwxxxx....x........wxxxxXW.xxxW7xx + x4xx44wwW.<WWwxxxxxxxxx......xxxxxwxxxW.WxxW.Wx + xx34wwwxxWWW.7.WWWxxxxxxxxxxW.WWWWxwxxW7Wxxx.Wxx + x3ww44xxxxxxWWW.7.WWXxxxxxxxxW7.v.WWwWW.WxxW7Wx +xxwxxx2x xxxxWWW.WWWXXxxxxxxxxWW..<..Wxxx.WWx +xwxx xxx xxxxW.7WWW.7.xxxxxxxWWWWWxxx4.Wxx +xxx xxxx...WWW.7.xxxxxxxxwxxxW74x + xxwxxXXWWWW.Wxxxx55w5xW.Wxx x42xxxxxXXWW..Wxxxx5wxW7Wx xxxx xxxxXWW.7WxxxwxW.Wx xxxxWW..WxwW.Wxx - xxxxW...7WXx - xxxxWWWxx - xxxwx - xxx + xxxxW...7WXx + xxxxWWWxx + xxxwx + xxx ENDMAP diff --git a/crawl-ref/source/dat/des/variable/altar.des b/crawl-ref/source/dat/des/variable/altar.des index 7bff6c4..e5c2963 100644 --- a/crawl-ref/source/dat/des/variable/altar.des +++ b/crawl-ref/source/dat/des/variable/altar.des @@ -733,7 +733,7 @@ MAP ... d_e ... -ENDMAP +ENDMAP ### Cheibriados overflow altars ############################################### @@ -1692,11 +1692,11 @@ ENDMAP # Troves might choose one of these items as their fee, too. Items are # marked as "seen" for acquirement purposes as well. Under Ashenzari, # you won't pick up rings and amulets seen in this vault since having -# one is considered enough for most types (this logic is partially +# one is considered enough for most types (this logic is partially # faulty with identification being possible without having the item in # your inventory). -# If the second part doesn't scare you, I think merging this -# functionality into current _is_affordable() could be good -- that +# If the second part doesn't scare you, I think merging this +# functionality into current _is_affordable() could be good -- that # function contains crude heurestics for items on display. # NAME: xom_gifts_altar diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 5a671e6..9ad03ed 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -592,6 +592,7 @@ enum command_type CMD_PICKUP, CMD_PICKUP_QUANTITY, CMD_DROP, + CMD_DROP_LAST, CMD_BUTCHER, CMD_INSPECT_FLOOR, CMD_SHOW_TERRAIN, diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 819bfd8..7db7377 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -6142,11 +6142,11 @@ bool wielded_weapon_check(item_def *weapon, bool no_message) if (needs_handle_warning(*weapon, OPER_ATTACK)) weapon_warning = true; else if(!_is_melee_weapon(weapon)) - { - weapon_warning = true; + { + weapon_warning = true; // We switch to the first available melee weapon. - if(Options.auto_switch) + if(Options.auto_switch) for (int i = 0; i <= 1; ++i) if(_is_melee_weapon(&you.inv[i])) { @@ -6154,7 +6154,7 @@ bool wielded_weapon_check(item_def *weapon, bool no_message) // This attack is cancelled, but we switched weapons return (false); } - } + } } else if (you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] && you_tran_can_wear(EQ_WEAPON)) diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 34b4ba3..feb8c0c 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -744,7 +744,7 @@ void game_options::reset_options() (1 << 7) | // jewellery (1 << 3) | // wands (1 << 4)); // food - auto_switch =true; + auto_switch =true; suppress_startup_errors = false; show_inventory_weights = false; @@ -2210,7 +2210,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) else BOOL_OPTION(restart_after_game); #endif else BOOL_OPTION(show_inventory_weights); - else BOOL_OPTION(auto_switch); + else BOOL_OPTION(auto_switch); else BOOL_OPTION(suppress_startup_errors); else BOOL_OPTION(clean_map); else BOOL_OPTION(colour_map); diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index c265d20..bc1f437 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1287,16 +1287,16 @@ int get_ammo_to_shoot(int item, dist &target, bool teleport) return (-1); } - if(Options.auto_switch && you.m_quiver->get_fire_item() == -1 - && _autoswitch_to_ranged()) - { - return (-1); - } + if(Options.auto_switch && you.m_quiver->get_fire_item() == -1 + && _autoswitch_to_ranged()) + { + return (-1); + } - if(!_fire_choose_item_and_target(item, target, teleport)) - return (-1); + if(!_fire_choose_item_and_target(item, target, teleport)) + return (-1); - std::string warn; + std::string warn; if (!_fire_validate_item(item, warn)) { mpr(warn.c_str()); diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 3b9b48a..335459f 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1269,6 +1269,11 @@ void pickup(bool partial_quantity) int o = you.visible_igrd(you.pos()); const int num_nonsquelched = _count_nonsquelched_items(o); + // Store last_pickup in case we need to restore it. + // Then clear it to fill with items picked up. + std::map<int,int> tmp_l_p = you.last_pickup; + you.last_pickup.clear(); + if (o == NON_ITEM) { mpr("There are no items here."); @@ -1276,7 +1281,6 @@ void pickup(bool partial_quantity) else if (you.form == TRAN_ICE_BEAST && grd(you.pos()) == DNGN_DEEP_WATER) { mpr("You can't reach the bottom while floating on water."); - return; } else if (mitm[o].link == NON_ITEM) // just one item? { @@ -1355,6 +1359,8 @@ void pickup(bool partial_quantity) if (!pickup_warning.empty()) mpr(pickup_warning.c_str()); } + if (you.last_pickup.empty()) + you.last_pickup = tmp_l_p; } bool is_stackable_item(const item_def &item) @@ -1742,6 +1748,7 @@ int move_item_to_player(int obj, int quant_got, bool quiet, } you.turn_is_over = true; + you.last_pickup[m] = quant_got; return (retval); } } @@ -1835,6 +1842,8 @@ int move_item_to_player(int obj, int quant_got, bool quiet, you.turn_is_over = true; + you.last_pickup[item.link] = retval; + return (retval); } @@ -2225,9 +2234,27 @@ bool drop_item(int item_dropped, int quant_drop) dec_inv_item_quantity(item_dropped, quant_drop); you.turn_is_over = true; + you.last_pickup.erase(item_dropped); + return (true); } +bool drop_last() +{ + typedef std::map<int,int> MapType; + if (you.last_pickup.empty()) + { + mprf("No item to drop."); + return false; + } + MapType::iterator end = you.last_pickup.end(); + for (MapType::iterator it = you.last_pickup.begin(); it != end; ++it) + { + drop_item(it->first, it->second); + } + return true; +} + static std::string _drop_menu_invstatus(const Menu *menu) { const int cap = carrying_capacity(BS_UNENCUMBERED); @@ -2791,6 +2818,11 @@ static void _do_autopickup() return; } + // Store last_pickup in case we need to restore it. + // Then clear it to fill with items picked up. + std::map<int,int> tmp_l_p = you.last_pickup; + you.last_pickup.clear(); + int o = you.visible_igrd(you.pos()); std::string pickup_warning; @@ -2865,6 +2897,9 @@ static void _do_autopickup() if (did_pickup) you.turn_is_over = true; + if (you.last_pickup.empty()) + you.last_pickup = tmp_l_p; + item_check(false); explore_pickup_event(n_did_pickup, n_tried_pickup); diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h index b8899d3..dc47ec7 100644 --- a/crawl-ref/source/items.h +++ b/crawl-ref/source/items.h @@ -103,6 +103,7 @@ int runes_in_pack(); bool pickup_single_item(int link, int qty); bool drop_item(int item_dropped, int quant_drop); +bool drop_last(); int get_equip_slot(const item_def *item); mon_inv_type get_mon_equip_slot(const monster* mon, const item_def &item); diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index c665a2b..a1d3360 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -870,6 +870,7 @@ static bool _cmd_is_repeatable(command_type cmd, bool is_again = false) // Multi-turn commands case CMD_PICKUP: case CMD_DROP: + case CMD_DROP_LAST: case CMD_BUTCHER: case CMD_GO_UPSTAIRS: case CMD_GO_DOWNSTAIRS: @@ -1890,6 +1891,12 @@ void process_command(command_type cmd) StashTrack.add_stash(); break; + case CMD_DROP_LAST: + drop_last(); + if (Options.stash_tracking >= STM_DROPPED) + StashTrack.add_stash(); + break; + case CMD_EVOKE: if (!evoke_item()) flush_input_buffer(FLUSH_ON_FAILURE); diff --git a/crawl-ref/source/options.h b/crawl-ref/source/options.h index 181c465..7a24765 100644 --- a/crawl-ref/source/options.h +++ b/crawl-ref/source/options.h @@ -99,7 +99,7 @@ public: bool show_beam; // Show targeting beam by default. uint32_t autopickups; // items to autopickup - bool auto_switch; // switch melee&ranged weapons according to enemy range + bool auto_switch; // switch melee&ranged weapons according to enemy range bool show_inventory_weights; // show weights in inventory listings bool colour_map; // add colour to the map bool clean_map; // remove unseen clouds/monsters diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index e21c515..5fd4b70 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -456,6 +456,8 @@ public: const item_def *slot_item(equipment_type eq, bool include_melded=false) const; + std::map<int,int> last_pickup; + // actor int mindex() const; int get_experience_level() const; diff --git a/crawl-ref/source/spl-damage.cc b/crawl-ref/source/spl-damage.cc index c014caf..b30bf7c 100644 --- a/crawl-ref/source/spl-damage.cc +++ b/crawl-ref/source/spl-damage.cc @@ -768,7 +768,7 @@ static int _shatter_monsters(coord_def where, int pow, int, actor *) dam_dice.num = 0; // 1/3 damage to fliers and slimes. else if (mons_flies(mon) || mons_is_slime(mon)) - dam_dice.num = 1; + dam_dice.num = 1; // 3/2 damage to ice. else if (mon->is_icy()) dam_dice.num = 4; -- 1.7.6 0001-Drop-last.patch [^] (7,728 bytes) 2011-07-02 11:26 [Show Content] [Hide Content] From d87cbc6931d086201ab35629edacab2b71d48a45 Mon Sep 17 00:00:00 2001 From: Gustaf Hallberg <ghallberg@gmail.com> Date: Sat, 2 Jul 2011 11:19:50 +0200 Subject: [PATCH] Drop last --- crawl-ref/source/cmd-keys.h | 1 + crawl-ref/source/cmd-name.h | 1 + crawl-ref/source/command.cc | 6 ++++++ crawl-ref/source/enum.h | 1 + crawl-ref/source/items.cc | 37 ++++++++++++++++++++++++++++++++++++- crawl-ref/source/items.h | 1 + crawl-ref/source/main.cc | 7 +++++++ crawl-ref/source/player.h | 2 ++ 8 files changed, 55 insertions(+), 1 deletions(-) diff --git a/crawl-ref/source/cmd-keys.h b/crawl-ref/source/cmd-keys.h index 57a10e7..f3d1080 100644 --- a/crawl-ref/source/cmd-keys.h +++ b/crawl-ref/source/cmd-keys.h @@ -74,6 +74,7 @@ {'Y', CMD_RUN_UP_LEFT}, {'A', CMD_DISPLAY_MUTATIONS}, {'C', CMD_CLOSE_DOOR}, +{'D', CMD_DROP_LAST}, {'E', CMD_EXPERIENCE_CHECK}, {'F', CMD_THROW_ITEM_NO_QUIVER}, {CONTROL('G'), CMD_INTERLEVEL_TRAVEL}, diff --git a/crawl-ref/source/cmd-name.h b/crawl-ref/source/cmd-name.h index 9469ce5..9890213 100644 --- a/crawl-ref/source/cmd-name.h +++ b/crawl-ref/source/cmd-name.h @@ -36,6 +36,7 @@ {CMD_PICKUP, "CMD_PICKUP"}, {CMD_PICKUP_QUANTITY, "CMD_PICKUP_QUANTITY"}, {CMD_DROP, "CMD_DROP"}, +{CMD_DROP_LAST, "CMD_DROP_LAST"}, {CMD_BUTCHER, "CMD_BUTCHER"}, {CMD_INSPECT_FLOOR, "CMD_INSPECT_FLOOR"}, {CMD_SHOW_TERRAIN, "CMD_SHOW_TERRAIN"}, diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 510208e..fe73a56 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -318,6 +318,10 @@ void swap_inv_slots(int from_slot, int to_slot, bool verbose) } else // just to make sure you.redraw_quiver = true; + + // Remove the moved items from last_drop if they're there. + you.last_pickup.erase(to_slot); + you.last_pickup.erase(from_slot); } static void _adjust_item(void) @@ -2452,6 +2456,7 @@ static void _add_formatted_keyhelp(column_composer &cols) _add_command(cols, 1, CMD_DROP, "Drop an item", 2); _add_insert_commands(cols, 1, "<w>%#</w>: Drop exact number of items", CMD_DROP, 0); + _add_command(cols, 1, CMD_DROP_LAST, "Drop the last item(s) you picked up", 2); _add_command(cols, 1, CMD_BUTCHER, "Chop up a corpse", 2); { @@ -2639,6 +2644,7 @@ static void _add_formatted_hints_help(column_composer &cols) _add_command(cols, 1, CMD_DISPLAY_INVENTORY, "list inventory (select item to view it)", 2); _add_command(cols, 1, CMD_PICKUP, "pick up item from ground (also <w>g</w>)", 2); _add_command(cols, 1, CMD_DROP, "drop item", 2); + _add_command(cols, 1, CMD_DROP_LAST, "drop the last item(s) you picked up", 2); cols.add_formatted( 1, diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 5a671e6..9ad03ed 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -592,6 +592,7 @@ enum command_type CMD_PICKUP, CMD_PICKUP_QUANTITY, CMD_DROP, + CMD_DROP_LAST, CMD_BUTCHER, CMD_INSPECT_FLOOR, CMD_SHOW_TERRAIN, diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 3b9b48a..335459f 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1269,6 +1269,11 @@ void pickup(bool partial_quantity) int o = you.visible_igrd(you.pos()); const int num_nonsquelched = _count_nonsquelched_items(o); + // Store last_pickup in case we need to restore it. + // Then clear it to fill with items picked up. + std::map<int,int> tmp_l_p = you.last_pickup; + you.last_pickup.clear(); + if (o == NON_ITEM) { mpr("There are no items here."); @@ -1276,7 +1281,6 @@ void pickup(bool partial_quantity) else if (you.form == TRAN_ICE_BEAST && grd(you.pos()) == DNGN_DEEP_WATER) { mpr("You can't reach the bottom while floating on water."); - return; } else if (mitm[o].link == NON_ITEM) // just one item? { @@ -1355,6 +1359,8 @@ void pickup(bool partial_quantity) if (!pickup_warning.empty()) mpr(pickup_warning.c_str()); } + if (you.last_pickup.empty()) + you.last_pickup = tmp_l_p; } bool is_stackable_item(const item_def &item) @@ -1742,6 +1748,7 @@ int move_item_to_player(int obj, int quant_got, bool quiet, } you.turn_is_over = true; + you.last_pickup[m] = quant_got; return (retval); } } @@ -1835,6 +1842,8 @@ int move_item_to_player(int obj, int quant_got, bool quiet, you.turn_is_over = true; + you.last_pickup[item.link] = retval; + return (retval); } @@ -2225,9 +2234,27 @@ bool drop_item(int item_dropped, int quant_drop) dec_inv_item_quantity(item_dropped, quant_drop); you.turn_is_over = true; + you.last_pickup.erase(item_dropped); + return (true); } +bool drop_last() +{ + typedef std::map<int,int> MapType; + if (you.last_pickup.empty()) + { + mprf("No item to drop."); + return false; + } + MapType::iterator end = you.last_pickup.end(); + for (MapType::iterator it = you.last_pickup.begin(); it != end; ++it) + { + drop_item(it->first, it->second); + } + return true; +} + static std::string _drop_menu_invstatus(const Menu *menu) { const int cap = carrying_capacity(BS_UNENCUMBERED); @@ -2791,6 +2818,11 @@ static void _do_autopickup() return; } + // Store last_pickup in case we need to restore it. + // Then clear it to fill with items picked up. + std::map<int,int> tmp_l_p = you.last_pickup; + you.last_pickup.clear(); + int o = you.visible_igrd(you.pos()); std::string pickup_warning; @@ -2865,6 +2897,9 @@ static void _do_autopickup() if (did_pickup) you.turn_is_over = true; + if (you.last_pickup.empty()) + you.last_pickup = tmp_l_p; + item_check(false); explore_pickup_event(n_did_pickup, n_tried_pickup); diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h index b8899d3..dc47ec7 100644 --- a/crawl-ref/source/items.h +++ b/crawl-ref/source/items.h @@ -103,6 +103,7 @@ int runes_in_pack(); bool pickup_single_item(int link, int qty); bool drop_item(int item_dropped, int quant_drop); +bool drop_last(); int get_equip_slot(const item_def *item); mon_inv_type get_mon_equip_slot(const monster* mon, const item_def &item); diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index c665a2b..a1d3360 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -870,6 +870,7 @@ static bool _cmd_is_repeatable(command_type cmd, bool is_again = false) // Multi-turn commands case CMD_PICKUP: case CMD_DROP: + case CMD_DROP_LAST: case CMD_BUTCHER: case CMD_GO_UPSTAIRS: case CMD_GO_DOWNSTAIRS: @@ -1890,6 +1891,12 @@ void process_command(command_type cmd) StashTrack.add_stash(); break; + case CMD_DROP_LAST: + drop_last(); + if (Options.stash_tracking >= STM_DROPPED) + StashTrack.add_stash(); + break; + case CMD_EVOKE: if (!evoke_item()) flush_input_buffer(FLUSH_ON_FAILURE); diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index e21c515..5fd4b70 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -456,6 +456,8 @@ public: const item_def *slot_item(equipment_type eq, bool include_melded=false) const; + std::map<int,int> last_pickup; + // actor int mindex() const; int get_experience_level() const; -- 1.7.6 0001-Make-drop_last-play-nice-when-an-item-is-used-up-bef.patch [^] (984 bytes) 2011-07-02 22:03 [Show Content] [Hide Content] From a2957658f4e693666a34562d38a464bbc0616fa4 Mon Sep 17 00:00:00 2001 From: Gustaf Hallberg <ghallberg@gmail.com> Date: Sat, 2 Jul 2011 22:01:53 +0200 Subject: [PATCH] Make drop_last play nice when an item is used up before dropping. --- crawl-ref/source/items.cc | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 44e99e0..ce7b6fd 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2249,7 +2249,17 @@ bool drop_last() } MapType::iterator end = you.last_pickup.end(); for (MapType::iterator it = you.last_pickup.begin(); it != end; ++it) - drop_item(it->first, it->second); + { + if (you.inv[it->first].quantity > 0) + { + drop_item(it->first, it->second); + } + else + { + mprf("No item to drop."); + return false; + } + } return true; } -- 1.7.6 0001-Prevent-infinite-loop-just-in-case.patch [^] (973 bytes) 2011-07-10 16:41 [Show Content] [Hide Content] From 67a03ef825605ad621036ede743da5c6517172da Mon Sep 17 00:00:00 2001 From: Hurcan Solter <hsolter@gmail.com> Date: Sun, 10 Jul 2011 07:30:28 +0300 Subject: [PATCH] Prevent infinite loop just in case --- crawl-ref/source/items.cc | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 499265e..3131cc3 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2239,10 +2239,10 @@ bool drop_last() MapType::iterator it = you.last_pickup.begin(); while (it != you.last_pickup.end()) { - if (you.inv[it->first].quantity > 0) + std::pair<int,int> curr_item = *it++; + if (you.inv[curr_item.first].quantity > 0) { - std::pair<int,int> pair = *it++; - drop_item(pair.first, pair.second); + drop_item(curr_item.first, curr_item.second); dropped = true; } } -- 1.7.5.GIT |
||||||||||||
|
Mantis 1.1.8[^] Copyright © 2000 - 2009 Mantis Group |