Jump to content

[LE] Need help with script to update time in quest


Recommended Posts

Hello!

I am making a small quest and there is a dialogue where NPC told me "Come tomorrow". So I need to push the quest somehow to the next stage when 24 hours will pass.

I am new in scripting and I have already spent three days trying to set it up. I have found similar question here https://forums.nexusmods.com/index.php?/topic/1323969-need-help-with-a-script-update-time/

and some hints in other places but I am unable to combine them in a working script. I suppose the script should use Event OnUpdateGameTime() and/or GameHour, GameDay and other scaring things, and I have tried several scripts but they did not work. The only thing I understand is that scripting definitely is not my strong side.

But I know there are people here that could solve it within minutes. If someone will do me a favor and write a script and provide it with clear instructions how to make it work I would appreciate it very much.

The current stages of my quest are as follows:

Stage 10

I came to fisherman to thank him and offer a reward

Stage 50

(there are several options of reward, that is why the stage number is 50 and not 20)

I gave 1000 gold to fisherman and he in return promised to build fish hatchery for me. He said it will be done tomorrow.

Objective: wait 24 hours

Stage 55

As 24 hours have passed I have to meet with fisherman.

etc

 

That is what I have now (it does not work). First, the script attached to the quest. The name of the quest is aaThanks2Pit

Scriptname AS_TimerScript extends Quest

 

 

Event OnUpdateGameTime()

GameTime = GetCurrentGameTime()

GameHoursPassed = ((GameTime - (GameTime As Int)) * 24)

 

SetStage(55)

GotoState("")

EndEvent

EndState

Quest Property aaThanks2Pit Auto

 

And second, the Papyrus fragment at stage 50

SetObjectiveCompleted(10)

Alias_AliasPit.GetReference().AddItem(Gold001, 1000)

Game.GetPlayer().RemoveItem(Gold001, 1000)

SetObjectiveDisplayed(55)

 

aaThanks2Pit.RegisterForSingleUpdateGameTime(24)

aaThanks2Pit.GotoState("waitForUpdate")

SetObjectiveDisplayed(60)

SetStage(55)

 

 

 

 

 

Link to comment
Share on other sites

Maybe the next script phrases kick you in the right direction.

 

AS_TimerScript

 

Scriptname AS_TimerScript extends Quest
; this script should be attached to quest aaThanks2Pit, it means "self as Quest == aaThanks2Pit"

https://forums.nexusmods.com/index.php?/topic/5574162-need-help-with-script-to-update-time-in-quest/

; -- EVENTs -- 2
; http://www.creationkit.com/index.php?title=Category:Scripting

EVENT OnInit()
    Debug.Trace("OnInit() - Quest 'aaThanks2Pit' is running..  " +self)        ; info only
ENDEVENT

EVENT OnUpdateGameTime()
; this event will be received after 24 hours ingame
; caused by fragment codeline: ((self as Quest) as AS_TimerScript).RegisterForSingleUpdateGameTime(24.0)

IF (self as Quest) && self.IsRunning()    ; make sure your mod is still active
    self.setStage(55)
ENDIF
ENDEVENT

 

 

 

fragment code as suggestion, how to do that?

 

;/ ***
;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 6
Scriptname QF_???_Fisherman Extends Quest Hidden

;BEGIN ALIAS PROPERTY
;ALIAS PROPERTY TYPE ReferenceAlias Alias_AliasPit    the fisherman
ReferenceAlias Property Alias_AliasPit Auto
;END ALIAS PROPERTY
;--------------------------------------------------

;BEGIN FRAGMENT Fragment_0
Function Fragment_0()
;BEGIN CODE
;player has received the quest
    ; setStage(?)
    ; SetObjectiveDisplayed(?,1)
;END CODE
EndFunction
;END FRAGMENT


;BEGIN FRAGMENT Fragment_1
Function Fragment_1()
;BEGIN CODE
;Quest Failed, quest giver died: Did you cover this case?
    FailAllObjectives()
    Stop()
;END CODE
EndFunction
;END FRAGMENT


;BEGIN FRAGMENT Fragment_5        ; any other fragment_?? available
Function Fragment_5()
;BEGIN CODE
    ; and second, the Papyrus fragment at stage 50
    SetObjectiveCompleted(10)

IF myF_PlayerHasGold(1000)
    SetObjectiveDisplayed(55)
    ((self as Quest) as AS_TimerScript).RegisterForSingleUpdateGameTime(24.0)
    SetObjectiveDisplayed(60)
ENDIF
;END CODE
EndFunction
;END FRAGMENT

  MiscObject PROPERTY Gold001 auto

;-------------------------------------
Bool FUNCTION myF_PlayerHasGold(Int i)
;-------------------------------------
    actor aRef = Game.GetPlayer()

IF (aRef.GetItemCount(Gold001) > i)
    aRef.RemoveItem(Gold001, i)
    Alias_AliasPit.GetReference().AddItem(Gold001, i)
    Return TRUE
ENDIF
;---------
    Debug.Notification("Not enough gold..")
    Return False    ; not enough gold
ENDFUNCTION
*** /;

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

You have an EndState but no "State waitForUpdate" statement. In addition, the state waitForUpdate doesn't exist on a generic quest. Use (aaThanks2Pit as AS_TimerScript).GotoState("waitForUpdate").

Thank you for reply.

As for "State waitForUpdate" I just forget to copy it, this line exists in the original code.

But I cannot compile the fragment with this line:

(aaThanks2Pit as AS_TimerScript).GotoState("waitForUpdate")

Link to comment
Share on other sites

maybe you have not really understand:

; caused by fragment codeline: 
((self as Quest) as AS_TimerScript).RegisterForSingleUpdateGameTime(24.0)

if you really need states you have to do that:

 

Scriptname AS_TimerScript extends Quest
; this script should be attached to quest aaThanks2Pit, it means "self as Quest == aaThanks2Pit"

https://forums.nexusmods.com/index.php?/topic/5574162-need-help-with-script-to-update-time-in-quest/

; -- EVENTs --

EVENT OnInit()
    Debug.Trace("OnInit() - Quest 'aaThanks2Pit' is running..  " +self)        ; info only
ENDEVENT

;=====================================
state waitForUpdate
;==================
EVENT OnUpdateGameTime()
IF (self as Quest) && self.IsRunning()    ; make sure your mod is still active
    self.setStage(55)
ENDIF
ENDEVENT
;=======
endState

 

 

fragment code should look as follow:

((self as Quest) as AS_TimerScript).gotoState("waitForUpdate")
((self as Quest) as AS_TimerScript).RegisterForSingleUpdateGameTime(24.0)
Edited by ReDragon2013
Link to comment
Share on other sites

 

maybe you have not really understand:

; caused by fragment codeline: 
((self as Quest) as AS_TimerScript).RegisterForSingleUpdateGameTime(24.0)

if you really need states you have to do that:

 

Scriptname AS_TimerScript extends Quest
; this script should be attached to quest aaThanks2Pit, it means "self as Quest == aaThanks2Pit"

https://forums.nexusmods.com/index.php?/topic/5574162-need-help-with-script-to-update-time-in-quest/

; -- EVENTs --

EVENT OnInit()
    Debug.Trace("OnInit() - Quest 'aaThanks2Pit' is running..  " +self)        ; info only
ENDEVENT

;=====================================
state waitForUpdate
;==================
EVENT OnUpdateGameTime()
IF (self as Quest) && self.IsRunning()    ; make sure your mod is still active
    self.setStage(55)
ENDIF
ENDEVENT
;=======
endState

 

 

fragment code should look as follow:

((self as Quest) as AS_TimerScript).gotoState("waitForUpdate")
((self as Quest) as AS_TimerScript).RegisterForSingleUpdateGameTime(24.0)

Well, I have to admit I really have not understand that. That is why I have asked for a clear instructions and thank you for giving me them.

More to say, it seems I do not understand scripting at all, this is definitely not my territory. I have a lot of ideas about quest and dialogues and scenes but when it comes to technical side of all these things I spent two or three days for single stage and it makes me lose courage. Then I go and kill some draugrs and return back to work refreshed)

Link to comment
Share on other sites

  • 1 year later...

There's a cleaner way to do this, you need the dialogue/AI packs conditioned as follows:

 

Let's say you call your GlobalVariable "QuestDelay".

 

GetGlobalValue - QuestDelay <= GameDaysPassed
GetGlobalValue - QuestDelay != 0

 

So when you want to start the delay you can do it with the following line

QuestDelay.Value = (Utility.GetCurrentGameTime() + 1)
; sets global to current day +1

Where possible, avoid registering for update. If the papyrus engine gets overloaded, the update registration may drop, causing a stall in your quest.

 

Unless you specifically want the stage to fire, when you're randomly out in the wilderness? If so registering may be the best way.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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