Jump to content

Script to trigger an event at a specific time period in a game day.


wcho035

Recommended Posts

Hi, I am trying to get something trigger at between 05:31am to 18:59 pm in game time. Unfortunately, I can seem to get it correct.

 

I have two choices.

 

if Utility.GetCurrentGameTime() >= 05.31 && Utility.GetCurrentGameTime() <= 18.59

 

or

 

if GameHour.GetValue() >= 05.31 && GameHour.GetValue() <= 18.59

 

How do you implement it?

Link to comment
Share on other sites

GetCurrentGameTime() returns 24hour game days passed since start of game not the hour - o - clock, so use GameHour.

 

if its not time calculate the difference in game hours through or after midnight and StartTimeGameTime() on that.

Edited by SKK50
Link to comment
Share on other sites

Nah, that function can be used to get the current hour, minutes, seconds.. for the current day. The previous days passed are removed with the following conversion, leaving only the hours passed(seconds included as the fractional part, which then also need to be converted to minutes if you want a "time like" return value like 13.55 instead of 13.95) for the current day:

 

Float currentTime = Utility.GetCurrentGameTime()

Float currentHour = (currentTime - currentTime as int) * 24.0

 

To convert the "24h" time it uses, just subject 12 hours when the time is past 12 pm.

 

Additional calculations can be made to get other units of time.

 

In terms of speed, if you care about that, the function is slow, and the global version(GameDaysPassed) is faster. I think GetCurrentGameTime just calls GameDaysPassed.GetValue() under the hood and thus another one of the papyrus many unnecessary wrapper functions. GameHour of course is even better since you don't need to do math.

Edited by Rasikko
Link to comment
Share on other sites

Hi, thank you everyone for replying. Thanks to your input, I am able to narrow down the problem, but for GameHour I still can't get the trigger condition working with my if statements? Do I need to implement the following code?

 

Load()

 

Float Time = GameHour.GetValue()

 

if Time >= 5.31 && Time <= 18.59

 

(Script to execute)

 

endif.

 

 

End()

 

This is the best way?

Link to comment
Share on other sites

I have done a Messagebox printout of the GameHour.getvalue(), it is always 0.0000

 

It is not returning the proper value to the float variable Time.

 

Apparently GameHour is a globalvariable.

 

I have declare it as

 

globalvariable property GameHour auto

 

So how can I get the actual value returned instead of 0.0000 everytime?

Link to comment
Share on other sites

Really sounds like you don't have the property filled.

 

But in case you did and it's still not working, there is alternative that should work.

 

Copy this function:

 

 

Float Function GetCurrentTime()
    Float daysPassed = (Game.GetFormFromFile(0x00000039, "Fallout4.ESM") as GlobalVariable).GetValue()
    Float hoursPassed = (daysPassed - daysPassed as int) * 24.0
    Float currentTime = hoursPassed as int + ((((hoursPassed - hoursPassed as int) * 60.0) as int) / 100.0)
   
    return currentTime
EndFunction

That will return the actual in game time but still uses 24h format, just that the minutes are converted from the seconds. This isn't even necessary since GameHour can do this for you, but it seems to not be working for you, for some reason. This custom function should, as it "talks" directly to the GameDaysPassed global, so don't need to care about properties or whatever.

 

And then do something like..

 

 

Float gameHour = GetCurrentTime()
 
if gameHour >= 5.31 && gameHour <= 16.59
   ; stuff
endif
Link to comment
Share on other sites

In the console type [ show GameHour ] compare that decimal value from 0 to the pipboy map hour.

 

If the GameHour GlobalVariable is reporting in your save game (it is fundamental to the game engine, so it always does) then you have not linked the script property to the actual object with the [ PROPERTIES ] button.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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