ScriptName _amm_QuestTriggerScript Extends ObjectReference

Import Game

Actor Property acPlayer Auto
Faction Property fcFloatingIsland Auto
GlobalVariable Property gvBarrelQst Auto
GlobalVariable Property gvSaxhleelQst Auto
GlobalVariable Property gvStabelizerQst Auto
GlobalVariable Property gvTreasureQst Auto
GlobalVariable Property gvShakeStrenth Auto
ObjectReference Property orNote01 Auto
ObjectReference Property orNote02 Auto
ObjectReference[] Property orJournal Auto

Event OnTriggerEnter(ObjectReference akActionRef)

	Float fShakeStr = gvShakeStrenth.GetValue()
	
	If (!acPlayer.IsInFaction(fcFloatingIsland))
		acPlayer.AddToFaction(fcFloatingIsland)
	EndIf
	
	If (akActionRef == acPlayer)
		; Treasure quest completed
		If (gvTreasureQst.GetValue() As Bool == True)
			orJournal[0].Enable()
		EndIf
		; Saxhleel quest completed
		If (gvSaxhleelQst.GetValue() As Bool == True)
			orJournal[0].Disable()
			orJournal[1].Enable()
		EndIf
		; Summonable Dwemer barrel found
		If (gvBarrelQst.GetValue() As Bool == True)
			orNote02.Enable()
			; Shake camera at the player's position
			ShakeCamera(acPlayer, fShakeStr)
			fShakeStr += 0.05
			gvShakeStrenth.SetValue(fShakeStr)
			orJournal[1].Disable()
			orJournal[2].Enable()
		EndIf
		; Stabelizer quest completed
		If (gvStabelizerQst.GetValue() As Bool == True)
			Self.Disable()
			orJournal[2].Disable()
			orJournal[3].Enable()
		EndIf
	EndIf

EndEvent
