ScriptName aaaKimachuuDungeonsSpawner Extends ObjectReference

ActorBase Property aaaKimachuuDungeonsLV10Boss Auto
ActorBase Property aaaKimachuuDungeonsLV20Boss Auto
ActorBase Property aaaKimachuuDungeonsLV30Boss Auto
GlobalVariable Property aaaKimachuuDungeonsCurrentHierarchy Auto
GlobalVariable Property aaaKimachuuDungeonsQuotaCount Auto
ActorBase Property aaaKimachuuDungeonsLV01Actor Auto
ActorBase Property aaaKimachuuDungeonsLV06Actor Auto
ActorBase Property aaaKimachuuDungeonsLV11Actor Auto
ActorBase Property aaaKimachuuDungeonsLV16Actor Auto
ActorBase Property aaaKimachuuDungeonsLV21Actor Auto
ActorBase Property aaaKimachuuDungeonsLV26Actor Auto
ObjectReference Property objSpawnerMarker Auto

Int spawnCount

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

	Self.Disable()
	If aaaKimachuuDungeonsCurrentHierarchy.GetValue() >= 30
		spawnCount = 1
		spawnBossFunction(spawnCount, aaaKimachuuDungeonsLV30Boss)
	ElseIf aaaKimachuuDungeonsCurrentHierarchy.GetValue() >= 26
		spawnCount = Utility.RandomInt(4, 5)
		spawnEnemyFunction(spawnCount, aaaKimachuuDungeonsLV26Actor)
	ElseIf aaaKimachuuDungeonsCurrentHierarchy.GetValue() >= 21
		spawnCount = Utility.RandomInt(3, 5)
		spawnEnemyFunction(spawnCount, aaaKimachuuDungeonsLV21Actor)
	ElseIf aaaKimachuuDungeonsCurrentHierarchy.GetValue() >= 20
		spawnCount = 2
		spawnBossFunction(spawnCount, aaaKimachuuDungeonsLV20Boss)
	ElseIf aaaKimachuuDungeonsCurrentHierarchy.GetValue() >= 16
		spawnCount = Utility.RandomInt(5, 6)
		spawnEnemyFunction(spawnCount, aaaKimachuuDungeonsLV16Actor)
	ElseIf aaaKimachuuDungeonsCurrentHierarchy.GetValue() >= 11
		spawnCount = Utility.RandomInt(5, 6)
		spawnEnemyFunction(spawnCount, aaaKimachuuDungeonsLV11Actor)
	ElseIf aaaKimachuuDungeonsCurrentHierarchy.GetValue() >= 10
		spawnCount = 2
		spawnBossFunction(spawnCount, aaaKimachuuDungeonsLV10Boss)
	ElseIf aaaKimachuuDungeonsCurrentHierarchy.GetValue() >= 6
		spawnCount = Utility.RandomInt(3, 5)
		spawnEnemyFunction(spawnCount, aaaKimachuuDungeonsLV06Actor)
	ElseIf aaaKimachuuDungeonsCurrentHierarchy.GetValue() >= 1
		spawnCount = Utility.RandomInt(3, 4)
		spawnEnemyFunction(spawnCount, aaaKimachuuDungeonsLV01Actor)
	EndIf
EndEvent

Function spawnEnemyFunction(Int i01, ActorBase act01)
	aaaKimachuuDungeonsQuotaCount.SetValue(i01)
	While i01 > 0
		i01 -= 1
		objSpawnerMarker.PlaceActorAtMe(act01, 4)
		Utility.Wait(0.5)
	EndWhile
EndFunction

Function spawnBossFunction(Int i01, ActorBase act01)
	aaaKimachuuDungeonsQuotaCount.SetValue(i01)
	While i01 > 0
		i01 -= 1
		objSpawnerMarker.PlaceActorAtMe(act01, 3)
		Utility.Wait(0.1)
	EndWhile
EndFunction