ScriptName aaaKimachuuDungeonsKillActor Extends ObjectReference

GlobalVariable Property aaaKimachuuDungeonsCurrentHierarchy Auto
GlobalVariable Property aaaKimachuuDungeonsKillCount Auto
GlobalVariable Property aaaKimachuuDungeonsQuotaCount Auto
GlobalVariable Property aaaKimachuuDungeonsGoNextArea Auto
GlobalVariable Property aaaKimachuuDungeonsNFFFollowerMove Auto
GlobalVariable Property aaaKimachuuDungeonsRewards Auto
Message Property aaaKimachuuDungeonsGoNextMes Auto
ObjectReference Property objRestMarker Auto
Quest Property DialogueFollower Auto

Event OnDeath(Actor akKiller)
	aaaKimachuuDungeonsKillCount.Mod(1)
	If aaaKimachuuDungeonsKillCount.GetValue() >= aaaKimachuuDungeonsQuotaCount.GetValue()
		aaaKimachuuDungeonsGoNextArea.SetValue(1)
		aaaKimachuuDungeonsKillCount.SetValue(0)
		aaaKimachuuDungeonsQuotaCount.SetValue(0)
		aaaKimachuuDungeonsGoNextMes.Show()
		If aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 10 || aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 20 || aaaKimachuuDungeonsCurrentHierarchy.GetValue() == 30
			Utility.Wait(3.0)
			aaaKimachuuDungeonsRewards.SetValue(1)
			Game.GetPlayer().MoveTo(objRestMarker)
			followerMoveFunction(objRestMarker)
		EndIf
	EndIf
	Self.Disable(True)
	Self.Delete()
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