;Death Dungeon - Event
If GetUserFlag(0,11)=0
	SetUserFlag(0,11,1)
	SendMessageToMap(#PARAM1,"Stay alive until the end of the event!", #MSG_EMOTE)
	WavesRemaining=5
	OpenDoor(#PARAM1,8,15)
	OpenDoor(#PARAM1,9,15)
	OpenDoor(#PARAM1,10,15)
	OpenDoor(#PARAM1,11,15)
	OpenDoor(#PARAM1,12,15)
	Goto Spawn
Endif

WavesRemaining=#PARAM2

Label Spawn
SendMessageToMap(#PARAM1,"Monsters have been released!", #MSG_CRITICAL)
SendMessageToMap(#PARAM1,"There are "+WavesRemaining+" waves of monsters remaining.", #MSG_SERVER)
Monster1=Random(56,58)
Monster2=Random(56,58)
Monster3=Random(56,58)
Monster4=Random(56,58)
Monster5=Random(56,58)
OpenDoor(#PARAM1,8,1)
OpenDoor(#PARAM1,9,1)
OpenDoor(#PARAM1,10,1)
OpenDoor(#PARAM1,11,1)
OpenDoor(#PARAM1,12,1)
SpawnMonster(#PARAM1,Monster1,8,2)
SpawnMonster(#PARAM1,Monster2,9,2)
SpawnMonster(#PARAM1,Monster3,10,2)
SpawnMonster(#PARAM1,Monster4,11,2)
SpawnMonster(#PARAM1,Monster5,12,2)
If WavesRemaining=0
	SetUserFlag(0,10,0)
	SetUserFlag(0,11,2)
	DamageMonster(#PARAM1,8,8000)
	DamageMonster(#PARAM1,9,8000)
	DamageMonster(#PARAM1,10,8000)
	DamageMonster(#PARAM1,11,8000)
	DamageMonster(#PARAM1,12,8000)
	DamageMonster(#PARAM1,13,8000)
	DamageMonster(#PARAM1,14,8000)
	DamageMonster(#PARAM1,15,8000)
	SendMessageToAll("Death Dungeon has ended. "+GetMapPlayerCount(#PARAM1)+" players survived!", #MSG_SERVER)
Endif
Goto End


Label End


Continue = 1