Jump to content

Updating a script every ingame hour


Recommended Posts

Almost.

 

Use the OnUpdateGameTime event and RegisterForSingleUpdateGameTime function.

 

The limitation is that when you register for one hour, the only thing that's certain is that the event won't trigger in less than one hour. It might take longer (much longer). The problem is that when the player uses fast travel, sleeps, or waits the game goes into a "fast forward" mode and doesn't even try to process those sorts of events. So if you register for an event in one hour and then the player decides to sleep for 24, the event will still fire but 23 game hours later than you expected.

 

Depending on what exactly you're trying to do that may not be a problem. If you're trying to make some adjustment to the game world every hour and don't want to skip any then you'll need to compare the actual game time when the event does eventually happen, determine how late it is, and make adjustments if it took longer than you expected.

Link to comment
Share on other sites

Got it to work thank you.
The fast travel and waiting was a issue if i would update the script once every hour but i guess 12 hours would decrease the value by way too much so i just made the script update once every 3 hours and i multiplied the value by 3.

 

Event OnUpdateGameTime()

int ReduceBloodPoints = Utility.RandomInt(450, 1050)
debug.notification(ReduceBloodPoints)
If JVar_VampireBloodPoints > (ReduceBloodPoints)
JVar_VampireBloodPoints -= (ReduceBloodPoints)
debug.notification(JVar_VampireBloodPoints)
EndIf
EndEvent

 

Function VampireFeed()

JVar_VampireBloodPoints += 2500
VampireTransformDecreaseISMD.applyCrossFade(2.0)
utility.wait(2.0)
imageSpaceModifier.removeCrossFade()
Game.IncrementStat( "Necks Bitten" )
VampireFeedMessage.Show()
VampireStages()
UnregisterforUpdateGameTime()
RegisterForUpdateGameTime(3.0)
EndFunction

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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