;WizX=Random(0,20)
;WizY=Random(0,20)

WizardDead=Random(1,5)
DamageType=Random(1,3)
WizardReturn=Random(0,100000)
WizardPortal=Random(1,3)

If DamageType=1
	Damage=Random(1,25)
	SendMessageToMap(#MAPID,"The Wizard does "+Damage+" fire damage to "+GetUserName(#USERID)+"!", #MSG_CRITICAL)
	If GetUserHP(#USERID)<Damage
		SendMessageToAll("* "+GetUserName(#USERID)+" has been killed by a Wizard!", #MSG_CRITICAL)
	Endif
	DamageUser(#USERID,Damage)
	CreateEffect(0,600,0,#DIR_UP,GetUserMap(#USERID),GetUserX(#USERID),GetUserY(#USERID),0,0,0)
Endif

If DamageType=2
	Damage=Random(1,50)
	SendMessageToMap(#MAPID,"The Wizard does "+Damage+" electrical damage to "+GetUserName(#USERID)+"!", #MSG_CRITICAL)
	If GetUserHP(#USERID)<Damage
		SendMessageToAll("* "+GetUserName(#USERID)+" has been killed by a Wizard!", #MSG_CRITICAL)
	Endif
	DamageUser(#USERID,Damage)
	CreateEffect(2,600,0,#DIR_UP,GetUserMap(#USERID),GetUserX(#USERID),GetUserY(#USERID),0,0,0)
Endif

If DamageType=3
	Damage=Random(1,100)
	SendMessageToMap(#MAPID,"The Wizard does "+Damage+" magical damage to "+GetUserName(#USERID)+"!", #MSG_CRITICAL)
	If GetUserHP(#USERID)<Damage
		SendMessageToAll("* "+GetUserName(#USERID)+" has been killed by a Wizard!", #MSG_CRITICAL)
	Endif
	DamageUser(#USERID,Damage)
	CreateEffect(7,600,0,#DIR_UP,GetUserMap(#USERID),GetUserX(#USERID),GetUserY(#USERID),0,0,0)
Endif

If WizardDead=1
	SpawnMonster(#MAPID,253,#XPOS,#YPOS)
Else
	WizardVanish=Random(1,3)

	If WizardVanish=1
		Timer(191,WizardReturn,#MAPID,#XPOS,#YPOS)
		CreateEffect(1,600,0,#DIR_UP,#MAPID,#XPOS,#YPOS,0,0,0)
		SendMessageToMap(#MAPID,"The Wizard vanishes!", #MSG_EMOTE)
		If WizardPortal=1
			SetUserFlag(#USERID,15,#MAPID)
			Timer(192,Random(1000,30000),#USERID,GetUserX(#USERID),GetUserY(#USERID))
			SendMessageToMap(#MAPID,"The Wizard takes "+GetUserName(#USERID)+" with him!", #MSG_EMOTE)
			WarpUser(#USERID,579,Random(0,20),Random(0,20))
			CreateEffect(1,600,0,#DIR_UP,GetUserMap(#USERID),GetUserX(#USERID),GetUserY(#USERID),0,0,0)
		Endif
	Else
		SpawnMonster(#MAPID,254,#XPOS,#YPOS)
	Endif
Endif

;SpawnMonster(579,254,WizX,WizY)
;CreateEffect(1,600,0,#DIR_UP,579,WizX,WizY,0,0,0)

Continue = 1
