From 8bc8c04fbe230fb0f962f43da1acb3c51c4f88f0 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Mon, 23 Jun 2008 21:30:08 +0000 Subject: Fix monster emergency spells not checking for ENCH_TP, thus allowing monsters to cancel their teleportation without meaning to. (BR 2000428) Fix the quiver not being cleared when wielding the only quiverable (and thus previously quivered) item. (Un)wielding such an item now switches nicely between "Nothing wielded" and "Nothing quivered", as it should be. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6089 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mon-util.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'crawl-ref/source/mon-util.cc') diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 3c8140893a..91e073f839 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1546,7 +1546,7 @@ void define_monster(monsters &mons) case MONS_DEEP_ELF_KNIGHT: case MONS_DEEP_ELF_SOLDIER: case MONS_ORC_WIZARD: - spells = static_cast(MST_ORC_WIZARD_I+random2(3)); + spells = static_cast(MST_ORC_WIZARD_I + random2(3)); break; case MONS_LICH: @@ -2340,6 +2340,10 @@ bool ms_low_hitpoint_cast( const monsters *mon, spell_type monspell ) switch (monspell) { 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: @@ -2371,11 +2375,15 @@ bool ms_quick_get_away( const monsters *mon /*unused*/, spell_type monspell ) { switch (monspell) { - case SPELL_TELEPORT_SELF: - case SPELL_BLINK: - return true; - default: - return false; + 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_BLINK: + return (true); + default: + return (false); } } @@ -2451,7 +2459,7 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell ) case SPELL_TELEPORT_SELF: // Monsters aren't smart enough to know when to cancel teleport. - if (mon->has_ench( ENCH_TP )) + if (mon->has_ench(ENCH_TP)) ret = true; break; -- cgit v1.2.3-54-g00ecf