### Контейнеры ###
VAR Meshok	= '0x0E76';	тип мешка
VAR Deed	= '0x14EF';	свиток ресурсов
VAR body	= '0x2006';	труп (не разделанный)
##################

### Инструменты ###
VAR Dagger	= '0x0F51';	кинжал (резка трупа)
VAR Scissors	= '0x0F9E';	ножницы
##################

### Сырье ###
VAR hides	= '0x1078';	шкура животного
VAR leather	= '0x1067';	готовая кожа
##################

### Вспомогательные константы ###
VAR lootwait	= 50;		пауза
VAR printcolour	= '1069';	цвет сообщений
##################

### Переменные ###
VAR MeshSer, d, LastTimer, timemove
VAR Type, TType, Type1, Type2, Color, SourceContainer, TargetContainer
VAR corpse, a, hair, reg, colhides
##################

Sub autostart()
	Lootrunning()
	UO.filterspeech('clear')
	UO.filterspeech('add','[Surprize ! Fast loot detected!]')	; сообщение при фастлуте.
	UO.filterspeech('on')
end sub

Sub REZ()
	UO.Set('quiet','1')
	uo.set('finddistance', '3')
	;uo.ignorereset()
	uo.findtype(body, -1, 'ground')
	if uo.findcount() and Uo.GetDistance( 'finditem' ) < 3  then
		var x = uo.GetGraphic(uo.ObjAtLayer('Rhand'))
		var y = uo.GetGraphic(uo.ObjAtLayer('Lhand'))
		uo.warmode(0)
		wait(500)
		corpse = uo.getSerial("finditem")
		UO.WaitTargetObject(corpse)
		UO.UseType(dagger)
		wait(500)
		uo.Equipt('Rhand',x)
		uo.Equipt('Lhand',y) 
		if x <> uo.GetGraphic(uo.ObjAtLayer('Rhand')) or y <> uo.GetGraphic(uo.ObjAtLayer('Lhand')) then
			UO.UseType(x)
			wait(100)
			UO.UseType(y)
			wait(100)
		endif
		Loot()
		uo.warmode(1)
	endif
	UO.Set('quiet','0')
end sub

sub Lootrunning()
	uo.setGlobal('running',1)
end sub

Sub Loot()
	;uo.ignorereset()
	DIM G[7]
	G[1] = '0x0EED'		; деньги
	G[2] = '0x0E76'		; мешки
	G[3] = '0x09AA'		; пандоры
	G[4] = '0x1BFB'		; болты
	G[5] = '0x0F3F'		; стрелы
	G[6] = '0x1087'		; серьги
	G[7] = '0x108A'		; кольца
	UO.Set('quiet','1')
	if val(uo.getGlobal('running'))==1 then
		uo.setGlobal('running',2)
		uo.set('finddistance', '3')
		corpse = '0x00000000'
		corpse = findcorps()
		if corpse<>'0xffffffff' and corpse<>'0x00000000' then
			IF uo.findcount() and Uo.GetDistance( 'finditem' ) <= 4 then
				uo.deletejournal()
				uo.useobject(corpse)
				wait(300)
				if NOT uo.injournal("You can't do it here") then
					GrabLoot(corpse)
					IgnorHair(corpse)
					;Ignor(corpse)
					PUTLoot('-1', '-1', corpse, 'backpack','','','')
				endif
				UO.Hide(corpse)
				UO.Ignore(corpse)
			endif
		else
			For a=1 to 7
				PUTLoot(G[a], '-1', 'ground', 'backpack',30,150,0)
			next
		endif
		Scissors()
		uo.setGlobal('running',1)
	endif
	UO.Set('quiet','0')
end sub

Sub findcorps()
	DIM body[2]
	body[1] = '0x0ECA'	; кости
	body[2] = '0x2006'	; тело
	For a = 1 to 2
		UO.FindType(body[a], -1, 'ground')
		if UO.FindCount() then
			return uo.getSerial('finditem')
		endif
	next
end sub

Sub IgnorHair(corpse)
	For hair = 0x203B to 0x204D
		UO.FindType(hair, -1, corpse)
		if UO.FindCount() then
			UO.Ignore('finditem')
		endif
	next
end sub

Sub Ignor(corpse)
	For reg = 0xF7A to 0xF7B
		UO.FindType(reg, -1, corpse)
		if UO.FindCount() then
			UO.Ignore('finditem')
		endif
	next
	For reg = 0xF84 to 0xF86
		UO.FindType(reg, -1, corpse)
		if UO.FindCount() then
			UO.Ignore('finditem')
		endif
	next
	For reg = 0xF88 to 0xF88
		UO.FindType(reg, -1, corpse)
		if UO.FindCount() then
			UO.Ignore('finditem')
		endif
	next
	For reg = 0xF8C to 0xF8D
		UO.FindType(reg, -1, corpse)
		if UO.FindCount() then
			UO.Ignore('finditem')
		endif
	next
end sub

Sub GrabLoot(corps)
	var pack = 'backpack'
	;uo.charprint(printcolour,'лутим типы')
	PUTLoot('0x1869', '0', corps, pack,'','','')		; ЭНЧАНТ шарики
	PUTLoot('0x09AA', '0x0834', corps, pack,'','','')	; Пандора 10 Лв.
	PUTLoot('0x09AA', '0x0833', corps, pack,'','','')	; Пандора 9 Лв.
	PUTLoot('0x09AA', '0x0832', corps, pack,'','','')	; Пандора 8 Лв.
	PUTLoot('0x09AA', '0x08EA', corps, pack,'','','')	; Пандора 7 Лв.
	PUTLoot('0x09AA', '0x08C1', corps, pack,'','','')	; Пандора 6 Лв.
	PUTLoot('0x13B1', '0x099F', corps, pack,'150','170','0'); Exc.Rangers Bow
	PUTLoot('0x13B1', '0x05D8', corps, pack,'150','160','0'); Rangers bow
	PUTLoot('0x0A3E', '0', corps, pack,'160','170','0')	; шкатулка
	PUTLoot(-1, '0x086C', corps, pack,'','','')		; хантер вещи
	PUTLoot(-1, '0x099F', corps, pack,'','','')		; ренжер вещи
	PUTLoot(-1, '0x0358', corps, pack,'','','')		; рат вещи
	PUTLoot2(0x1869, 0x1870, '-1', corps, pack,'','','')	; шарики
	PUTLoot('0x0EED', '0', corps, pack,'','','')		; золото
	PUTLoot2(0x1E88, 0x1E89, '-1', corps, pack,'','','')	; мясо драконов и демонов
	PUTLoot2(0x1E8E, 0x1E8F, '-1', corps, pack,'','','')	; жаренное мясо драконов и демонов
	PUTLoot('0x09B5', '0', corps, pack,'','','')		; змеиные яйца
	PUTLoot('0x0EE3', '0', corps, pack,'','','')		; паутинка
	PUTLoot2(0x1085, 0x108b, '-1', corps, pack,'','','')	; бижутерия
	PUTLoot2(0x1f05, 0x1f0a, '-1', corps, pack,'','','')	; бижутерия
	PUTLoot2(0xf0f, 0xf30, '-1', corps, pack,'','','')	; камни
	PUTLoot2(0x1f5d, 0x1f6c, '0', corps, pack,'','','')	; scroll 7-8
	PUTLoot(-1, '0x0991', corps, pack,'','','')		; руины
	PUTLoot('0x9aa', '-1', corps, pack,10,170,0)		; пандоры
	PUTLoot(-1, '0x0482', corps, pack,'','','')		; серебрянные вещи
end sub

Sub Scissors()
	If UO.Hidden() and UO.Count ( Scissors ) > 0 Then
		UO.FindType(hides, -1, 'backpack')
		While UO.FindCount()
			colhides = uo.getColor('finditem')
			UO.WaitTargetObject('finditem')
			uo.usetype( Scissors )
			wait(300)
			UO.FindType(leather, colhides, 'backpack')
			if UO.FindCount() then
				UO.MoveItem('finditem', 0, 'backpack', 30, 150, 0)
				wait(300)
			endif
			UO.FindType(hides, -1, 'backpack')
		wend
	EndIf
end sub

Sub PUTLoot2(Type1, Type2, Color, SourceContainer, TargetContainer,X,Y,Z)
	;uo.ignorereset()
	for TType = Type1 to Type2
		PUTLoot(TType, Color, SourceContainer, TargetContainer,X,Y,Z)
	next
end sub

Sub PUTLoot(Type, Color, SourceContainer, TargetContainer,X,Y,Z)
	;uo.ignorereset()
	UO.FindType(Type, Color, SourceContainer)
	while UO.FindCount()
		if (TargetContainer=='ground') then
			uo.MoveItem('finditem',0,TargetContainer,uo.GetX('self'),uo.GetY('self'),uo.GetZ('self'))
		else
			timemove=UO.Timer()
			while UO.ContainerOf( UO.GetSerial('finditem') )==SourceContainer && timemove+20>UO.Timer() 
				uo.MoveItem('finditem',0,TargetContainer,X,Y,Z)
				wait(lootwait)
			wend
		end if
		UO.FindType(Type, Color, SourceContainer)
	wend
end sub

Sub DeleteJournal(msg)
	While UO.InJournal(msg)
		UO.SetJournalLine(UO.InJournal(msg) - 1,'')
	wend
end sub

Sub checklag()
	DeleteJournal("ackpack")
	UO.Click("backpack")
	repeat
		wait(100)
	until UO.InJournal("ackpack")
end sub