Jump to content

How to add quest after player sleeps in bed


kane4355

Recommended Posts

I am trying to create a quest line that basically starts once a player loads my mod, opens a save game, and sleeps for the first time. In essence, the quest is supposed to start based off a dream you had sleeping in bed, thus starting my questline. How do i go about adding a quest or scripting it so that the quest is added when a player sleeps in any bed the first time upon loading a save game?
Link to comment
Share on other sites

  • Replies 48
  • Created
  • Last Reply

Top Posters In This Topic

I think the best way to do this is having the quest already started.

 

So set the quest as "start game enabled". Then create an alias pointing to the player.

 

So now you are at stage 0.

 

Put a script on the alias player using OnSleepStop event. You should put a GetStage(0) as a condition, so the game will track the player sleeps only when at stage 0.

 

Make the event call a SetStage to a new stage, wich will effectively start the quest.

Link to comment
Share on other sites

i am fairly new to scripting and VERy new to the whole questing aspect. I have been looking up the right syntax for the getstage and set stage so it functions properly but i cannot find anything that works with what i am trying to do. here is what i have so far:

 

Scriptname DKqueststart01 extends ObjectReference

 

Quest Property DKMDQ01 Auto

 

Function SomeFunction()

RegisterForSleep() ; Before we can use OnSleepStart we must register.

EndFunction

 

Event OnSleepStop(bool abInterrupted)

if abInterrupted

Debug.Trace("Player was woken by something!")

else

Debug.Trace("Player woke up naturally")

endIf

EndEvent

 

under "Event OnSleepStop(bool abInterrupted)" i was going to put:

 

; Obtains the current stage and sets it to a certain level if conditions are met

if DKMDQ01.GetStage() = 0

DKMDQ01.SetStage(10)

else

;player has already advanced in quest

endif

 

but for some reason that last bit of snippet doesn't look right to me. any ideas?

 

edit: this is what i get when tried to compile:

 

Starting 1 compile threads for 1 files...

Compiling "DKqueststart01"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKqueststart01.psc(11,22): required (...)+ loop did not match anything at input '='

No output generated for DKqueststart01, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on DKqueststart01

Edited by kane4355
Link to comment
Share on other sites

using the script below:

 

 

Scriptname DKqueststart01 extends ObjectReference

 

Quest Property DKMDQ01 Auto

 

Function SomeFunction()

RegisterForSleep() ; Before we can use OnSleepStart we must register.

EndFunction

 

Event OnSleepStop(bool abInterrupted)

; Obtains the current stage and sets it to a certain level if conditions are met

if DKMDQ01.GetStage(0)

DKMDQ01.SetStage(10)

else

;player has already advanced in quest

endif

EndEvent

 

 

and i get this error:

 

 

Starting 1 compile threads for 1 files...

Compiling "DKqueststart01"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKqueststart01.psc(11,12): too many arguments passed to function

No output generated for DKqueststart01, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on DKqueststart01

Link to comment
Share on other sites

wow i finally got it to work.. i think... at least it compiled, whether it works is another thing (the script at least). here it is:

 

 

Scriptname DKqueststart01 extends ObjectReference

 

Quest Property DKMDQ01 Auto

 

Function SomeFunction()

RegisterForSleep() ; Before we can use OnSleepStart we must register.

EndFunction

 

Event OnSleepStop(bool abInterrupted)

; Obtains the current stage and sets it to a certain level if conditions are met

if (DKMDQ01.GetStage() < 10)

DKMDQ01.SetStage(10)

else

if (DKMDQ01.GetStage() > 0)

;player has already advanced in quest

endif

endif

EndEvent

Link to comment
Share on other sites

I think the first error was you put "=" instead of "==" for the Getstage 0.

 

Anyway, you should make this script extend AliasRef, not ObjectReference.

 

Create a new alias pointing to the player, the put this script ON the alias.

 

Also, when you say if getstage, use this

 

if DKMDQ01.GetStage() == 0
DKMDQ01.SetStage(10)
ElseIf DKMDQ01.GetStage() != 0
Debug.Trace("Player has already advanced the quest")
Endif

 

So your script should be this

 

Scriptname DKQuestStart01 Extends AliasRef

import game
import debug

Quest Property DKMDQ01 Auto

Int Property ReqStage Auto

Int Property StageToSet Auto

Function SomeFunction()
RegisterForSleep() ; Before we can use OnSleepStart we must register.
EndFunction

Event OnSleepStop(bool abInterrupted)
        If DKMDQ01.GetStage() == ReqStage
        DKMDQ01.SetStage(StageToSet)
        EndIf
EndEvent

Edited by gasti89
Link to comment
Share on other sites

I think the first error was you put "=" instead of "==" for the Getstage 0.

 

Anyway, you should make this script extend AliasRef, not ObjectReference.

 

Create a new alias pointing to the player, the put this script ON the alias.

 

Also, when you say if getstage, use this

 

if DKMDQ01.GetStage() == 0
DKMDQ01.SetStage(10)
ElseIf DKMDQ01.GetStage() != 0
Debug.Trace("Player has already advanced the quest")
Endif

 

So your script should be this

 

Scriptname DKQuestStart01 Extends AliasRef

import game
import debug

Quest Property DKMDQ01 Auto

Int Property ReqStage Auto

Int Property StageToSet Auto

Function SomeFunction()
RegisterForSleep() ; Before we can use OnSleepStart we must register.
EndFunction

Event OnSleepStop(bool abInterrupted)
        If DKMDQ01.GetStage() == ReqStage
        DKMDQ01.SetStage(StageToSet)
        EndIf
EndEvent

 

using your script entirely i get this error:

 

Starting 1 compile threads for 1 files...

Compiling "DKqueststart01"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKqueststart01.psc(0,0): unable to locate script AliasRef

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKqueststart01.psc(13,0): RegisterForSleep is not a function or does not exist

No output generated for DKqueststart01, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on DKqueststart01

 

 

just replacing ObjectReference with AliasRef gets me this:

 

Starting 1 compile threads for 1 files...

Compiling "DKqueststart01"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKqueststart01.psc(0,0): unable to locate script AliasRef

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKqueststart01.psc(6,2): RegisterForSleep is not a function or does not exist

No output generated for DKqueststart01, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on DKqueststart01

 

 

interestingly enough, when AliasRef is replaced with ObjectReference, I get no compiling Error.

Link to comment
Share on other sites

The player alias must be "Specific reference", not unique actor. (quoting from CKwiki)

 

To add the Player as a Reference, select Specific Reference, click Select Forced Reference, pick (any) for cell and find the Player reference

 

the register for sleep part i just copypasted from your scripts, so i don't know why it doesn't work.

 

Are you putting this script on the player alias?

 

EDIT: Sorry man i just noticed my big mistake. It must extend ReferenceAlias, not AliasRef. Anyway, in the moment you click "add script" and "new" in the alias tab, then "edit source" it should automatically write the 1st line (Scriptname bla bla extends ReferenceAlias)

Edited by gasti89
Link to comment
Share on other sites

The player alias must be "Specific reference", not unique actor. (quoting from CKwiki)

 

To add the Player as a Reference, select Specific Reference, click Select Forced Reference, pick (any) for cell and find the Player reference

 

the register for sleep part i just copypasted from your scripts, so i don't know why it doesn't work.

 

Are you putting this script on the player alias?

 

yes i am and i got that portion from OnSleepStop, what u sent me.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...