BaseDamage=GetUserFlag(#PARAM1,24)

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 GetUserAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3)=#PARAM1
		Goto Continue
	Endif
	If GetMapType(GetUserFlag(#PARAM1,20))<>#MAPTYPE_FRIENDLY
		If GetMapType(GetUserFlag(#PARAM1,20))=#MAPTYPE_NEUTRAL
			If GetUserGuild(#PARAM1)="0"
				Goto End
			ElseIf GetUserGuild(GetUserAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3))="0"
				Goto End
			EndIf
		EndIf
		If GetUserGuild(#PARAM1)="0"
			UserDamageUser(#PARAM1,BaseDamage,GetUserAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3))
		Else
			If GetUserGuild(#PARAM1)<>GetUserGuild(GetUserAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3))
				UserDamageUser(#PARAM1,BaseDamage,GetUserAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3))
			Endif
		Endif
	Endif
	Goto End
Elseif GetMonsterAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3)>-1
	SetMonsterTarget(GetUserFlag(#PARAM1,20),GetMonsterAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3),#PARAM1)
	UserDamageMonster(GetMonsterAtXY(GetUserFlag(#PARAM1,20),#PARAM2,#PARAM3),BaseDamage,#PARAM1)
	Goto End
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_DOOR
	Goto End
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_WALL
	Goto End
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_NPC
	Goto End
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_GODONLY
	Goto End
Elseif GetTileType(GetUserFlag(#PARAM1,20),NextX,NextY)=#TILE_WARP
	Goto End
Endif

Goto Continue

Label Continue
Timer(402,35,#PARAM1,NextX,NextY)
Goto End

Label End


Continue = 1