4
Fork 0

Moved HourIsInRange() to a dedicated script

Eddoursul 3 months ago
parent 4dc08bce05
commit 4c234ae3e9
  1. BIN
      scripts/_00e_func_hourisinrange.pex
  2. BIN
      scripts/_00e_questfunctions.pex
  3. BIN
      scripts/_00e_sermontriggerboxscript.pex
  4. 30
      source/scripts/_00e_func_hourisinrange.psc
  5. 29
      source/scripts/_00e_questfunctions.psc
  6. 2
      source/scripts/_00e_sermontriggerboxscript.psc

Binary file not shown.

@ -0,0 +1,30 @@
Scriptname _00E_Func_HourIsInRange Hidden
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 Run(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

@ -222,35 +222,6 @@ Function WaitForReferenceToLoad(ObjectReference ref) Global
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
Function EnableReferenceFormList(FormList referenceList) Global
Int nItems = referenceList.GetSize()

@ -48,7 +48,7 @@ Function TryStartSermonScene()
ObjectReference preachMarkerRef = priestRef.GetLinkedRef()
If (priestRef.GetDistance(preachMarkerRef) > 1000.0) || (_00E_QuestFunctions.HourIsInRange(GameHour.GetValue(), __Config_SermonHourStart, __Config_SermonHourEnd) == False)
If (priestRef.GetDistance(preachMarkerRef) > 1000.0) || (_00E_Func_HourIsInRange.Run(GameHour.GetValue(), __Config_SermonHourStart, __Config_SermonHourEnd) == False)
If bPlayerIsInside
RegisterForSingleUpdate(5.0)
EndIf

Loading…
Cancel
Save