;Fireball thing - Timed script (For Death Crypt Dungeon, Map 1140)

Map = #PARAM1
XPos = #PARAM2
YPos = #PARAM3

UserID = 0

CreateEffect(4, 1500, 500, #DIR_DOWN, Map,XPos,YPos,0, 0, 1)

Step = 0
While Step < 3
	Step=Step+1
	UserID = GetUserAtXY(Map,XPos,YPos+Step)
	If UserID > 0
		Damage = Floor(GetUserMaxHP(UserID) * 0.25)
		If Damage < 10
			Damage = 10
		EndIf
		If GetUserHP(UserID) < Floor(Damage-1)
			Damage=Damage+5
			SendMessageToAll("* "+GetUserName(UserID)+" has been killed by a projectile!",#MSG_CRITICAL)
		EndIf
		DamageUser(UserID,Damage)
		
		GoTo DIE
	EndIf
	
	TileType = GetTileType(Map,XPos,YPos+Step)
	If TileType = #TILE_WALL
		GoTo DIE
	ElseIf TileType = #TILE_DOOR
		GoTo DIE
	ElseIf TileType = #TILE_GODONLY
		GoTo DIE
	EndIf
Wend

Timer(593,2000,Map,XPos,YPos+Step)

GoTo END
Label DIE
CreateEffect(18, 1000, 0, #DIR_DOWN, Map,XPos,YPos+Step,0, 0, 1)
If GetMapPlayerCount(Map) > 0
	Timer(593,Random(3000,5000),Map,XPos,3)
Else
	RemoveItem(1140,461)
EndIf
Label END

Continue = 1