Jump to content

[LE] Help with some basic scripting


Recommended Posts

Could I have some help with a little script I wrote? I added the script to the quest. Here's the quest:

 

Scriptname BSEDreamStart extends Quest
Quest Property MainQuestE Auto
Event OnInit()
RegisterForSleep()
EndEvent
Event OnSleepStop(bool abInterrupted)
Debug.MessageBox("I have had a disturbing dream: there were grasslands and dusty steppes beneath the Moons and I heard a Khajiit woman crying. I cannot shake a sensation of doom and fear. Maybe I should talk to someone about it.")
MainQuestE.SetObjectiveDisplayed(10)
MainQuestE.SetStage(10)
EndEvent
The message box triggers, yet the quest doesn't want to change its stage or display a new stage. Do any of you know why this could be?
Link to comment
Share on other sites

 

Could I have some help with a little script I wrote? I added the script to the quest. Here's the quest:

 

Scriptname BSEDreamStart extends Quest
Quest Property MainQuestE Auto
Event OnInit()
RegisterForSleep()
EndEvent
Event OnSleepStop(bool abInterrupted)
Debug.MessageBox("I have had a disturbing dream: there were grasslands and dusty steppes beneath the Moons and I heard a Khajiit woman crying. I cannot shake a sensation of doom and fear. Maybe I should talk to someone about it.")
MainQuestE.SetObjectiveDisplayed(10)
MainQuestE.SetStage(10)
EndEvent
The message box triggers, yet the quest doesn't want to change its stage or display a new stage. Do any of you know why this could be?

 

 

Check your aliases, make sure they're all filled. Console command 'sqv'.

Link to comment
Share on other sites

Difficult to know the context that you have placed this script in as you talk about it not starting a quest when the stage 10 is set, if this is the case the problem could be with what is being done at stage 10 (is it starting another quest?).

 

I would generally run sleep scripts on the player alias, testing for stage already at and then set to a stage. I would also place the message and set objective as a quest fragment in the stage that was set. This makes it much easier to see what's happening in quest stages and the script is generic so it can be used again.

 

eg in your sleep event:

 

If GetOwningQuest().GetStage() == StageToTest
GetOwningQuest().SetStage(StageToSet)

EndIff

Link to comment
Share on other sites

probably an issue with understanding:

   self.SetObjectiveDisplayed(10)
   self.setStage(10)

sleep is located in form.psc

; Registers this form to receive events when the player sleeps and wakes up
Function RegisterForSleep() native

; Unregisters this form to receive events when the player sleeps and wakes up
Function UnregisterForSleep() native

; Received when the player sleeps. Start and desired end time are in game time days (after registering)
Event OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime)
EndEvent

; Received when the player stops sleeping - whether naturally or interrupted (after registering)
Event OnSleepStop(bool abInterrupted)
EndEvent

vanilla refalias sample:

 

ScriptName TiberSeptimBedScript extends ReferenceAlias

Event OnActivate(ObjectReference akActionRef)
    If (akActionRef == Game.GetPlayer()) && (GetOwningQuest().GetStageDone(5) == 0)
        self.GetOwningQuest().SetStage(5)
        RegisterForSleep()                              ; *R*
    EndIf
EndEvent

Event OnSleepStop(bool abInterrupted)                   ; *E*
    If self.GetOwningQuest().GetStageDone(10) == 0
        self.GetOwningQuest().SetStage(10)
        UnregisterForSleep()                            ; ***
    EndIf
EndEvent

 


vanilla quest sample: two scripts attached to same quest, here does not exist a call of UnregisterForSleep()

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname QF_PlayerSleepQuest_000FC1A2 Extends Quest Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0()
;BEGIN AUTOCAST TYPE PlayerSleepQuestScript
Quest __temp = self as Quest
PlayerSleepQuestScript kmyQuest = __temp as PlayerSleepQuestScript
;END AUTOCAST
;BEGIN CODE
;Check when the player sleeps
; debug.trace(self + "Register for sleep to give player Well-Rested perks")
    kmyquest.RegisterForSleep()                            ; *R*
;END CODE
EndFunction
;END FRAGMENT
;END FRAGMENT CODE - Do not edit anything between this and the begin comment


ScriptName PlayerSleepQuestScript extends Quest
  CompanionsHousekeepingScript Property CHScript Auto
  Quest Property RelationshipMarriageFIN Auto

  Keyword Property LocTypeInn Auto
  Keyword Property LocTypePlayerHouse Auto

  Message Property RestedMessage  Auto  
  Message Property WellRestedMessage  Auto  
  Message Property MarriageRestedMessage  Auto  
  Message Property BeastBloodMessage  Auto

  Spell Property Rested Auto
  Spell Property WellRested Auto
  Spell Property MarriageSleepAbility Auto
  Spell Property pDoomLoverAbility Auto

  ReferenceAlias Property LoveInterest Auto

Event OnSleepStop(bool abInterrupted)                    ; *E*
;     debug.trace(self + "Player is sleeping")
    If CHScript.PlayerHasBeastBlood == 1
;         Debug.Trace(Self + "Player is werewolf; no restedness on sleep.")
        RemoveRested()                                                                        ; ***
        BeastBloodMessage.Show()

    ElseIf Game.GetPlayer().HasSpell(pDoomLoverAbility) == 0
        ;do not run this if player has the Lover sign

        If RelationshipMarriageFIN.IsRunning() == True && RelationshipMarriageFIN.GetStage() >= 10 && Game.GetPlayer().GetCurrentLocation() == LoveInterest.GetActorRef().GetCurrentLocation()
;             debug.trace(Self + "Giving player the Lover's Comfort spell on Sleep End")
            MarriageRestedMessage.Show()
            RemoveRested()                                                                    ; ***
            Game.GetPlayer().AddSpell(MarriageSleepAbility, abVerbose = false)

        ElseIf Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeInn) == True
;             debug.trace(Self + "Giving player the Well Rested spell for sleeping in an Inn")    
            WellRestedMessage.Show()
            RemoveRested()                                                                    ; ***
            Game.GetPlayer().AddSpell(WellRested, abVerbose = false)

        ElseIf Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypePlayerHouse) == True
;             debug.trace(Self + "Giving player the Well Rested spell for sleeping in Player House")    
            Game.GetPlayer().AddSpell(WellRested, abVerbose = false)

        Else
;             debug.trace(Self + "Giving player the Rested spell for sleeping")    
            RestedMessage.Show()
            RemoveRested()                                                                    ; ***
            Game.GetPlayer().AddSpell(Rested, abVerbose = false)
        EndIf
    EndIf
EndEvent


Function RemoveRested()  ; internal only
;remove all previous rested states
    Game.GetPlayer().RemoveSpell(Rested)
    Game.GetPlayer().RemoveSpell(WellRested)
    Game.GetPlayer().RemoveSpell(MarriageSleepAbility)
EndFunction

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...