Jump to content

PSA: Calculating when a script timer will expire to report time to go


SKKmods

Recommended Posts

I have been around this exact same learning loop several times over the years because I dont keep a proper development journal. This is both a PSA and memo to self when using base game native functions only:

 

 

GameTime

GetCurrentGameTime() in GameHours is paused in menus and preserved across OnPlayerLoadGame.
StartTimerGameTime() in GameHours is paused in menus but the timer resolution is only accurate to +/- 180 gametime seconds which at default 20:1 is 9 realtime seconds. At lower timescales run by many modern players the realtime skew is worse up to 180 realtime seconds at Timescale 1:1
If you need timer accuracy below 9 real time seconds in a default game you MUST use RealTime, but:
RealTime
GetCurrentRealTime() in real seconds still tick in menus and is reset to zero OnPlayerLoadGame.
StartTimer() in real seconds do not tick in menus. To align with GetCurrentRealTime() store an end time and reset the timer at each OnMenuOpenCloseEvent (abOpening == false) .AND. use Utility.IsMenuMode() to detect multiple stacked open menus e.g. (PipboyMenu + PauseMenu).
As GetCurrentRealTime() resets to zero and there is no OnPlayerExitGame event to trigger a snapshot there is no elegant solution to preserve an accurate +/- 9 realtime second timer end time value across a game exit/load cycle.
Saving GetCurrentRealTime() value to a variable every N timer seconds is nasty. Saving a parallel GameTime based end time and refactoring that back to RealTime at each OnPlayerLoadGame is better BUT can suffer +/- 9 seconds skew each cycle. No EZ solution.
ps Convert GameTime <> RealTime by aligning the days/seconds units and factor by pTimescale.GetValue() never assume its a fixed value of 20.
Link to comment
Share on other sites

I'm glad you posted that as it points out a significant editing error (now corrected) its 180 gametime seconds == 9 realtime seconds at default 20:1

 

I run a lot of worst case stress tests at 1:1 timescale.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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