ScriptName aaaKimachuuDungeonsNextArea Extends ObjectReference

GlobalVariable Property aaaKimachuuDungeonsGoNextArea Auto
GlobalVariable Property aaaKimachuuDungeonsCurrentHierarchy Auto
GlobalVariable Property aaaKimachuuDungeonsNFFFollowerMove Auto
ObjectReference Property objNextMarkerA Auto
ObjectReference Property objNextMarkerB Auto
ObjectReference Property objTriggerBoxA Auto
ObjectReference Property objTriggerBoxB Auto
Message Property aaaKimachuuDungeonsNotAchievedMes Auto
Quest Property DialogueFollower Auto

Event OnActivate(ObjectReference akActionRef)
	If akActionRef != Game.GetPlayer()
		Return
	EndIf

	If aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 0 || aaaKimachuuDungeonsGoNextArea.GetValue() == 1
		aaaKimachuuDungeonsGoNextArea.SetValue(0)
		aaaKimachuuDungeonsCurrentHierarchy.Mod(1)
		Utility.Wait(0.1)
		If aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 6 || aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 10 || aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 16 || aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 20 || aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 26 || aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 30
			Game.GetPlayer().MoveTo(objNextMarkerB)
			objTriggerBoxB.Enable()
			followerMoveFunction(objNextMarkerB)
			Self.PlayAnimation("Close")
		Else
			Game.FadeOutGame(True, True, 1.0, 1.0)
			Game.GetPlayer().MoveTo(objNextMarkerA)
			Game.FadeOutGame(False, True, 1.0, 1.0)
			objTriggerBoxA.Enable()
			followerMoveFunction(objNextMarkerA)
			Self.PlayAnimation("Close")
		EndIf
	Else
		aaaKimachuuDungeonsNotAchievedMes.Show()
		Utility.Wait(0.5)
		Self.PlayAnimation("Close")
	EndIf
	Debug.Notification(aaaKimachuuDungeonsCurrentHierarchy.GetValueInt() + "F")
EndEvent

Function followerMoveFunction(ObjectReference obj01)
	if Game.GetModByName("nwsFollowerFramework.esp") < 255 && aaaKimachuuDungeonsNFFFollowerMove.GetValue() == 1
		Quest NFFQuest = DialogueFollower
		int i = 2
		While i <= 12
			Utility.Wait(0.1)
			Actor Follower = (NFFQuest.GetAlias(i) as ReferenceAlias).GetRef() as Actor
			if Follower
				Follower.MoveTo(obj01)
			endif
			i += 1
		EndWhile
	Endif
EndFunction