diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-08 14:01:16 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-08 14:01:16 +0000 |
commit | c7ab36b8b51c2fa925fd5245d31e5f98cfa466e0 (patch) | |
tree | f121170da25495ab7f6deaedfeac493c4fb201e2 /crawl-ref/source/player.cc | |
parent | c0976eb78b1c1319e427b449073d532d033dee50 (diff) | |
download | crawl-ref-c7ab36b8b51c2fa925fd5245d31e5f98cfa466e0.tar.gz crawl-ref-c7ab36b8b51c2fa925fd5245d31e5f98cfa466e0.zip |
Ghosts can use ensorcelled hibernation. Breaks saves, needs some work on PC sleep and wake-up correctness.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2377 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/player.cc')
-rw-r--r-- | crawl-ref/source/player.cc | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 519e7dca5d..9e74b1628d 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6073,6 +6073,48 @@ void player::moveto(const coord_def &c) dungeon_events.fire_position_event(DET_PLAYER_MOVED, c); } +bool player::asleep() const +{ + return duration[DUR_SLEEP] > 0; +} + +bool player::cannot_move() const +{ + return (asleep() || paralysed()); +} + +void player::put_to_sleep(int) +{ + if (asleep()) // No cumulative sleeps. + return; + + // Not all species can be put to sleep. Check holiness. + const mon_holy_type holy = holiness(); + if (holy == MH_UNDEAD || holy == MH_NONLIVING) + return; + + mpr("You fall asleep."); + you.flash_colour = DARKGREY; + viewwindow(true, false); + + // Do this *after* redrawing the view, or viewwindow() will no-op. + duration[DUR_SLEEP] = 3 + random2avg(5, 2); +} + +void player::awake() +{ + duration[DUR_SLEEP] = 0; + mpr("You wake up."); + you.flash_colour = BLACK; + viewwindow(true, false); +} + +void player::check_awaken(int disturbance) +{ + if (asleep() && random2(50) <= disturbance) + awake(); +} + //////////////////////////////////////////////////////////////////////////// PlaceInfo::PlaceInfo() @@ -6223,7 +6265,6 @@ PlaceInfo PlaceInfo::operator - (const PlaceInfo &other) const return copy; } - PlaceInfo& player::get_place_info() const { return get_place_info(where_are_you, level_type); @@ -6327,4 +6368,3 @@ bool player::do_shaft() return (true); } - |