See You Sleep In Skyrim?

Post » Thu Jun 21, 2012 5:06 pm

Ok so I've scoured the net and cannot find a See You Sleep style mod for Skyrim. I've messed around with it for a couple hours and cannot really get anywhere.

Does anyone know where the "rest how long" message is at, and how I would go about delaying its pop up until the player is in the bed idle position?

Basically I'd like beds to work like alchemy or crafting workbenches. Load the player into the station (in this case the bed) and then bring up the menu that asks how long they want to rest.

I tried putting a script on a bed but it fires on top of the damn sleep dialogue. I have a few ideas to hack around all this, but I'd rather not go that way if I don't have to.
User avatar
Katharine Newton
 
Posts: 3318
Joined: Tue Jun 13, 2006 12:33 pm

Post » Thu Jun 21, 2012 1:13 pm

You need to avoid the bed normal activation kicking in. For that, you need to use the blockactivaion function.

In the case of the script on a bed:
Event OnInit()BlockActivation()EndEvent

Then add an onactivate event with what you want the bed to do, and once you need the bed to be activated:

self.activate(game.getplayer(), true) ; the 'self' word is unneded here but it's handy so you can get easier the use of the function.;let's say that The player didn't activate the object the object makes the player activate it.

If you wan't to allow the bed to be activated as always:

Blockactivation(false)

Anyway, this approach is a great error, as you will put a script directly on any bed you want to use, which I assume are all. So, the script will be there even if the mod is uninstalled.

To avoid this, add a permanent cloack spell with the required script, to the player, detecting beds and adding the spell to them. Use the oneffectstart event instead of the oninit one, and add a check to ensure that it didn't work on the player (just add an if block surrounding commands). When the player is near enough, the spell will be added to the bed and when the mod is removed the spell will disappear from the player and all the beds.

This link will help you with the cloack spell part: http://www.creationkit.com/Dynamically_Attaching_Scripts


EDIT: I forgot to add that you will need to check on the onactivate block that the one activating it is the player. Just:
Event OnActivate(ObjectReference akActionRef)If aktionRef == game.getplayer();Use here the animationutility.wait(3) ; instead of 3 just put the time you judge appropriateself.activate(game.getplayer(), true) EndifEndEvent
User avatar
Cathrine Jack
 
Posts: 3329
Joined: Sat Dec 02, 2006 1:29 am

Post » Thu Jun 21, 2012 3:11 pm

@madmole

http://forums.nexusmods.com/index.php?/topic/672112-see-you-sleep-in-skyrim/page__view__findpost__p__5353589.

So I can manage to get the player to play the sleeping animation when activating a bed. However, I cannot call up the sleep menu while the player is playing the sleeping animation.

@amgepo

Unlike with actors, objects cannot run magic effect scripts. The cloak spell will not do anything to the beds.
User avatar
chinadoll
 
Posts: 3401
Joined: Tue Aug 22, 2006 5:09 am

Post » Thu Jun 21, 2012 6:34 am

I tried the blockActivation inside an OnInit block but it didn't work. The wiki shows use of BlockActivation inside a function. Should I maybe try adding BlockActivation to a function, then call that function OnInit?

I added it to the onActivate block, then it works after first activating a bed.
User avatar
Chenae Butler
 
Posts: 3485
Joined: Sat Feb 17, 2007 3:54 pm

Post » Thu Jun 21, 2012 4:49 pm

@madmole http://forums.nexusmods.com/index.php?/topic/672112-see-you-sleep-in-skyrim/page__view__findpost__p__5353589. So I can manage to get the player to play the sleeping animation when activating a bed. However, I cannot call up the sleep menu while the player is playing the sleeping animation. @amgepo Unlike with actors, objects cannot run magic effect scripts. The cloak spell will not do anything to the beds.
Oh yes, I saw that thread already, I guess you have a different user name over there. What did you do to get the player to climb into the bed and use it? I know how to play anims on players, but to have him actually use the bed, I'm not sure how to do that.
User avatar
Flesh Tunnel
 
Posts: 3409
Joined: Mon Sep 18, 2006 7:43 pm

Post » Thu Jun 21, 2012 1:27 pm

I created a quest with two (optional) reference aliases: PlayerRef and BedRef. PlayerRef has an AI package to sleep in BedRef.

When the quest is first loaded, I add a perk to the player. This perk has an "activate" entry point. It will work only on furniture objects and check whether or not it's a bed in my script (I could not get http://www.creationkit.com/IsFurnitureAnimType to work properly).

If the furniture is a bed, then I check if the bed is owned by the player, the PlayerBedOwnership faction, or nobody (for some reason there is no condition function for GetOwner). Finally, I check if the bed is occupied already. If the furniture passes all checks, then it's a bed that the player can sleep on.

I set the player to AI controlled, and assign him/her to the PlayerRef alias. The player will get into bed. If the furniture fails any of the checks, then I have the player call a default activation on the furniture instead.
User avatar
kennedy
 
Posts: 3299
Joined: Mon Oct 16, 2006 1:53 am

Post » Thu Jun 21, 2012 8:17 pm

Hmmm, sounds similar to what I was going to try, except rather than a package, I was going to use the behavior tree though to naturally play the anim hopefully, and then after a period of utility(wait) go ahead and allow the activation in the script. My guess is at this point, because the player is locked up doing an animation, that it won't allow you to activate anything because controls are disabled.
User avatar
Alex Vincent
 
Posts: 3514
Joined: Thu Jun 28, 2007 9:31 pm

Post » Thu Jun 21, 2012 3:28 pm

I too have missed this from Oblivion. I was pleased to find out it is included in the popular http://skyrim.nexusmods.com/downloads/file.php?id=13931 mod. You have to use your relax power on a bed, rather than just activate it normally, so it's not perfect. Perhaps you could do it in a similar way.
User avatar
Daniel Brown
 
Posts: 3463
Joined: Fri May 04, 2007 11:21 am

Post » Thu Jun 21, 2012 4:30 pm

I too have missed this from Oblivion. I was pleased to find out it is included in the popular http://skyrim.nexusmods.com/downloads/file.php?id=13931 mod. You have to use your relax power on a bed, rather than just activate it normally, so it's not perfect. Perhaps you could do it in a similar way.
Nice. It's not quite like See You Sleep was, but is quite genius. Made me feel like a total noob to read some of the code in that, lol. Definitely will help in this pursuit though :)
User avatar
Shirley BEltran
 
Posts: 3450
Joined: Wed Jul 26, 2006 4:14 pm

Post » Thu Jun 21, 2012 11:50 am

I set the player to AI controlled

Do you make this with :

PlayerRef.SetAnimationVariableBool("bMotionDriven", true)

or is it something else ?
User avatar
CYCO JO-NATE
 
Posts: 3431
Joined: Fri Sep 21, 2007 12:41 pm

Post » Thu Jun 21, 2012 11:52 am

Do you make this with :

PlayerRef.SetAnimationVariableBool("bMotionDriven", true)

or is it something else ?

http://www.creationkit.com/SetPlayerAIDriven_-_Game
User avatar
glot
 
Posts: 3297
Joined: Mon Jul 17, 2006 1:41 pm

Post » Thu Jun 21, 2012 6:09 pm

Is there a way to get the position reference of a furniture marker? The game must surely recognize the nearest available marker on a piece of furniture at least internally. Right now I'm doing a moveto on the player to the furniture, then switching to 3rd person, and playanimationevent (lay down) or whatever, and it works fine for like a cot. However if I could identify the actual location of available markers on furniture, I could then call the correct anim for enter bed left, right, cots, etc and get this working perfectly.

So is there a way to use MoveTo (piece of furnitureREF, nearestmarker?) or something like that?

Edit: I think I found it. http://www.creationkit.com/GetFurnitureMarkerID
Now I just have to figure out how to move the player to that position.
User avatar
FABIAN RUIZ
 
Posts: 3495
Joined: Mon Oct 15, 2007 11:13 am

Post » Thu Jun 21, 2012 4:51 am

Hmmm I think GetFurnitureMarkerID is probably outdated, like Oblivion/Fallout stuff, because it talks about Idle Manager, and isn't that not used anymore, but now it uses the Havok animation tree to pick idles?

This leaves me at the conclusion that the furniture marker is calling the sleep menu, which also stops the player from using the furniture himself, but allows actors to use it. So here are my thoughts on how to make this mod:

1.) I can definitely script it to work. I have a prototype that works. It blocks the activation of the bed, moves the player to the bed, then plays a sleep animation and forces third person, then unblocks activation, and calls the sleep menu. However the problem with this method is I would have to probably give each bed a new keyword so I can identify it properly in my script, then moveto a predefined position based on the keyword type and play the proper entry animation based on the keyword as well, all in a big script. It might not be that bad at all really.

2.) I could maybe try copying the player, then have the copy use the bed, then have the bed activate the sleep menu for the player. Have to somehow hide the player and do a bunch of hacks. Copying the player might cause lag too.

3.) One could make new furniture nifs which don't have a marker named sleep, but its like a new type of passive furniture that has no special activation menu hard coded. Basically new chairs with new sit anims. Then add a new entry to the animation tree that tells the player what animation to play, and just reuse the furniture. Then You would have to edit every bed base object in the game to be this new type... however, I am leery that it would break NPC's from using beds, but maybe not.

I'm leaning towards trying out method 1.
User avatar
Marie Maillos
 
Posts: 3403
Joined: Wed Mar 21, 2007 4:39 pm

Post » Thu Jun 21, 2012 1:13 pm

wow, I am really close now. I was trying to manually set the animation to play based on keywords I gave beds, and manually offset the player so it would look like the player is sleeping in the bed, etc... none of that was needed. I stumbled across something pretty amazing... if you simply use player.moveto (object) it automatically activates it! So I have it working without doing anything really. The only problem is, the player activating the bed actually puts him in bed immediately. It doesn't play the get into the bed animation.

Now here is my theory on how to fix it. I need to somehow do player.moveto (one of the beds markers)

Does anyone know how to identify a furniture marker in the script? Then I am sure the player would activate the "get into bed" anim first. Because if I just player.moveto (self) on the bed he activates, he is sleeping, then gets up naturally. So if I can somehow move the player to the bed marker, it would work I think.
User avatar
LuBiE LoU
 
Posts: 3391
Joined: Sun Jun 18, 2006 4:43 pm

Post » Thu Jun 21, 2012 5:27 pm

Thanks everyone for your help. I've pulled it off. I should have a release soon. I have to build the alias quest yet to give any bed the script without messing with the beds manually, and probably will do a few other little touches like an auto get undressed feature you can configure.
User avatar
Vera Maslar
 
Posts: 3468
Joined: Wed Sep 27, 2006 2:32 pm

Post » Thu Jun 21, 2012 5:46 am

Very promissing indeed, I too am missing the mod, especially with all the (for me) unintrusive 3d animations (like forge, tanning rack etc.). Looking forward for the release.
User avatar
April D. F
 
Posts: 3346
Joined: Wed Mar 21, 2007 8:41 pm

Post » Thu Jun 21, 2012 5:39 pm

http://www.creationkit.com/SetPlayerAIDriven_-_Game

Yeah, it is better with that. Thanks.
User avatar
Brandi Norton
 
Posts: 3334
Joined: Fri Feb 09, 2007 9:24 pm

Post » Thu Jun 21, 2012 11:14 am

This is the version I made with the method I described: http://youtu.be/kRyHVOk4XBk

It uses clones since I still can't figure out how to call up the sleep menu while lying in bed. Also, it appears that activation prompts don't show up when the player is invisible. It didn't work on the hay pile because the script I'm using checks the name of the furniture for "bed" to determine if it's a bed.

Note: There is no audio to keep the file size down.

EDIT: Just double-checked the video. Don't know if it's because my video card svcks or if it's because I'm using a freeware program, but there is a lot of flickering and sometimes you can't see the message boxes...
User avatar
Schel[Anne]FTL
 
Posts: 3384
Joined: Thu Nov 16, 2006 6:53 pm

Post » Thu Jun 21, 2012 1:39 pm

This is the version I made with the method I described: http://youtu.be/kRyHVOk4XBk

It uses clones since I still can't figure out how to call up the sleep menu while lying in bed. Also, it appears that activation prompts don't show up when the player is invisible. It didn't work on the hay pile because the script I'm using checks the name of the furniture for "bed" to determine if it's a bed.

Note: There is no audio to keep the file size down.

EDIT: Just double-checked the video. Don't know if it's because my video card svcks or if it's because I'm using a freeware program, but there is a lot of flickering and sometimes you can't see the message boxes...
That is nice you got them to lay down. If I could identify the node of the bed, I might be able to get the player to "moveTo" it, which is how I got my version working. Moveto activates the object, if it is an activator.

Now I just need to do the quest alias stuff. I did the chop wood tutorial and got a basic understanding of it. Hopefully I can get that part working now :)
User avatar
Queen
 
Posts: 3480
Joined: Fri Dec 29, 2006 1:00 pm

Post » Thu Jun 21, 2012 11:04 am

I took a quick look at the nif files for some of the beds. I'm not a modeller, but they don't seem to use nodes for the marker positions. The marker positions for where an NPC lies down are determined by an offset vector from the local origin of the bed. There doesn't seem to be any nodes involved.

I'm not sure why you even need to find the node of a bed. Using
Game.GetPlayer().MoveTo(BedRef, -150, -150)
still put the player in bed the same as
Game.GetPlayer().MoveTo(BedRef)
so how would finding the node for the bed help?

Or did you mean that you wanted to move the player next to the bed, and then script them to activate the bed, in order to try and get him/her to play a getting in bed animation?
User avatar
Mr. Ray
 
Posts: 3459
Joined: Sun Jul 29, 2007 8:08 am

Post » Thu Jun 21, 2012 1:10 pm

I took a quick look at the nif files for some of the beds. I'm not a modeller, but they don't seem to use nodes for the marker positions. The marker positions for where an NPC lies down are determined by an offset vector from the local origin of the bed. There doesn't seem to be any nodes involved.

I'm not sure why you even need to find the node of a bed. Using
Game.GetPlayer().MoveTo(BedRef, -150, -150)
still put the player in bed the same as
Game.GetPlayer().MoveTo(BedRef)
so how would finding the node for the bed help?

Or did you mean that you wanted to move the player next to the bed, and then script them to activate the bed, in order to try and get him/her to play a getting in bed animation?
Well, I figured that if Game.GetPlayer().Moveto (bed) puts the player in bed sleeping, then my logic was that Game.GetPlayer().Moveto (bed sleep marker) would activate the get into bed animation. Right now I had to do the fade to black stuff because I don't know how to make the player play the get into bed animation. I just move the player to the bed, and he's sleeping, then he gets up and plays the proper get up animation, all by using moveto. I'm not telling the player to activate the bed or anything, just moveto any piece of furniture makes the player use it. I had no idea, because usually you tell them to activate it to get them to use something.
User avatar
Marine x
 
Posts: 3327
Joined: Thu Mar 29, 2007 4:54 am

Post » Thu Jun 21, 2012 11:05 am

How does one get the package to the player that you want them to run when you switch to the http://www.creationkit.com/SetPlayerAIDriven_-_Game I Tried a scene alias of the player
then I scripted a bed with a unique ID and set in the script Init block activate. I set up the script to run the setplayerAIDriven and start the scene with the player as the alias which has a package to sleep any time for 3 hours The player just stands there... and I cant move him while its happening which I expected but he does not use the bed and the getpackage does not show the package running ?


So what's up
User avatar
jessica breen
 
Posts: 3524
Joined: Thu Aug 03, 2006 1:04 am

Post » Thu Jun 21, 2012 8:14 pm

So what's up

Not enough info on your script and/or AI package settings to begin to tell the problem.
User avatar
courtnay
 
Posts: 3412
Joined: Sun Nov 05, 2006 8:49 pm

Post » Thu Jun 21, 2012 4:07 am

Well It is kind of hard to put the scene and quest up here... Its a self start quest 1 dummy stage then the scene has the alias sleeper which is the playerref in the scene there is one package which only says sleep for 3 hours at any time.
The script is simply on the bed
Now my take on it is that the player should run the package while the script is waiting ?


Scene property ZZPlayerSleepbedScene Auto
package property ZZPlayerSleepmbed Auto

Event OnInit()
BlockActivation()
EndEvent

Event OnActivate(ObjectReference akActionRef)
If akActionRef == game.getplayer()

Game.ForceThirdPerson();
Game.SetPlayerAIDriven()
ZZPlayerSleepbedScene.Start()

utility.wait(10)
if (game.getplayer().GetCurrentPackage() == ZZPlayerSleepmbed)
Debug.notification("Were running package")
endIf
utility.wait(10)
ZZPlayerSleepbedScene.Stop()
Game.SetPlayerAIDriven(False)
endif endevent
User avatar
kirsty joanne hines
 
Posts: 3361
Joined: Fri Aug 18, 2006 10:06 am

Post » Thu Jun 21, 2012 8:36 am

I've never worked with scenes so I don't know what's going on. What I described did not require using scenes at all.
  • Create a quest.
  • Create an optional reference alias for the player.
  • Create an optional reference alias for beds.
  • Create a sleep package telling player alias to sleep in bed alias.
  • Give sleep package to player alias.
  • Use a script like this on the bed:

Scriptname BedScript extends ObjectReferenceReferenceAlias Property PlayerAlias AutoReferenceAlias Property BedAlias AutoEvent OnInit()    BlockActivation()EndEventEvent OnActivate(ObjectReference akActionRef)    if (akActionRef == Game.GetPlayer())        BedAlias.ForceRefTo(Self)        PlayerAlias.ForceRefTo(akActionRef)        Game.SetPlayerAIDriven(True)        (akActionRef as Actor).EvaluatePackage()        while ((akActionRef as Actor).GetSleepState() != 3)            Utility.Wait(0.5)        endwhile        Debug.MessageBox("Player should be in bed now.")        PlayerAlias.Clear()        BedAlias.Clear()        Game.SetPlayerAIDriven(False)    else        Activate(akActionRef, True)    endifEndEvent
User avatar
Etta Hargrave
 
Posts: 3452
Joined: Fri Sep 01, 2006 1:27 am

Next

Return to V - Skyrim