From f9b61b5115bb93a1381cfc3032820489875624c5 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Fri, 6 Nov 2009 15:10:29 -0600 Subject: Consolidate player/monster sleep checks. --- crawl-ref/source/spells4.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'crawl-ref/source/spells4.cc') 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); } -- cgit v1.2.3-54-g00ecf