diff options
-rw-r--r-- | crawl-ref/docs/options_guide.txt | 5 | ||||
-rw-r--r-- | crawl-ref/settings/init.txt | 1 | ||||
-rw-r--r-- | crawl-ref/source/acr.cc | 9 | ||||
-rw-r--r-- | crawl-ref/source/delay.cc | 33 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/it_use2.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 2 |
9 files changed, 50 insertions, 7 deletions
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index ca6ed2ba1e..d774a1c088 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -916,6 +916,11 @@ chunks_autopickup = false all of the autopickup options. Requires '%' to be in the autopickup line. +swap_when_safe = false + If both this and easy_butcher are true, then if an auto-switch + butchery is interupted, then the auto-switch will be reversed + as soon as your safe again. + easy_quit_item_prompts = true Setting this option to true allows the quitting of item listing with Space (as well as Escape, which always works). These lists diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt index 416dbdba66..60851d5681 100644 --- a/crawl-ref/settings/init.txt +++ b/crawl-ref/settings/init.txt @@ -206,6 +206,7 @@ include = travel_stoppers.txt # easy_butcher = false # always_confirm_butcher = true # chunks_autopickup = true +# swap_when_safe = true # easy_quit_item_prompts = false # easy_exit_menu = false # sort_menus = pickup: true : basename, qualname, curse, qty diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index dad3f3faf6..ca8da8a4ee 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1414,6 +1414,15 @@ static void _input() if (need_to_autoinscribe()) autoinscribe(); + if (i_feel_safe() && you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]) + { + weapon_switch(you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]); + print_stats(); + + // To prevent spam in case the weapon can't be switched back to. + you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0; + } + handle_delay(); const coord_def cwhere = grid2view(you.pos()); diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index e796164ac7..77c9d18412 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -268,12 +268,22 @@ static void pop_delay() you.delay_queue.erase( you.delay_queue.begin() ); } +static int delays_cleared[NUM_DELAYS]; +static int cleared_delays_parm1[NUM_DELAYS]; + static void clear_pending_delays() { + memset(delays_cleared, 0, sizeof(delays_cleared)); + memset(cleared_delays_parm1, 0, sizeof(cleared_delays_parm1)); + while (you.delay_queue.size() > 1) { const delay_queue_item delay = you.delay_queue[you.delay_queue.size() - 1]; + + delays_cleared[delay.type]++; + cleared_delays_parm1[delay.type] = delay.parm1; + you.delay_queue.pop_back(); if (is_run_delay(delay.type) && you.running) @@ -334,9 +344,10 @@ void stop_delay( bool stop_stair_travel ) case DELAY_BOTTLE_BLOOD: case DELAY_OFFER_CORPSE: { - bool multiple_corpses = false; - bool butcher_swap_warn = false; - int wpn_delay = -1; + bool multiple_corpses = false; + bool butcher_swap_warn = false; + int butcher_swap_weapon = 0; + for (unsigned int i = 1; i < you.delay_queue.size(); i++) { if (you.delay_queue[i].type == DELAY_BUTCHER @@ -347,14 +358,20 @@ void stop_delay( bool stop_stair_travel ) } else if (you.delay_queue[i].type == DELAY_WEAPON_SWAP) { - wpn_delay = i; - butcher_swap_warn = true; + butcher_swap_weapon = you.delay_queue[i].parm1; + butcher_swap_warn = true; break; } else break; } + if (!butcher_swap_warn && delays_cleared[DELAY_WEAPON_SWAP] > 0) + { + butcher_swap_warn = true; + butcher_swap_weapon = cleared_delays_parm1[DELAY_WEAPON_SWAP]; + } + const std::string butcher_verb = (delay.type == DELAY_BUTCHER ? "butchering" : delay.type == DELAY_BOTTLE_BLOOD ? "bottling blood from" @@ -363,8 +380,6 @@ void stop_delay( bool stop_stair_travel ) // Corpse keeps track of work in plus2 field, see handle_delay() -- bwr if (butcher_swap_warn) { - const int butcher_swap_weapon = you.delay_queue[wpn_delay].parm1; - std::string weapon; if (butcher_swap_weapon == -1) weapon = "unarmed combat"; @@ -376,6 +391,10 @@ void stop_delay( bool stop_stair_travel ) mprf(MSGCH_WARN, "You stop %s the corpse%s; not switching " "back to %s.", butcher_verb.c_str(), (multiple_corpses ? "s" : ""), weapon.c_str()); + + if (Options.swap_when_safe) + you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] + = butcher_swap_weapon; } else mprf("You stop %s the corpse%s.", butcher_verb.c_str(), diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index d3edde0a47..6006ae087d 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -178,6 +178,7 @@ enum attribute_type ATTR_DEMONIC_RUNES, ATTR_ABYSSAL_RUNES, ATTR_RUNES_IN_ZOT, + ATTR_WEAPON_SWAP_INTERRUPTED, NUM_ATTRIBUTES }; diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 91cc735a1e..461c87bb86 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1635,6 +1635,8 @@ public: bool easy_butcher; // autoswap to butchering tool bool always_confirm_butcher; // even if only one corpse bool chunks_autopickup; // Autopickup chunks after butchering + bool swap_when_safe; // If autoswapped butchery was interrupted, + // swap weapon back when safe. bool list_rotten; // list slots for rotting corpses/chunks bool default_target; // start targeting on a real target bool autopickup_no_burden; // don't autopickup if it changes burden diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 1eda3233f1..2410102252 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -671,6 +671,7 @@ void game_options::reset_options() easy_butcher = true; always_confirm_butcher = false; chunks_autopickup = false; + swap_when_safe = false; list_rotten = true; easy_confirm = CONFIRM_SAFE_EASY; easy_quit_item_prompts = true; @@ -1885,6 +1886,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) else BOOL_OPTION(easy_butcher); else BOOL_OPTION(always_confirm_butcher); else BOOL_OPTION(chunks_autopickup); + else BOOL_OPTION(swap_when_safe); else BOOL_OPTION(list_rotten); else if (key == "lua_file" && runscript) { diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index 8299c21c34..575815ff27 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -523,6 +523,8 @@ bool unwield_item(bool showMsgs) mpr("You feel your mana capacity decrease."); } + you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0; + return (true); } // end unwield_item() diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 222bbb9285..5e8865a723 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -758,6 +758,8 @@ void wield_effects(int item_wield_2, bool showMsgs) if (showMsgs) warn_shield_penalties(); + + you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0; } // end wield_weapon() //--------------------------------------------------------------- |