summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-util.cc
diff options
context:
space:
mode:
authorCharles Otto <ottochar@gmail.com>2009-11-06 00:15:09 -0500
committerCharles Otto <ottochar@gmail.com>2009-11-06 00:15:50 -0500
commit8c0f2ef1e0ca14dfbe4dc5263ce9d1dddd674758 (patch)
tree0ce03d9fbc4370b46372c0cb25ff0e33d21712c7 /crawl-ref/source/mon-util.cc
parent2cd18cf91603ca59471842721b584b8a7521f103 (diff)
downloadcrawl-ref-8c0f2ef1e0ca14dfbe4dc5263ce9d1dddd674758.tar.gz
crawl-ref-8c0f2ef1e0ca14dfbe4dc5263ce9d1dddd674758.zip
Add haste other as a monster spell
Diffstat (limited to 'crawl-ref/source/mon-util.cc')
-rw-r--r--crawl-ref/source/mon-util.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index b60b9924b7..53f1a11e94 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -2180,6 +2180,42 @@ void mons_pacify(monsters *mon)
behaviour_event(mon, ME_EVAL);
}
+static bool _mons_should_fire_beneficial(bolt &beam)
+{
+ // Should monster haste other be able to target the player?
+ // Saying no for now. -cao
+ if (beam.target == you.pos())
+ return false;
+
+ // Assuming all beneficial beams are enchantments if a foe is in
+ // the path the beam will definitely hit them so we shouldn't fire
+ // in that case.
+ if (beam.friend_info.count == 0
+ || beam.foe_info.count != 0)
+ return (false);
+
+ // Should beneficial monster enchantment beams be allowed in a
+ // sanctuary? -cao
+ if (is_sanctuary(you.pos()) || is_sanctuary(beam.source))
+ return (false);
+
+ return (true);
+}
+
+static bool _beneficial_beam_flavour(beam_type flavour)
+{
+ switch(flavour)
+ {
+ case BEAM_HASTE:
+ case BEAM_HEALING:
+ case BEAM_INVISIBILITY:
+ return (true);
+
+ default:
+ return (false);
+ }
+}
+
bool mons_should_fire(struct bolt &beam)
{
#ifdef DEBUG_DIAGNOSTICS
@@ -2191,6 +2227,11 @@ bool mons_should_fire(struct bolt &beam)
beam.foe_ratio, beam.smart_monster ? "yes" : "no");
#endif
+ // Use different evaluation criteria if the beam is a beneficial
+ // enchantment (haste other).
+ if (_beneficial_beam_flavour(beam.flavour))
+ return _mons_should_fire_beneficial(beam);
+
// Friendly monsters shouldn't be targetting you: this will happen
// often because the default behaviour for charmed monsters is to
// have you as a target. While foe_ratio will handle this, we