Scriptname _00E_MQ07a_RiddleBookSC extends ObjectReference  

Event OnActivate(ObjectReference akActionRef)

	If MQ07a.GetCurrentStageID() == 90
		If MQ07a_BookRiddle.GetValueInt() == RiddleNumber
			ProgressRiddle()
		Else
			ResetRiddle()
		EndIf
	EndIf
	
EndEvent

Function ProgressRiddle()

	DRScTreasureDwarvenLargeOpenM.Play(Self)
	MQ07a_BookRiddle.SetValueInt(RiddleNumber + 1)
	
	If MQ07a_BookRiddle.GetValueInt() >= 4
		Utility.Wait(0.5)
		DRScTreasureBossDwarvenOpenM.Play(Self)
	EndIf


EndFunction


Function ResetRiddle()

	DRScTreasureBossDwarvenCloseM.Play(Self)
	; Debug.Notification("Der Mechanismus wurde revertiert.")
	MQ07a_BookRiddle.SetValueInt(0)

EndFunction

Quest Property MQ07a Auto

int Property RiddleNumber Auto

GlobalVariable Property MQ07a_BookRiddle Auto
GlobalVariable Property MQ07a_RiddleSolved Auto

Sound Property DRScTreasureDwarvenLargeOpenM Auto
Sound Property DRScTreasureBossDwarvenCloseM Auto
Sound Property DRScTreasureBossDwarvenOpenM Auto
Sound Property UIActivateFailM Auto