Is there any way to interrupt sleep?

Post » Wed Jun 20, 2012 2:01 am

So, I'm looking for a way to interrupt sleep think I know of one way (not at a system where I can test)

CreationKit shows the following for sleep:
Event OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime)

So we can RegisterForSleep which will trigger this. But I want to interrupt the player randomly at some hour after game time has passed so I'm thinking
float interupttime = Utility.RandomFloat(0,afDesiredSleepEndTime)RegisterForUpdateGameTime(interupttime)

My hope was that this would trigger since gametime does pass when you're sleeping but then the note on the wiki says:
OnUpdateGameTime may come in much later then you expect if the player is sleeping, waiting, fast traveling, or serving jail time. The event will only be sent once, after the sleep/wait/travel/serve period is over, so you should be prepared to handle hours passing between updates.

But what is funny to me is that the wiki mentions the following about OnSleepStop:
Event OnSleepStop(bool abInterrupted)
Parameters
  • abInterrupted: Whether sleep was interrupted or not.

So how does a player get interrupted in their sleep otherwise?

Any suggestions? Basically this is for one of a few radiant quests that I have where certain conditions trigger certain bounty hunter attacks. I don't want to interrupt the player BEFORE they sleep, nor AFTER they wakeup to trigger. I want it to happen some time WHILE they are sleeping so that the benefits of sleeping in my mod get nullified. Granted, I guess if I just place an actor and have them attack during the OnSleepStart that would trigger an interruption but then time really hasn't passed and so it just becomes a nuance rather than a nusance. :smile:

Thanks!

-MM

Edit: Only a few scripts use OnSleepStop event, and only one of those uses abInterruptedValue. Only one script (outside of base class scripts) uses OnSleepStart and that's the Dark Brotherhod quest where player wakes in shack. It doesn't do anything unique.
User avatar
Naughty not Nice
 
Posts: 3527
Joined: Sat Nov 04, 2006 6:14 am

Post » Wed Jun 20, 2012 2:31 pm

The full time does not pass with the DB script, so look closer there.
User avatar
JUan Martinez
 
Posts: 3552
Joined: Tue Oct 16, 2007 7:12 am

Post » Wed Jun 20, 2012 5:51 am

Thanks Rhoark. I didn't realize the full time didn't pass in that script.... I wonder if doing WAIT(#.#) calls lets the time pass.... and then you could interrupt after a certain amount of time passes by perhaps playing the wakeup idle? I'll check into that and report my findings!

Source from the DB script:

; For the player sleeping, to move him to the shack to be forcegreeted by Astrid.If pSleepyTime == 1		  Game.DisablePlayerControls(ablooking = true, abCamSwitch = true)		    Game.ForceFirstPerson()		  Game.GetPlayer().MoveTo(pPlayerShackMarker)		  Woozy.Apply()		  Game.GetPlayer().PlayIdle(WakeUp)		  Utility.Wait (3)		  pSleepyTime = 3endif

-MM
User avatar
Lillian Cawfield
 
Posts: 3387
Joined: Thu Nov 30, 2006 6:22 pm

Post » Wed Jun 20, 2012 1:50 am

So far no luck actually interupting the player. Which makes me think that the MoveTo is what's doing it. Here's my current script

Event OnSleepStart(float afDesiredSleepTimeTime, float afDesiredSleepEndTime)Trace("OnSleepStart")Trace("Chance to trigger a Sleep Attack Quest: " + ChanceToTriggerQuest)int diceRoll = RandomInt(0,100)Trace("DM rolls a " + diceRoll)if(diceRoll < 100)  ; Mark that the player is going/was asleep.  float sleeptime = utility.RandomFloat(0,afDesiredSleepTimeTime)  Trace("Waiting .... " + sleeptime + " seconds...then play wake up")  Utility.Wait(sleeptime)  ;Trace("Calling SendStoryEvent to trigger a sleep interuption hunter quest")  ;mm_BeluaQuestStart.SendStoryEventAndWait()  Game.DisablePlayerControls(ablooking = true, abCamSwitch = true)	 Game.ForceFirstPerson()  Game.GetPlayer().PlayIdle(Wakeup)  Utility.wait(2)  Game.EnablePlayerControls(ablooking = true, abcamswitch = true)EndIfEndEvent

Right now I'm forcing this block section to execute every time. Here's my papyrus output:

[03/21/2012 - 09:45:45PM] OnSleepStart[03/21/2012 - 09:45:45PM] Chance to trigger a Sleep Attack Quest: 6[03/21/2012 - 09:45:45PM] DM rolls a 66[03/21/2012 - 09:45:45PM] Waiting .... 0.716932 seconds...then play wake up[03/21/2012 - 09:46:00PM] OnSleepStop

When I sleep I sleep the full amount and then the wake up animation plays but it doesn't interrupt the player. I think moving between cell loads might be the trigger. I'll try a simple move and see what happens.

-MM

Edit: ok, there is one bug in that script because I'm waiting a random amount of time based on the game time the player wants to wakeup but from the logs you can see that we picked 0.7 seconds to wait so it's possible if the random number is greater than the time that passes by it wouldn't trigger, but in this case it was much less (Waited 24 hours which is about 23 seconds of IRL time).
User avatar
Chantel Hopkin
 
Posts: 3533
Joined: Sun Dec 03, 2006 9:41 am


Return to V - Skyrim