summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-util.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-29 05:16:39 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-29 05:16:39 +0000
commit6e8c4b9c5c42d35f71c444b524a9bb366f70e9cd (patch)
treeb888e9f208d93a196908516417fa99a21a1f0573 /crawl-ref/source/mon-util.cc
parent020b21eee05af9a8e23d9f1f4053a3f1c06519aa (diff)
downloadcrawl-ref-6e8c4b9c5c42d35f71c444b524a9bb366f70e9cd.tar.gz
crawl-ref-6e8c4b9c5c42d35f71c444b524a9bb366f70e9cd.zip
Bug 2005002: Allow friendly and neutral-good monsters to cast spells while in
sanctuary, and allow hostile and neutral monsters to cast spells once outside of sanctuary as long as it won't harm anything inside of sanctuary. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6205 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mon-util.cc')
-rw-r--r--crawl-ref/source/mon-util.cc36
1 files changed, 30 insertions, 6 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index a16cc59a97..6c794f77eb 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -2333,34 +2333,46 @@ bool ms_useful_fleeing_out_of_sight( const monsters *mon, spell_type monspell )
bool ms_low_hitpoint_cast( const monsters *mon, spell_type monspell )
{
- bool ret = false;
- bool targ_adj = false;
+ bool ret = false;
+ bool targ_adj = false;
+ bool targ_sanct = false;
if (mon->foe == MHITYOU || mon->foe == MHITNOT)
{
if (adjacent(you.x_pos, you.y_pos, mon->x, mon->y))
targ_adj = true;
+ if (is_sanctuary(you.x_pos, you.y_pos))
+ targ_sanct = true;
}
- else if (adjacent( menv[mon->foe].x, menv[mon->foe].y, mon->x, mon->y ))
+ else
{
- targ_adj = true;
+ if (adjacent( menv[mon->foe].x, menv[mon->foe].y, mon->x, mon->y ))
+ targ_adj = true;
+ if (is_sanctuary( menv[mon->foe].x, menv[mon->foe].y ))
+ targ_sanct = true;
}
switch (monspell)
{
+ case SPELL_TELEPORT_OTHER:
+ ret = !targ_sanct;
+ break;
+
case SPELL_TELEPORT_SELF:
// Don't cast again if already about to teleport.
if (mon->has_ench(ENCH_TP))
return (false);
// intentional fall-through
- case SPELL_TELEPORT_OTHER:
case SPELL_LESSER_HEALING:
case SPELL_GREATER_HEALING:
ret = true;
break;
- case SPELL_BLINK:
case SPELL_BLINK_OTHER:
+ if (targ_sanct)
+ return (false);
+ // intentional fall-through
+ case SPELL_BLINK:
if (targ_adj)
ret = true;
break;
@@ -2412,6 +2424,18 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
return (true);
}
+ if (!mons_friendly(mon) && !mons_good_neutral(mon))
+ {
+ if (spell_harms_area(monspell) && env.sanctuary_time > 0)
+ return (true);
+
+ if (spell_harms_target(monspell)
+ && is_sanctuary(mon->target_x, mon->target_y))
+ {
+ return (true);
+ }
+ }
+
// Eventually, we'll probably want to be able to have monsters
// learn which of their elemental bolts were resisted and have those
// handled here as well. -- bwr