67 lines
1.9 KiB
Plaintext
67 lines
1.9 KiB
Plaintext
|
Scriptname _00E_TimeControl Hidden
|
||
|
|
||
|
Function SkipTimeToHour(Float fNewHourOfDay, Float fMinHoursToSkip = 0.0) Global
|
||
|
{Progresses the current in-game time to the desired hour (and optionally, by no less than fMinHoursToSkip hours), moving to the next day if needed}
|
||
|
|
||
|
GlobalVariable GameHourVar = Game.GetForm(0x38) as GlobalVariable
|
||
|
|
||
|
Float fCurHour = GameHourVar.GetValue()
|
||
|
If fNewHourOfDay <= fCurHour
|
||
|
fNewHourOfDay += 24.0 ; Go to the next day
|
||
|
EndIf
|
||
|
If (fNewHourOfDay - fCurHour) < fMinHoursToSkip
|
||
|
fNewHourOfDay += 24.0 ; Go to the next day
|
||
|
EndIf
|
||
|
GameHourVar.SetValue(fNewHourOfDay)
|
||
|
GameHourVar.SendModEvent("TimeSkip")
|
||
|
|
||
|
EndFunction
|
||
|
|
||
|
;/ Unused
|
||
|
Function SkipHours(Float fHoursToSkip) Global
|
||
|
{Progresses the current in-game time by fHoursToSkip hours}
|
||
|
|
||
|
GlobalVariable GameHourVar = Game.GetForm(0x38) as GlobalVariable
|
||
|
|
||
|
GameHourVar.SetValue(GameHourVar.GetValue() + fHoursToSkip)
|
||
|
GameHourVar.SendModEvent("TimeSkip")
|
||
|
|
||
|
EndFunction
|
||
|
/;
|
||
|
|
||
|
Float Function NormalizeHour(Float fHour) Global
|
||
|
|
||
|
If fHour >= 24.0
|
||
|
Return (fHour - 24.0)
|
||
|
ElseIf fHour < 0.0
|
||
|
Return (fHour + 24.0)
|
||
|
Else
|
||
|
Return fHour
|
||
|
EndIf
|
||
|
|
||
|
EndFunction
|
||
|
|
||
|
Bool Function HourIsInRange(Float fHour, Float fHourStart, Float fHourEnd) Global
|
||
|
|
||
|
; "Smart" test for fHour being withing a range.
|
||
|
; Works both with "day" ranges (e.g., 06:00- 20:00) and with "night" ranges (e.g., 21:00-06:00)
|
||
|
|
||
|
fHour = NormalizeHour(fHour)
|
||
|
fHourStart = NormalizeHour(fHourStart)
|
||
|
fHourEnd = NormalizeHour(fHourEnd)
|
||
|
|
||
|
If fHourStart <= fHourEnd ; Something like 06:00 - 20:00
|
||
|
Return (fHour >= fHourStart && fHour < fHourEnd)
|
||
|
Else ; Something like 20:00 - 06:00
|
||
|
Return (fHour >= fHourStart || fHour < fHourEnd)
|
||
|
EndIf
|
||
|
|
||
|
EndFunction
|
||
|
|
||
|
Float Function AdjustTimePeriodByEngineTimerError(Float fUnadjustedPeriod) Global
|
||
|
|
||
|
; In SE, the game time runs slower than the real time by about 2.5/60 second
|
||
|
Return fUnadjustedPeriod - (2.5 * Math.Floor(fUnadjustedPeriod) / 60.0)
|
||
|
|
||
|
EndFunction
|