Damage=Floor(Floor(GetUserAgility(#PARAM1)+GetUserAgilityBonus(#PARAM1))*0.35+Floor(GetUserStrength(#PARAM1)+GetUserStrengthBonus(#PARAM1))*0.15)+GetItemFlag1(#PARAM4)

If GetUserFlag(#PARAM1,19)=1
	NextX=#PARAM2
	NextY=#PARAM3-1
Elseif GetUserFlag(#PARAM1,19)=2
	NextX=#PARAM2
	NextY=#PARAM3+1
Elseif GetUserFlag(#PARAM1,19)=3
	NextX=#PARAM2+1
	NextY=#PARAM3
Elseif GetUserFlag(#PARAM1,19)=4
	NextX=#PARAM2-1
	NextY=#PARAM3
Endif

If NextX>21
	Goto End
Elseif NextX<-1
	Goto End
Elseif NextY>21
	Goto End
Elseif NextY<-1
	Goto End
Endif

If GetUserAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3)>0
	If GetMapType(GetUserFlag(#PARAM1,20))<>#MAPTYPE_FRIENDLY
		If GetUserAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3)<>#PARAM1
			If CanAttack(GetUserFlag(#PARAM1,20),#PARAM1,GetUserAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3)) = 1
				UserDamageUser(#PARAM1,Damage,GetUserAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3))
			Endif
		Endif
	Endif
	SpawnItem(GetUserFlag(#PARAM1,20),#PARAM4,#PARAM2,#PARAM3)
	Goto End
Elseif GetMonsterAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3)>-1
	UserDamageMonster(GetMonsterAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3),Damage,#PARAM1)
	SpawnItem(GetUserFlag(#PARAM1,20),#PARAM4,#PARAM2,#PARAM3)
	Goto End
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_DOOR
	Goto Stop
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_WALL
	Goto Stop
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_NPC
	Goto Stop
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_GODONLY
	Goto Stop
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_WARP
	Goto Stop
Endif

Goto Continue

Label Stop
SpawnItem(GetUserFlag(#PARAM1,20),#PARAM4,#PARAM2,#PARAM3)
Goto End

Label Continue
Timer5(209,35,#PARAM1,NextX,NextY,#PARAM4,0)
Goto End2

Label End

Label End2

Continue = 1