;Oisvo Deep "Master of the Deep" death script
;and warping point

FireSprite = 29
MasterOfTheDeep = 48
FireStone = 92

If #MAPID = 369
	GoTo WARP_IN
ElseIf #MAPID = 370
	GoTo WARP_OUT
EndIf

GoTo END
Label WARP_IN

If HasItem(#USERID, FireStone) = 1
	GoTo END
EndIf

FirstWarper = 1

Y = 10
While Y < 17
	X = 9
	While X < 16
		If GetUserAtXY(370, X, Y) <> 0
			If GetUserAtXY(370, X, Y) <> #USERID
				FirstWarper = 0
			EndIf
		EndIf
		X = X + 1
	Wend
	Y = Y + 1
Wend

If FirstWarper = 1
	i = 0
	While i < 16
		DamageMonster(370, i, 9999)
		i = i + 1
	Wend
	
	SendMessageToUser(#USERID,"The Master Of the Deep whispers, 'Welcome "+GetUserName(#USERID)+", my minions shall feast on your corpse!'",#MSG_SAY)
	
	SpawnMonster(370, FireSprite, 9, 10)
	SpawnMonster(370, FireSprite, 15, 16)
	SpawnMonster(370, MasterOfTheDeep, 12, 10)
	SpawnMonster(370, FireSprite, 9, 16)
	SpawnMonster(370, FireSprite, 15, 10)
	
	i = 0
	While i < 16
		SetMonsterTarget(370, i, #USERID)
		i = i + 1
	Wend

EndIf

WarpUser(#USERID, 370, #XPOS, #YPOS)

GoTo END

Label WARP_OUT

Y = 10
While Y < 17
	X = 9
	While X < 16
		UserID = GetUserAtXY(370, X, Y)
		If UserID <> 0
			WarpUser(UserID, 369, X, Y)
		EndIf
		X = X + 1
	Wend
	Y = Y + 1
Wend

If IsInvFull(#USERID) = 1
	SendMessageToUser(#USERID,"You don"t have anymore room in your inventory.",#MSG_TELL)
Else
	GiveItem(#USERID, FireStone)
EndIf

Label END

Continue = 1