;Death Crypt script trigger, on map 1137

User1 = GetUserAtXY(1137,6,16)
User2 = GetUserAtXY(1137,14,16)

If User1 < 1
	GoTo END
EndIf
If User2 < 1
	GoTo END
EndIf
If GetUserFlag(User1,45) = 777
	GoTo END
EndIf
If GetUserFlag(User2,45) = 777
	GoTo END
EndIf

SetUserFlag(User1,45,777)
SetUserFlag(User2,45,777)

SendMessageToMap(1137," - Switches triggered - ",#MSG_SAY)
RemoveItem(1137,463)
SpawnItem(1137,463,10,3)

i=0
While i < 16
	UnspawnMonster(1137,195)
	i=i+1
Wend

SpawnMonster(1137,195,2,14)
SpawnMonster(1137,195,2,15)
SpawnMonster(1137,195,2,16)
SpawnMonster(1137,195,2,17)
i=8
While i < 12
	SetMonsterTarget(1137,i,User1)
	i=i+1
Wend


SpawnMonster(1137,195,18,14)
SpawnMonster(1137,195,18,15)
SpawnMonster(1137,195,18,16)
SpawnMonster(1137,195,18,17)
i=12
While i < 16
	SetMonsterTarget(1137,i,User2)
	i=i+1
Wend

;RAISING THE WATER:
SetUserFlag(0,35,0)

userID = GetNextMapUser(0,1139)
While userID <> 0
	WarpUser(userID,1138,#XPOS,#YPOS)
	userID = GetNextMapUser(userID,1139)
Wend


SendMessageToMap(1139,"The water was raised.",#MSG_EMOTE)
SendMessageToMap(1143,"The water was raised.",#MSG_EMOTE)

Y = 5
While Y < 16
	X = 4
	While X < 17
		UserID = GetUserAtXY(1143,X,Y)
		If UserID > 0
			SendMessageToAll("* "+GetUserName(UserID)+" has drowned!",#MSG_CRITICAL)
			DamageUser(UserID,9999)
		EndIf
		X=X+1
	Wend
	Y=Y+1
Wend
Y = 3
While Y < 5
	X = 9
	While X < 12
		UserID = GetUserAtXY(1143,X,Y)
		If UserID > 0
			SendMessageToAll("* "+GetUserName(UserID)+" has drowned!",#MSG_CRITICAL)
			DamageUser(UserID,9999)
		EndIf
		X=X+1
	Wend
	Y=Y+1
Wend


userID = GetNextMapUser(0,1139)
While userID <> 0
	WarpUser(userID,1138,#XPOS,#YPOS)
	userID = GetNextMapUser(userID,1139)
Wend

userID = GetNextMapUser(0,1143)
While userID <> 0
	WarpUser(userID,1142,#XPOS,#YPOS)
	userID = GetNextMapUser(userID,1143)
Wend

Label END

Continue = 1