summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monster.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-11 20:40:13 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-11 20:56:37 -0700
commitdaae54a4133a85a6393b9351f17d825cfdcdd126 (patch)
treea2043f59b2c2e9e0a1dda1f0a68ba43c24764efe /crawl-ref/source/monster.cc
parent30d9616ef6d9e0f6e5bccaacf4446854ceb757be (diff)
downloadcrawl-ref-daae54a4133a85a6393b9351f17d825cfdcdd126.tar.gz
crawl-ref-daae54a4133a85a6393b9351f17d825cfdcdd126.zip
Improve sleep code
Refactor put_to_sleep() and hibernate() together. Also improve messenging for resisting repeated sleep (by replacing a generic canned message).
Diffstat (limited to 'crawl-ref/source/monster.cc')
-rw-r--r--crawl-ref/source/monster.cc18
1 files changed, 5 insertions, 13 deletions
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 93eb968e97..5f4a5a81a6 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -5512,25 +5512,17 @@ bool monster::do_shaft()
return reveal;
}
-void monster::hibernate(int)
+void monster::put_to_sleep(actor *attacker, int strength, bool hibernate)
{
- if (!can_hibernate())
- return;
-
- stop_constricting_all();
- behaviour = BEH_SLEEP;
- flags |= MF_JUST_SLEPT;
- add_ench(ENCH_SLEEP_WARY);
-}
-
-void monster::put_to_sleep(actor *attacker, int strength)
-{
- if (!can_sleep())
+ const bool valid_target = hibernate ? can_hibernate() : can_sleep();
+ if (!valid_target)
return;
stop_constricting_all();
behaviour = BEH_SLEEP;
flags |= MF_JUST_SLEPT;
+ if (hibernate)
+ add_ench(ENCH_SLEEP_WARY);
}
void monster::weaken(actor *attacker, int pow)