Northborn Posted April 6, 2013 Share Posted April 6, 2013 Has anyone ever found a way to interrupt the player's sleep? I've been trying to code a scene where after the player goes to sleep, it'll be interrupted at a specific time and the scene happens from then on. (Think enemy ambush in the middle of the night.) I've been digging through all the script functions and I have not found anything. Using RegisterForSleep / OnSleepStart seemed like the right direction, but there doesn't seem to be anything that interrupts the sleep cycle once initiated. I've even tried toggling player AI to have him play a package in hopes it would interrupt the cycle, but it just waited until the player woke up. The only way I can think of right now is using SKSE and doing a Key tap to cancel, but I would prefer not to use SKSE, not because I dislike it, I use it, but because I want to keep the required files for my mod to a minimum. The reason I wanted to do this was for camping/frostfall compatibility. I could simply code the bed at the lodge to play the scene and set the time on activate, but it would have been cool if the player had to option to set up their own camp near the lodge. Hopefully, someone might have something I'm missing! Link to comment Share on other sites More sharing options...
McclaudEagle Posted April 6, 2013 Share Posted April 6, 2013 I've had to put this as a spoiler as it contains some information about a certain mission in the game, proceed with caution. Try looking at the script that plays when the Dark Brotherhood first contacts you after killing Grelod the Kind. The player has to go to sleep, at which point the player is transported somewhere else and a scene plays. Link to comment Share on other sites More sharing options...
FiftyTifty Posted April 6, 2013 Share Posted April 6, 2013 "but I would prefer not to use SKSE"However, you need SKSE to do this. It's called a Script Extender for a reason ;) I wouldn't worry about using SKSE. Anyone who has mods will surely have it. If they don't? Put a link to download it on your mod's description. Link to comment Share on other sites More sharing options...
Northborn Posted April 6, 2013 Author Share Posted April 6, 2013 McclaudEagle, on 06 Apr 2013 - 18:32, said:I've had to put this as a spoiler as it contains some information about a certain mission in the game, proceed with caution. Try looking at the script that plays when the Dark Brotherhood first contacts you after killing Grelod the Kind. The player has to go to sleep, at which point the player is transported somewhere else and a scene plays. Jack pot! Moving the player works wonders! Huzzah! Link to comment Share on other sites More sharing options...
Northborn Posted April 7, 2013 Author Share Posted April 7, 2013 PlaceAtMe + GetHeadingAngle/SetAngle on an XMarkerHeading is a nice way to maintain position dynamically.Something like this: (Code is still fairly primitive. Its a fresh script and I'm also fairly new to papyrus scripting). Thought I'd post this here in case someone ever looked this question up in the future. (This script also handles a cutscene.) Scriptname NBBlackmaneQ01Stg20PlayerOnSleep extends ReferenceAlias Actor Property PlayerRef Auto GlobalVariable Property GameHour Auto Idle Property WakeUp Auto ImageSpaceModifier Property BlackScreen Auto ImageSpaceModifier Property Woozy Auto Location Property EdgthosLodge Auto ObjectReference Property pWakeUpSpot Auto ObjectReference Property Xmarker Auto Quest Property NBBlackmaneQ01 Auto ReferenceAlias Property Player Auto Form XmarkerBase Event OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime) XmarkerBase = Xmarker.GetBaseObject() ObjectReference XmarkerPos = PlayerRef.PlaceAtMe(XmarkerBase) AS ObjectReference float zOffset = XmarkerPos.GetHeadingAngle(PlayerRef) + 180 XmarkerPos.SetAngle(XmarkerPos.GetAngleX(), XmarkerPos.GetAngleY(), XmarkerPos.GetAngleZ() + zOffset) if PlayerRef.IsInLocation(EdgthosLodge) if (GameHour.GetValue() >= 8 && GameHour.GetValue() <= 13.9) Debug.Notification("It is too early to lure Blackmane. Better wait until late afternoon.") elseif (GameHour.GetValue() >= 2 && GameHour.GetValue() <= 7.9) Debug.Notification("It is too late to lure Blackmane now, morning comes. Better wait until late afternoon.") else ;Setup Cutscene + advance time Game.DisablePlayerControls(true, true, true, true, true, true, true) Game.ForceFirstPerson() BlackScreen.Apply() ;MoveTo allows to interrupt sleep PlayerRef.MoveTo(XmarkerPos) ;Set time and wait GameHour.SetValue(2.0) Utility.Wait(5.0) ;get the player moving to a specific xmarkerheading, done to move out of the tent (for Frostfall/camping mod users) Game.SetPlayerAIDriven() PlayerRef.EvaluatePackage() Game.GetPlayer().PlayIdle(WakeUp) Utility.Wait(3.0) BlackScreen.PopTo(Woozy) Game.EnablePlayerControls() Game.SetPlayerAIDriven(false) ;Setup next quest stage (and objectives) NBBlackmaneQ01.SetStage(30) NBBlackmaneQ01.SetObjectiveDisplayed(30) NBBlackmaneQ01.SetObjectiveCompleted(20) ;Stop watching for sleep mode Player.UnregisterForSleep() endIf endIf XmarkerPos.Disable() EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts