summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.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/monstuff.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/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc27
1 files changed, 13 insertions, 14 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index b3f1aac6f5..554395e427 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -5045,6 +5045,15 @@ static bool _handle_spell(monsters *monster, bolt &beem)
bool finalAnswer = false; // as in: "Is that your...?" {dlb}
const spell_type draco_breath = _get_draconian_breath_spell(monster);
+ if (is_sanctuary(monster->x, monster->y))
+ {
+ if (!mons_friendly(monster)
+ && !mons_good_neutral(monster))
+ {
+ return (false);
+ }
+ }
+
// Yes, there is a logic to this ordering {dlb}:
if (mons_is_sleeping(monster)
|| monster->has_ench(ENCH_SUBMERGED)
@@ -5206,6 +5215,7 @@ static bool _handle_spell(monsters *monster, bolt &beem)
{
bool spellOK = false;
+
// Setup spell - monsters that are fleeing or leaving
// the level will always try to choose their emergency
// spell.
@@ -5214,10 +5224,6 @@ static bool _handle_spell(monsters *monster, bolt &beem)
spell_cast = (one_chance_in(5) ? SPELL_NO_SPELL
: hspell_pass[5]);
}
- else if (_is_player_or_mon_sanct(monster))
- {
- return (false);
- }
else
{
// Randomly picking one of the non-emergency spells:
@@ -5243,9 +5249,7 @@ static bool _handle_spell(monsters *monster, bolt &beem)
// All direct-effect/summoning/self-enchantments/etc.
spellOK = true;
- if (_is_player_or_mon_sanct(monster))
- spellOK = false;
- else if (ms_direct_nasty(spell_cast)
+ if (ms_direct_nasty(spell_cast)
&& mons_aligned(monster_index(monster),
monster->foe))
{
@@ -5288,13 +5292,8 @@ static bool _handle_spell(monsters *monster, bolt &beem)
// If not okay, then maybe we'll cast a defensive spell.
if (!spellOK)
{
- if (_is_player_or_mon_sanct(monster))
- spell_cast = SPELL_NO_SPELL;
- else
- {
- spell_cast = (coinflip() ? hspell_pass[2]
- : SPELL_NO_SPELL);
- }
+ spell_cast = (coinflip() ? hspell_pass[2]
+ : SPELL_NO_SPELL);
}
if (spell_cast != SPELL_NO_SPELL)