From 4c0344b9dd2c823ab6926542a58d3e1407bff7da Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 9 Jan 2007 11:47:02 +0000 Subject: Turn off autoprayer and autopickup if attacked by an invisible monster. NOTE: autopickup is turned off only if safe_autopickup is enabled. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@817 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/delay.cc | 32 ++++++++++++++++++++++++++++++++ crawl-ref/source/libutil.h | 2 +- crawl-ref/source/travel.h | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index e40d3526be..1a9f7b48af 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -951,11 +951,43 @@ inline static void monster_warning(activity_interrupt_type ai, } } +static void paranoid_option_disable( activity_interrupt_type ai, + const activity_interrupt_data &at ) +{ + if (ai == AI_HIT_MONSTER || ai == AI_MONSTER_ATTACKS) + { + const monsters* mon = static_cast(at.data); + if (mon && !player_monster_visible(mon)) + { + std::vector deactivatees; + if (Options.autoprayer_on) + { + deactivatees.push_back("autoprayer"); + Options.autoprayer_on = false; + } + + if (Options.autopickup_on && Options.safe_autopickup) + { + deactivatees.push_back("autopickup"); + Options.autopickup_on = false; + } + + if (!deactivatees.empty()) + mprf(MSGCH_WARN, "Deactivating %s.", + comma_separated_line(deactivatees.begin(), + deactivatees.end()).c_str()); + } + } +} + // Returns true if any activity was stopped. bool interrupt_activity( activity_interrupt_type ai, const activity_interrupt_data &at ) { + paranoid_option_disable(ai, at); + const int delay = current_delay_action(); + if (delay == DELAY_NOT_DELAYED) return (false); diff --git a/crawl-ref/source/libutil.h b/crawl-ref/source/libutil.h index 084a7318d9..be30ec5ebd 100644 --- a/crawl-ref/source/libutil.h +++ b/crawl-ref/source/libutil.h @@ -94,7 +94,7 @@ std::string comma_separated_line(Z start, Z end) text += " and "; } - text += i->name; + text += *i; } return (text); } diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index 02291b4735..010d8cd626 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -236,6 +236,7 @@ private: Z thing; named_thing(const std::string &n, Z t) : name(n), thing(t) { } + operator std::string () const { return name; } }; int es_flags; -- cgit v1.2.3-54-g00ecf