;Timed script, Death Crypt

If GetMapPlayerCount(1189) = 0
	SetUserFlag(0,37,0)
	GoTo END
EndIf
If GetUserFlag(0,37) = 0
	GoTo END
EndIf

Target=GetMonsterTarget(1189,8)

Rand = Random(0,7)
SendMessageToUser(GetUserID("comrade"),"Random: "+Rand,#MSG_TELL)

If Rand < 3
	;Attack target
	CreateEffect(8,500,0,#DIR_RIGHT,GetUserMap(Target),GetUserX(Target),GetUserY(Target),0,0,0)
	Damage=35
	If GetUserHP(Target) < Damage
		SendMessageToAll("* "+GetUserName(Target)+" was killed by The Liche!",#MSG_CRITICAL)
	EndIf
	
	DamageUser(Target,Damage)
ElseIf Rand = 3
	;Summon monsters, if they aren't already summoned
	If GetUserFlag(0,37) = 1
		SendMessageToMap(1189,"The Liche calls forth his servants!", #MSG_CRITICAL)
		SetUserFlag(0,37,3)
		
		;Spawn monsters
		SpawnMonster(1189, 197, 5, 10)
		SpawnMonster(1189, 197, 15, 10)
		
		;Start monster skill timers
		Timer(626,10000,9,0,0)
		Timer(626,3000,10,0,0)
	EndIf
ElseIf Rand = 4
	;Unequip armor from target
ElseIf Rand = 5
	;AoE blast
EndIf

Timer(625,8000,0,0,0)

Label END

Continue = 1