4
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

67 lines
1.6 KiB

Scriptname _00E_DayTimeControlScript extends Quest
ObjectReference Property NightLightsMarker Auto
ObjectReference Property TradeHoursMarker Auto
GlobalVariable Property GameHour Auto
Float Property NIGHT_LIGHTS_ON_TIME = 18.9 AutoReadOnly
Float Property NIGHT_LIGHTS_OFF_TIME = 6.25 AutoReadOnly
Float Property TRADE_ON_TIME = 8.1 AutoReadOnly
Float Property TRADE_OFF_TIME = 20.0 AutoReadOnly
Event OnInit()
RegisterForSingleUpdate(3.0) ; Give a few seconds for the game to warm up at the start
EndEvent
Event OnUpdate()
UpdateMarkers()
EndEvent
Event OnUpdateGameTime()
UpdateMarkers()
EndEvent
Function UpdateMarkers()
Float nextUpdateHour = 24.0
nextUpdateHour = _UpdateMarker(NightLightsMarker, NIGHT_LIGHTS_ON_TIME, NIGHT_LIGHTS_OFF_TIME, nextUpdateHour)
nextUpdateHour = _UpdateMarker(TradeHoursMarker, TRADE_ON_TIME, TRADE_OFF_TIME, nextUpdateHour)
RegisterForSingleUpdateGameTime(nextUpdateHour + 0.025)
EndFunction
Float Function _UpdateMarker(ObjectReference markerRef, Float onTime, Float offTime, Float questUpdateHour)
Float nextUpdateHour
Float curHour = GameHour.GetValue()
If onTime > offTime
If curHour >= offTime && curHour < onTime
markerRef.Disable()
nextUpdateHour = onTime
Else
markerRef.Enable()
nextUpdateHour = offTime
EndIf
Else ; onTime < offTime
If curHour >= onTime && curHour < offTime
markerRef.Enable()
nextUpdateHour = offTime
Else
markerRef.Disable()
nextUpdateHour = onTime
EndIf
EndIf
If nextUpdateHour < curHour
nextUpdateHour += 24.0
EndIf
nextUpdateHour -= curHour
If nextUpdateHour < questUpdateHour
Return nextUpdateHour
Else
Return questUpdateHour
EndIf
EndFunction