summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells4.cc
diff options
context:
space:
mode:
authorDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-11-06 15:10:29 -0600
committerDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-11-06 15:12:26 -0600
commitf9b61b5115bb93a1381cfc3032820489875624c5 (patch)
tree637b6b52c190b1feb0e17193784056324213cf08 /crawl-ref/source/spells4.cc
parentb192fdbbbeb85e80aae71e169417511b52e5ab19 (diff)
downloadcrawl-ref-f9b61b5115bb93a1381cfc3032820489875624c5.tar.gz
crawl-ref-f9b61b5115bb93a1381cfc3032820489875624c5.zip
Consolidate player/monster sleep checks.
Diffstat (limited to 'crawl-ref/source/spells4.cc')
-rw-r--r--crawl-ref/source/spells4.cc14
1 files changed, 5 insertions, 9 deletions
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index a70bb84861..3a513c8bcc 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -393,28 +393,24 @@ void cast_detect_secret_doors(int pow)
static int _sleep_monsters(coord_def where, int pow, int, actor *)
{
monsters *monster = monster_at(where);
- if (monster == NULL)
+ if (!monster)
return (0);
- if (monster->holiness() != MH_NATURAL)
+ if (!monster->can_sleep(true))
return (0);
+
if (monster->check_res_magic(pow))
return (0);
- // Works on friendlies too, so no check for that.
-
- //jmf: Now that sleep == hibernation:
const int res = monster->res_cold();
if (res > 0 && one_chance_in(std::max(4 - res, 1)))
return (0);
+
if (monster->has_ench(ENCH_SLEEP_WARY) && !one_chance_in(3))
return (0);
monster->put_to_sleep();
-
- if (mons_class_flag( monster->type, M_COLD_BLOOD ) && coinflip())
- monster->add_ench(ENCH_SLOW);
-
+ monster->expose_to_element(BEAM_COLD, 2);
return (1);
}