summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/misc.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-25 17:33:38 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-25 17:33:38 +0000
commit63e4083df060b3cdd0ce18d04949dd7831cc10d4 (patch)
tree67311940576728ec6be2d310256d1727b9a77d5a /crawl-ref/source/misc.cc
parent0eceb6ff8b8501d07c94e2e5d46aca19121b205e (diff)
downloadcrawl-ref-63e4083df060b3cdd0ce18d04949dd7831cc10d4.tar.gz
crawl-ref-63e4083df060b3cdd0ce18d04949dd7831cc10d4.zip
Consolidate the attack warning prompts for both melee and beams, and use
the prompts properly with Burn/Freeze, Smite, and Airstrike. Also, move the now-single function for this into misc.cc, since I can't think of a better location right now. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5235 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/misc.cc')
-rw-r--r--crawl-ref/source/misc.cc73
1 files changed, 73 insertions, 0 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index f96865f093..1a3e99d9ed 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -49,6 +49,7 @@
#include "dgnevent.h"
#include "directn.h"
#include "dungeon.h"
+#include "fight.h"
#include "files.h"
#include "food.h"
#include "format.h"
@@ -2997,3 +2998,75 @@ std::string your_hand(bool plural)
return result;
}
+
+bool stop_attack_prompt(const monsters *mon, bool beam_attack,
+ bool beam_target, god_conduct_trigger *conduct)
+{
+ bool retval = false;
+ bool prompt = false;
+
+ const bool inSanctuary = (is_sanctuary(you.x_pos, you.y_pos)
+ || is_sanctuary(mon->x, mon->y));
+ const bool wontAttack = mons_wont_attack(mon);
+ const bool isFriendly = mons_friendly(mon);
+ const bool isNeutral = mons_neutral(mon);
+ const bool isUnchivalric = is_unchivalric_attack(&you, mon, mon);
+ const bool isHoly = mons_is_holy(mon);
+
+ if (isFriendly)
+ {
+ // listed in the form: "your rat", "Blork"
+ snprintf(info, INFO_SIZE, "Really %s %s%s?",
+ (beam_attack) ? (beam_target) ? "fire at"
+ : "fire through"
+ : "attack",
+ mon->name(DESC_NOCAP_THE).c_str(),
+ (inSanctuary) ? ", despite your sanctuary"
+ : "");
+ prompt = true;
+ }
+ else if (inSanctuary || wontAttack
+ || (is_good_god(you.religion) && (isNeutral || isHoly))
+ || (you.religion == GOD_SHINING_ONE && isUnchivalric))
+ {
+ // "Really fire through the helpless neutral holy Daeva?"
+ // was: "Really fire through this helpless neutral holy creature?"
+ snprintf(info, INFO_SIZE, "Really %s the %s%s%s%s%s?",
+ (beam_attack) ? (beam_target) ? "fire at"
+ : "fire through"
+ : "attack",
+ (isUnchivalric) ? "helpless "
+ : "",
+ (isFriendly) ? "friendly " :
+ (wontAttack) ? "non-hostile " :
+ (isNeutral) ? "neutral "
+ : "",
+ (isHoly) ? "holy "
+ : "",
+ mon->name(DESC_PLAIN).c_str(),
+ (inSanctuary) ? ", despite your sanctuary"
+ : "");
+ prompt = true;
+ }
+
+ if (you.confused() || (prompt && yesno(info, false, 'n')))
+ {
+ if (conduct)
+ {
+ if (isFriendly)
+ conduct->set(DID_ATTACK_FRIEND, 5, true, mon);
+ else if (isNeutral)
+ conduct->set(DID_ATTACK_NEUTRAL, 5, true, mon);
+
+ if (isUnchivalric)
+ conduct->set(DID_UNCHIVALRIC_ATTACK, 4, true, mon);
+
+ if (isHoly)
+ conduct->set(DID_ATTACK_HOLY, mon->hit_dice, true, mon);
+ }
+ }
+ else
+ retval = true;
+
+ return retval;
+}