diff options
author | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-11-06 15:10:29 -0600 |
---|---|---|
committer | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-11-06 15:12:26 -0600 |
commit | f9b61b5115bb93a1381cfc3032820489875624c5 (patch) | |
tree | 637b6b52c190b1feb0e17193784056324213cf08 /crawl-ref/source/spells4.cc | |
parent | b192fdbbbeb85e80aae71e169417511b52e5ab19 (diff) | |
download | crawl-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.cc | 14 |
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); } |