;'Entrance Key' - item pickup script

If #XPOS <> 12
	GoTo END
EndIf
If #YPOS <> 8
	GoTo END
EndIf
If GetUserFlag(#USERID,45) = 321
	GoTo END
EndIf
SetUserFlag(#USERID,45,321)

Damage = Floor(GetUserMaxHP(#USERID) / 2)
If Damage > GetUserHP(#USERID)
	Damage = Floor(GetUserHP(#USERID) / 2)
EndIf

CreateEffect(6, 1000, 0, #DIR_DOWN, #MAPID,#XPOS,#YPOS,0, 0, 1)
DamageUser(#USERID, Damage)

;Unspawn old monsters
i=0
While i < 16
	UnspawnMonster(1141,195)
	i=i+1
Wend

;Spawn new monsters
x = 9
While x < 16
	SpawnMonster(1140,195,x,11)
	CreateEffect(6, 1000, 0, #DIR_DOWN, 1140, x,11,0, 0, 1)
	x=x+1
Wend

;Set new monsters' target
i=8
While i < 16
	SetMonsterTarget(1140,i,#USERID)
	i=i+1
Wend

Label END

Continue = 1