diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-05-30 04:52:33 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-05-30 04:52:33 +0000 |
commit | 38ebcee4627305ea124f2802fc9498e1acb97764 (patch) | |
tree | 160c889b466700e411b10c0d152984b1bb7706d2 /crawl-ref/source/delay.cc | |
parent | 96a64a6214f7c68b0aa6b94836e77cdf6984d728 (diff) | |
download | crawl-ref-38ebcee4627305ea124f2802fc9498e1acb97764.tar.gz crawl-ref-38ebcee4627305ea124f2802fc9498e1acb97764.zip |
Added two new options, rest_wait_both and chunks_autopickup, both defaulting
to false. If rest_wait_both is true then resting will only stop when both
HP and MP are both fully restored, not when only one or the other is restored.
If chunks_autopickup is true then flesh chunks generated from butchering
will automatically be picked up (respecting the other autopickup settings).
My implementation of rest_wait_both has a few side effects. I got rid
of check_hp() and check_mp() from the runrest class, since player AI
interruption code seems to be able to take care of that. I also added
a rather kuldgey block_interruptions() so that the activity interrupts
code could use mpr() without going into infinite recursion because of
AI_MESSAGE interrutps.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5337 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/delay.cc')
-rw-r--r-- | crawl-ref/source/delay.cc | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 75b3fe6be7..29be88c450 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -48,6 +48,8 @@ extern std::vector<SelItem> items_for_multidrop; +static int _interrupts_blocked = 0; + static void xom_check_corpse_waste(); static void armour_wear_effects(const int item_inv_slot); static void handle_run_delays(const delay_queue_item &delay); @@ -284,6 +286,8 @@ void start_delay( delay_type type, int turns, int parm1, int parm2 ) { ASSERT(!crawl_state.is_repeating_cmd() || type == DELAY_MACRO); + _interrupts_blocked = 0; // Just to be safe + delay_queue_item delay; delay.type = type; @@ -307,6 +311,8 @@ void start_delay( delay_type type, int turns, int parm1, int parm2 ) void stop_delay( bool stop_stair_travel ) /*********************/ { + _interrupts_blocked = 0; // Just to be safe + if (you.delay_queue.empty()) return; @@ -1110,6 +1116,14 @@ static void finish_delay(const delay_queue_item &delay) mpr("You enjoyed that."); you.berserk_penalty = 0; } + + // Don't atuopickup chunks if there's a weapon-swap delay + // waiting to happen. + if (Options.chunks_autopickup + && you.delay_queue.size() == 1) + { + autopickup(); + } } } else @@ -1535,12 +1549,28 @@ static bool should_stop_activity(const delay_queue_item &item, delay_type curr = current_delay_action(); - if (curr != DELAY_REST && (ai == AI_FULL_HP || ai == AI_FULL_MP)) - return false; - else if (ai == AI_SEE_MONSTER && (curr == DELAY_ASCENDING_STAIRS || - curr == DELAY_DESCENDING_STAIRS)) + if (ai == AI_SEE_MONSTER && (curr == DELAY_ASCENDING_STAIRS || + curr == DELAY_DESCENDING_STAIRS)) return false; + if (ai == AI_FULL_HP || ai == AI_FULL_MP) + { + // No recursive interruptions from messages (AI_MESSAGE) + block_interruptions(true); + if (ai == AI_FULL_HP) + mpr("HP restored."); + else + mpr("Magic restored."); + block_interruptions(false); + + if (Options.rest_wait_both && curr == DELAY_REST + && (you.magic_points < you.max_magic_points + || you.hp < you.hp_max)) + { + return false; + } + } + return (ai == AI_FORCE_INTERRUPT || Options.activity_interrupts[item.type][ai]); } @@ -1658,6 +1688,9 @@ static void paranoid_option_disable( activity_interrupt_type ai, bool interrupt_activity( activity_interrupt_type ai, const activity_interrupt_data &at ) { + if (_interrupts_blocked > 0) + return false; + paranoid_option_disable(ai, at); if (crawl_state.is_repeating_cmd()) @@ -1795,3 +1828,11 @@ const char *delay_name(int delay) return delay_names[delay]; } + +void block_interruptions(bool block) +{ + if (block) + _interrupts_blocked++; + else + _interrupts_blocked--; +} |