Scriptname _00E_GypsyMinstrelsControlScript extends Quest Conditional Int Property WAYPOINT_SANDBOX_MARKETPLACE = 0 AutoReadOnly Int Property WAYPOINT_TRAVEL_INN = 1 AutoReadOnly Int Property WAYPOINT_SANDBOX_INN = 2 AutoReadOnly Int Property WAYPOINT_TRAVEL_MARKETPLACE = 3 AutoReadOnly ; TIME_PERFORMANCE_START must be less than TIME_PERFORMANCE_END ; TIME_PERFORMANCE_START and TIME_PERFORMANCE_END must be greater than 0 ; Otherwise the curHour check in UpdateWaypoint must be rewritten Float Property TIME_PERFORMANCE_START = 7.0 AutoReadOnly Float Property TIME_PERFORMANCE_END = 23.0 AutoReadOnly Int Property CurrentWaypoint auto Hidden conditional ReferenceAlias Property Alias_LutePlayer Auto ReferenceAlias Property Alias_Dancer Auto GlobalVariable Property GameHour Auto Cell Property InnCell Auto ObjectReference Property LutePlayMarker Auto ObjectReference Property TipBasket Auto ObjectReference Property TempStorageMarker Auto Event OnInit() CurrentWaypoint = -1 ; Force update RegisterForSingleUpdate(3.0) ; Give a few seconds for the game to warm up at the start EndEvent Event OnUpdate() UpdateWaypoint() EndEvent Event OnUpdateGameTime() UpdateWaypoint() EndEvent Bool IsTipBasketHidden = False Bool WaypointUpdateLocked = False ; Called from OnUpdate, OnUpdateGameTime and from end events of travel packages Function UpdateWaypoint() While WaypointUpdateLocked Utility.Wait(0.5) EndWhile WaypointUpdateLocked = True Int newWaypoint = WAYPOINT_SANDBOX_MARKETPLACE Float nextCheckTime Actor lutePlayer = Alias_LutePlayer.GetActorReference() Float curHour = GameHour.GetValue() ; Debug.Trace("_00E_GypsyMinstrelsControlScript: time of day = " + curHour + "; lutePlayer -> LutePlayMarker " + lutePlayer.GetDistance(LutePlayMarker)) If curHour >= TIME_PERFORMANCE_START && curHour < TIME_PERFORMANCE_END If lutePlayer.GetDistance(LutePlayMarker) > 256.0 newWaypoint = WAYPOINT_TRAVEL_MARKETPLACE Else newWaypoint = WAYPOINT_SANDBOX_MARKETPLACE EndIf nextCheckTime = TIME_PERFORMANCE_END - curHour If newWaypoint == WAYPOINT_TRAVEL_MARKETPLACE && nextCheckTime > 0.5 nextCheckTime = 0.5 ; Failsafe if the end of the travel package is not triggered for some reason EndIf Else If lutePlayer.GetParentCell() != InnCell newWaypoint = WAYPOINT_TRAVEL_INN Else newWaypoint = WAYPOINT_SANDBOX_INN EndIf nextCheckTime = TIME_PERFORMANCE_START - curHour If nextCheckTime < 0.0 nextCheckTime += 24.0 EndIf EndIf RegisterForSingleUpdateGameTime(nextCheckTime + 0.025) ; Debug.Trace("_00E_GypsyMinstrelsControlScript: nextCheckTime = " + nextCheckTime) if newWaypoint != CurrentWaypoint ; Debug.Trace("_00E_GypsyMinstrelsControlScript: switching from waypoint " + CurrentWaypoint + " to waypoint " + newWaypoint) ; Wait for the lute player to finish his current song (if he's playing) (lutePlayer as _00E_BardPlayInstrumentScript).FadeAndStopMusic() CurrentWaypoint = newWaypoint lutePlayer.EvaluatePackage() Alias_Dancer.TryToEvaluatePackage() If CurrentWaypoint == WAYPOINT_SANDBOX_MARKETPLACE If IsTipBasketHidden IsTipBasketHidden = False TipBasket.MoveToMyEditorLocation() EndIf Else If IsTipBasketHidden == False IsTipBasketHidden = True TipBasket.MoveTo(TempStorageMarker) EndIf EndIf EndIf WaypointUpdateLocked = False EndFunction