Somebody asked for help with a script on my website, but in trying to answer it, I realized I wasn't entirely sure how to do it. Their question was this:
So I was wondering how this could be done. I looked at the Dark brotherhood quests for some reference, but it wasn't quite what I was looking for. I cobbled together this script in a few minutes, but it doesn't work entirely. It compiles, but it doesn't work.
Scriptname SleepTestScriptDream extends ReferenceAlias {Attach this script to a reference alias in your quest pointing to the player}ObjectReference Property XMarkerDreamStart AutoObjectReference Property XMarkerPlayerLoc AutoEvent OnInit() RegisterForSleep() EndEventEvent OnSleepStart(Float afSleepStartTime, Float afDesiredSleepEndTime) If GetOwningQuest().GetStage() == 10 XMarkerPlayerLoc.MoveTo(Game.GetPlayer(), 10) Game.GetPlayer().MoveTo(XMarkerDreamStart) Game.DisablePlayerControls(true, true, true, false, true, true, true, false) Debug.Notification("Scene would be here...") Utility.Wait(5.0) Game.GetPlayer().MoveTo(XMarkerPlayerLoc) UnregisterForSleep() EnablePlayerControls() GetOwningQuest().SetStage(20) Debug.Notification("Dream ended.") EndIf EndEvent
All properties are filled correctly.
It's attached to a playeralias on the quest I had for the dream. The quest was activated (set to stage 10) on reading a book, and the idea was that once you went to sleep, if the proper conditions were met, then a marker would move to where the player was (the bed), somewhat near them. Then, the player would move to another marker somewhere else, their controls would be disabled, and a scene would play at that location. Then, the player would move back to the marker that was near where they were. While the XMarkerPlayerLoc would have been buggy, and possibly end up with players in the walls, I'm too tired to think of a better way. If you've got a better idea for sending the player back to the bed they went to sleep in, that would be helpful.
What ended up happening is I went to sleep, woke up with my controls disabled, the notification played, I stood there for five seconds next to the bed, and then was released from the "cutscene".
How would you go about doing this?