Auto Sleep

Post » Fri May 27, 2011 11:21 am

Hi. Is there a script command (or some other sequence of events) that can be used to make the player sleep?

Example: Player enters an Inn and pays for a bed (not a room, just a bed) for X period of time. The moment he pays for the bed, he automatically goes to the room containing the bed and sleeps for X period of time. When sleep time is done, the player simply wakes up standing next to the bed as usual.

It doesn't matter too much if the player simply pays and the sleep screen comes up - there really is no need for the animation showing the walk to the bed etc, but it does matter that the player wakes up standing next to the bed.

Possible?

Cheers

MVK
User avatar
Nadia Nad
 
Posts: 3391
Joined: Thu Aug 31, 2006 3:17 pm

Post » Fri May 27, 2011 12:47 pm

MerchantsInnRentDoor.Unlock 1;;;;;(Only need this if you DON'T pay for the room first)MerchantsInnRentBed.SetOwnership;;;;;(Only need this if you DON'T pay for the room first);;;;;;;;; player.removeitem gold001 20;;;;;;;;;; (You could use this if you wanted to bypass the renting of the bed, so instead the player loses the amount of gold the room costs instead and the two lines of code above set the ownership of the bed and unlock the door)setpcsleephours 72;;;;;(3 days sleep)player.moveto MerchantsInnRentBed;;;;;(This must be the last line of code, but the sleep will not happen until the player appears at the bed)


Only problem with this code is that the player ends up on top of the bed instead of beside it. Probably could use Player.MoveTo MerchantsInnRentBed 0,20,20 or something that would set distance from the bed the player appears, or in theory it should.

Another problem is that I used this particular code as a quest script when the player clicks on an item. I'm not sure how you would make it work after the player pays for the bed, maybe a quest script related to the merchants "Bed" dialogue?

Another thing to consider might be when you use Player.MoveTo MerchantsInnRentBed 0,20,20 you may need to know which way the player needs to move to be on the side of the bed, incase the bed is next to a wall and the player tries to transport into the wall. (Probably need more than 0,20,20 too, like 0,200,200)

Ah another issue, lol. When I used SetPCSleepHours 72 to sleep for 3 days, the actual sleep screen doesn't appear, the player just stands there and the world moves on 3 days in about 3 seconds. Sometimes you can get wierd glitches with this command, like NPC's getting stuck somewhere for a few hours or when the cell resets. I once had a farmer guy raking the floor of the Merchants Inn once, but he soon moved on.
User avatar
Kelly Tomlinson
 
Posts: 3503
Joined: Sat Jul 08, 2006 11:57 pm

Post » Fri May 27, 2011 6:13 am

There are a few things you want to do, I think.
1) Force the Player to sleep
Try using the function http://cs.elderscrolls.com/constwiki/index.php/SetPCSleepHours. That way you can set the player to sleep for however long, and you could even use http://cs.elderscrolls.com/constwiki/index.php/WakeUpPC to cancel it if needs be. That works just as if the Player went to the Wait/Sleep menu, and set it to that certain length of time, just skipping out the time selection screen.

2) Forcing the Player to walk up towards a Bed
Well, this is really quite complicated. It's not like an NPC, where you can set packages for them to behave by - The player has entire freedom of choice in most cases. The only way you could do this, is by either persuading the player to do this (by hinting to go to the bed, such as getting an NPC to tell them to go to the bed, where it is, etc...) and then calling the sleep function when they're there; or by creating a hideously complicated animation that shows the player walking up the stairs, and to the bed. And that's so hard that you might as well forget it! It'd take hours work.
I guess you could create a clone of the Player, then give them a package to walk up the stairs to the bed. That would have the illusion of the player doing it (and you could make the player invisible, and make it so that they can't move - like in the start of Oblivion when the Blades are opening the block and the player can't do anything about it). The player wouldn't be able to move though, so you wouldn't be able to follow this clone of the player. All you'd be able to see is the player walking up the stairs.

3) Force the Player to stand by the Bed on waking up
Well this isn't too hard at all. Just call a Player.http://cs.elderscrolls.com/constwiki/index.php/MoveTo [DesignatedMarker] when the player wakes up. Put the marker next to the bed where you want the player to find themselves.
It might be tricky to call it after the player has been sleeping - so I'd do it in the order of 3) then 1), so it looks like:

...	Player.MoveTo [The Marker's Reference ID]	SetPCHoursSleep [Number of hours to sleep]...

That way, they'll wake up where you want them to.

Good luck, and I hope that helps!
User avatar
Kelly John
 
Posts: 3413
Joined: Tue Jun 13, 2006 6:40 am

Post » Fri May 27, 2011 5:45 am

Thanks guys, quick responses there!

Ill play with those bits of code but Iv a feeling that you hit the nail right on the head - it does everything I need. I'm not worried about the animations, just paying, sleeping and waking up next to the bed is fine. I'm not sure if I will need to put this in a quest of some sort, but Ill try first without doing so (Lets face it, I'm feeling my way about here!).

As an afterthought, is it possible to have a custom screen shown while the player is sleeping? You know like the screens that appear when you open a door, or the one that appears as the background when you do actually sleep or wait. It would be nice to show a message while the player is waiting to wake up.

Many thanks

MVK
User avatar
OJY
 
Posts: 3462
Joined: Wed May 30, 2007 3:11 pm

Post » Fri May 27, 2011 5:06 pm

The screen that shows when you're sleeping is just black, no? And the screens shown that give random Trivia show when you're being put into a new place, from where you used to be (So if you load into a new worldspace or interior through a door, or after teleporting).
As far as I can recall, you can't do anything much when the player is sleeping, because the game is frozen in place. If you were to load this loadscreen, and then initiate the sleep, you'd see a flash of the loadscreen and then it'd go black and show the normal sleep screen.

Having said that, I seem to recall it would be possible to use a http://cs.elderscrolls.com/constwiki/index.php/Message function to show a message to the player (That goes in the place where it says 'Savegame Created' or whatever it actually says. Should be at the top left hand corner). That could be called just before the sleep. Then, I imagine, the message would remain as normal whilst the player is sleeping. This should be put before the MoveTo bit of the code I put (So before 3)).
Failing that, you could just call a http://cs.elderscrolls.com/constwiki/index.php/MessageBox function when they wake up, although that may be a little harder to time. I'll give you an example piece of code with both of them in to show how they might work:

...	Message "[Message goes here!]"	Player.MoveTo [The Marker's Reference ID]	SetPCHoursSleep [Number of hours to sleep]	MessageBox "[Message goes here, too!]"...

I'd suggest only using one of those functions though, as people don't like being told what to do too much!
Good luck!
User avatar
Patrick Gordon
 
Posts: 3366
Joined: Thu May 31, 2007 5:38 am

Post » Fri May 27, 2011 4:20 am

Thats excellent Kengon, thanks.
User avatar
Gen Daley
 
Posts: 3315
Joined: Sat Jul 08, 2006 3:36 pm


Return to IV - Oblivion