;Timed script, Death Crypt

;Script not in use at this time
;GoTo END

If GetMapPlayerCount(1189) = 0
	GoTo END
EndIf
If GetUserFlag(0,37) = 2
	If #PARAM1 = 10
		GoTo END
	EndIf
EndIf
If GetUserFlag(0,37) = 1
	If #PARAM1 = 9
		GoTo END
	EndIf
EndIf
If GetUserFlag(0,37) = 0
	GoTo END
EndIf

;GetMonsterType doesn't return 0, when the spawned monster dies...
;If GetMonsterType(1189,#PARAM1) = 0
;	GoTo END
;EndIf

Target = GetMonsterTarget(1189,#PARAM1)

Rand = Random(0,5)
If Rand = 0
	;Heal the boss
	DamageMonster(1189,8,-150)
	CreateEffect(6,500,0,#DIR_RIGHT,1189,GetMonsterX(1189,8),GetMonsterY(1189,8),0,0,0)
ElseIf Rand < 5
	;Do damage here
	CreateEffect(6,500,0,#DIR_RIGHT,1189,GetUserX(Target),GetUserY(Target),0,0,0)
	Damage=15
	If GetUserHP(Target) < Damage
		SendMessageToAll("* "+GetUserName(Target)+" was killed by a Crypt Horror!",#MSG_CRITICAL)
	EndIf
	
	DamageUser(Target,Damage)
EndIf


Timer(626,15000,#PARAM1,0,0)

Label END

Continue = 1