Jump to content

Wait time control script


icecreamassassin

Recommended Posts

So the short of it; I want to have a timer that starts via conversation and then at the end of X days, advances the quest to another stage. Basically a script to check the passage of time since it was first initiated. I could totally do this in Oblivion but I am not seeing similar calls on total days passed so I can set up a check against that global vs the total days played later on when the check would pass as true... sigh... can anyone point me in the right direction? I'm not finding any leads at all online or on the forum

 

And just FYI I am not looking for RegisterForSingleUpdate or Wait functions, these are in REAL TIME, I need to check GAME TIME. Thanks.

Link to comment
Share on other sites

You can also use GetCurrentGameTime coupled with a while loop

 

float Property DaysToPass Auto

;... some event

float StartTime = Utility.GetCurrentGameTime()

float EndTime = StartTime + DaysToPass

While Utility.GetCurrentGameTime() < EndTime

;do nothing, just loop

Utility.Wait(1.0) ; wait just a single second so it doesn't over burden papyrus with rapid calls every few milliseconds.

EndWhile

If Utility.GetCurrentGameTime() >= EndTime

;enough time has passed, so do something

EndIf

;... other stuff

 

Under the hood GetCurrentGameTime() is the same as GameDaysPassed.GetValue(). GameDaysPassed is the name of the global that holds the total amount of in-game time that has passed. FormID 00000039

 

EDIT: Saw I had used INT instead of FLOAT

Edited by IsharaMeradin
Link to comment
Share on other sites

ah thanks, good to know. I thought it was kind of odd that Skyrim didn't seem to have a very similar time tracking mechanism to Oblivion. I'll try the simple script pause method and if that fails I'll work off what you posted. Thanks again as always, you are a huge life saver :)

Link to comment
Share on other sites

  • 8 years later...

I bumped this because I am like the OP: I've made countless timers in earlier games.



So for my latest quest, I'm trying to make a timer script, and came across this thread. Because (again) I can't find any tutorials for this sort of thing. Bethesda's Creation Kit website only gives you bits and pieces....



What I want to happen is pretty simple. An NPC says "I'll be here. Come back in a day and I'll tell you what happens next." The player goes somewhere else, returns in 24 hours or more, and the NPC has new dialog.



And so obviously, I need a timer. Which I assume the script below can work, but I have questions.



--------------------------------------



float Property DaysToPass Auto


;... some event


float StartTime = Utility.GetCurrentGameTime()


float EndTime = StartTime + DaysToPass



While Utility.GetCurrentGameTime() < EndTime


;do nothing, just loop


Utility.Wait(1.0) ; wait just a single second so it doesn't over burden papyrus with rapid calls every few milliseconds.


EndWhile



If Utility.GetCurrentGameTime() >= EndTime


;enough time has passed, so do something


EndIf


;... other stuff



----------------------------------------------



I kind of get how this works, but where do I declare how many days should pass?


Edited by xenaclone
Link to comment
Share on other sites

There is probably a better method in your scenario.

 

Use a quest script that contains the following (can be added to your existing quest script if you have one):

 

 

ScriptName myQuestScript Extends Quest
;feel free to rename the script - just update its usage throughout
 
GlobalVariable Property myDayIsUp Auto
;create a global variable record with a default float value of 0
;i.e. create new, give it a name and 'ok' out of the record
 
Function RFSUGT(Float afInterval)
  RegisterForSingleUpdateGameTime(afInterval)
EndFunction
 
Event OnUpdate()
  ;enough time has passed
  myDayIsUp.SetValue(1.0)
EndEvent

 

Where the NPC tells the player to go wait, add this to the dialog fragment:

 

;the following creates a local variable that will fetch the quest holding the dialog fragment
;and assign the designated script to the local variable
;which can then be used to run a function (or pull property variables) on said script
myQuestScript MQS
MQS = GetOwningQuest() as myQuestScript
MQS.RFSUGT(24.0)

 

Where you want the NPC to have dialog options after the time is up use the following condition statement

GetGlobalValue, point it to the global variable you created for the myDayIsUp property and set it to be equal to 1.

Link to comment
Share on other sites

Nice. I'm finally home and in front of my gaming computer. Everything compiled! Now just gotta get into the game and see if this works. Gotta get some rest though, first.

 

Does RFSUGT stand for RegisterForSingleUpdateGameTime? Similar to the way Scriptname could be shortened to SCN?

Link to comment
Share on other sites

Nice. I'm finally home and in front of my gaming computer. Everything compiled! Now just gotta get into the game and see if this works. Gotta get some rest though, first.

 

Does RFSUGT stand for RegisterForSingleUpdateGameTime? Similar to the way Scriptname could be shortened to SCN?

That is what I meant it to mean. But only because I created a custom function (and needed to give it a name) to be called upon which in turn calls the real function.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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