SUB GoToXY(x,y,prec)
#original (c) ...
#modification 2.00 (c) SerrouS
dim turn[8] ; индекс - ГетДир, значение поворот направо под 45 градусов
turn[0] = 39
turn[1] = 34
turn[2] = 40
turn[3] = 35
turn[4] = 37
turn[5] = 36
turn[6] = 38
turn[7] = 33
dim deltax[8]; индекс - аналогично, значение - изменение координаты при проходе стенки
dim deltay[8]
deltax[0] = 1
deltax[1] = 1
deltax[2] = 1
deltax[3] = 0
deltax[4] = -1
deltax[5] = -1
deltax[6] = -1
deltax[7] = 0
deltay[0] = -1
deltay[1] = 0
deltay[2] = 1
deltay[3] = 1
deltay[4] = 1
deltay[5] = 0
deltay[6] = -1
deltay[7] = -1
var dx,dy
var mx,my ; current coords
var lx = 0, ly = 0, ld = -1 ; last move coords
var pathFind = 0 ; as logical 0 - norm, 1 - block
var ind
var recursInd = 0
var fout = 0
var stepdelay = 300
InitStack()
repeat
mx=UO.GetX()
my=UO.GetY()
; calculating for precision coming
dx = mx - x
If dx < 0 Then
dx = 0 - dx
EndIf ;get ABS diff
dy = my - y
If dy < 0 Then
dy = 0 - dy
EndIf
If dy > dx Then
dx = dy
EndIf
If dx <= prec Then
Return
EndIf
if mx == x and my == y then
return
endif
lx = mx
ly = my
ld = UO.GetDir() ; cause once pressing can only change the direcction
if mx == x and my > y then
UO.Press(33)
endif
if mx == x and my < y then
UO.Press(35)
endif
if mx < x and my == y then
UO.Press(34)
endif
if mx < x and my > y then
UO.Press(39)
endif
if mx < x and my < y then
UO.Press(40)
endif
if mx > x and my == y then
UO.Press(36)
endif
if mx > x and my > y then
UO.Press(38)
endif
if mx > x and my < y then
UO.Press(37)
endif
wait( stepdelay )
if lx == UO.GetX() and ly == UO.GetY() and ld == UO.GetDir() then
; now there is a stop situation
recursInd = 0
repeat
#################################################
ind = ld
fout = 0
repeat ; идем в обход пока не упремся снова или не кончится стена
mx = UO.GetX()
my = UO.GetY()
ld = UO.GetDir()
UO.Press( turn[ ind ] )
wait( stepdelay )
if (UO.GetX() == mx and UO.GetY() == my and ld == UO.GetDir()) then
fout = 1 ; уперлись
else
dx = UO.GetX() - mx
dy = UO.GetY() - my
if deltax[ ind ] == dx and deltay[ ind ] == dy then
fout = 2 ; препятствие пройдено
endif
endif
until fout
if fout == 1 then ; уходим на следующий поворот
recursInd = recursInd + 1
Push( str( ind ) )
;ld = ind
else ; fout == 2
; надо попытаться восстановить контекст из стека, или выйти из обхода
pathFind = 0
if recursInd then ; восстановление
pathFind = 1
recursInd = recursInd - 1
ld = val(Pop()) - 1
if ld == -1 then
ld = 7
endif
UO.Press( turn[ld] )
wait ( stepdelay ) ; в сиду того, что ондо нажатие меняет напрваление
endif
endif
#################################################
until not recursInd and not pathFind
endif
until 0
endsub
#(c)SerrouS
Sub InitStack()
UO.SetGlobal('STACK', '0')
endsub
Sub Push( param )
var chk = val(UO.GetGlobal('STACK')) ; количество элементов в стеке
UO.SetGlobal('STACK',str(chk + 1))
UO.SetGlobal('STACK_'+str(chk), param)
endsub
Sub Pop ()
var chk = val(UO.GetGlobal('STACK')) ; количество элементов в стеке
if chk then
UO.SetGlobal('STACK',str(chk - 1))
return UO.GetGlobal('STACK_'+str(chk - 1))
else
return ''
endif
endsub
Sub CheckLag()
DeleteJournal( 'backpack' )
UO.Click( 'backpack' )
repeat
wait(100)
until UO.InJournal( 'backpack' )
return
end sub
Sub DeleteJournal( string1 )
VAR nom = UO.InJournal( string1 )
If nom > 0 Then
UO.SetJournalLine( Nom - 1, 'string replaced' )
DeleteJournal( string1 )
Endif
endsub
SUB GoTo(o,u,Target)
VAR i
VAR do,du,Exit=0
While Exit<>1
If Target<>"" Then
do=UO.GetX(Target)-UO.GetX()
du=UO.GetY(Target)-UO.GetY()
;
If UO.GetDistance(Target)<2 Then
Exit=1
Endif
Else
do=o-UO.GetX()
du=u-UO.GetY()
If do==0 AND du==0 Then
Exit=1
Endif
Endif
If do<>0 AND du<>0 Then
If do>0 AND do>0 Then
GoSE()
Endif
If do>0 AND du<0 Then
GoNE()
Endif
If do<0 AND du>0 Then
GoSW()
Endif
If do<0 AND du<0 Then
GoWN()
Endif
Endif
If do<>0 AND du==0 Then
If do>0 Then
GoE()
Endif
If do<0 Then
GoW()
Endif
Endif
If do==0 AND du<>0 Then
If du>0 Then
GoS()
Endif
If du<0 Then
GoN()
Endif
Endif
Wend
end sub
Sub GoW()
VAR walkwait=300
VAR o,u,dir=6
VAR key=36 ; Home key
o=UO.GetX()
u=UO.GetY()
while UO.GetDir()<>dir
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
wend
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetX()+1==o Then
return -1
Else
return 1
Endif
end sub
Sub GoN()
VAR walkwait=300
VAR o,u,dir=0
VAR key=33 ; PgUp
o=UO.GetX()
u=UO.GetY()
while UO.GetDir()<>dir
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
wend
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetY()+1==u Then
return -1
Else
return 1
Endif
end sub
Sub GoE()
VAR walkwait=300
VAR o,u,dir=2
VAR key=34 ; PgDown
o=UO.GetX()
u=UO.GetY()
while UO.GetDir()<>dir
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
wend
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetX()-1==o Then
return -1
Else
return 1
Endif
end sub
Sub GoS()
VAR walkwait=300
VAR o,u,dir=4
VAR key=35 ; End
o=UO.GetX()
u=UO.GetY()
while UO.GetDir()<>dir
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
wend
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetY()-1==u Then
return -1
Else
return 1
Endif
end sub
Sub GoWN()
VAR walkwait=300
VAR o,u,dir=7
VAR key=38 ; UpArrow
o=UO.GetX()
u=UO.GetY()
If UO.GetDir()<>dir Then
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
Endif
If UO.GetDir()==dir Then
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetDir()==dir Then
return -1
Else
return UO.GetDir()
Endif
Else
return UO.GetDir()
Endif
end sub
Sub GoNE()
VAR walkwait=300
VAR o,u,dir=1
VAR key=39 ; RightArrow
o=UO.GetX()
u=UO.GetY()
If UO.GetDir()<>dir Then
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
Endif
If UO.GetDir()==dir Then
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetDir()==dir Then
return -1
Else
return UO.GetDir()
Endif
Else
return UO.GetDir()
Endif
end sub
Sub GoSE()
VAR walkwait=300
VAR o,u,dir=3
VAR key=40 ; DownArrow
o=UO.GetX()
u=UO.GetY()
If UO.GetDir()<>dir Then
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
Endif
If UO.GetDir()==dir Then
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetDir()==dir Then
return -1
Else
return UO.GetDir()
Endif
Else
return UO.GetDir()
Endif
end sub
Sub GoSW()
VAR walkwait=300
VAR o,u,dir=5
VAR key=37 ; LeftArrow
o=UO.GetX()
u=UO.GetY()
If UO.GetDir()<>dir Then
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
Endif
If UO.GetDir()==dir Then
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetDir()==dir Then
return -1
Else
return UO.GetDir()
Endif
Else
return UO.GetDir()
Endif
end sub
###############################################START################################################
sub START()
repeat
wait(50)
if uo.count('0x11F6') >= 60 and uo.count('0x0FA0') >= 180 then
craft()
end if
if uo.count('0x170F') then
gotoxy(2383,3391,0)
wait(1000)
CheckLag()
uo.say('pay')
wait(1000)
gotoxy(2383,3397,0)
end if
if uo.count('0x11F6') <= 60 then
kroliki()
end if
if uo.count('0x0FA0') <= 180 then
xlopok()
end if
end if
wait(50)
until uo.dead()
end sub
Sub xlopok()
if uo.count('0x0DF9') <= 29 then
gotoxy(2368,3411,0)
repeat
wait(50)
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
gotoxy(2368,3408,0)
repeat
wait(50)
uo.DeleteJournal()
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
gotoxy(2365,3408,0)
repeat
wait(50)
uo.DeleteJournal()
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
gotoxy(2362,3408,0)
repeat
wait(50)
uo.DeleteJournal()
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
gotoxy(2362,3411,0)
repeat
wait(50)
uo.DeleteJournal()
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
else
gotoxy(2370,3396,0)
repeat
uo.DeleteJournal()
uo.waittargetobject('0x40046DB7')
uo.usetype('0x0DF9')
wait(1300)
uo.waittargetobject('0x4002F7AE')
uo.usetype('0x0DF9')
wait(1300)
until uo.count("0x0FA0") >= 180
end if
end sub
Sub craft()
repeat
uo.DeleteJournal()
uo.waittargettype("0x11F6")
uo.usetype('0x0F9D')
wait(200)
CheckLag()
UO.LDblClick(64,68)
wait(3500)
until uo.count('0x11F6') < 2 or uo.inJournal("You can")
end sub
Sub kroliki()
repeat
gotoxy(2390,3440,0)
kill()
wait(100)
until uo.count("0x11F6") >= 60 or uo.dead()
end sub
SUB kill()
uo.set('finddistance','8')
uo.findtype('0x00CD','-1','ground')
while uo.findcount()>0
goto((uo.getx('findtype')),(uo.gety('findtype')),'finditem')
uo.attack('finditem')
wait(1000)
repeat
wait(50)
while uo.getdistance('finditem') >= 2
wait(100)
goto((uo.getx('findtype')),(uo.gety('findtype')),'finditem')
wend
until uo.gethp('finditem') == 0
while uo.gethp('finditem')<>0
wait(100)
wend
loot()
uo.findtype('0x00CD','-1','ground')
wend
endsub
SUB loot()
var fur = '0x11F6'
var corpse='0x2006'
var waittime=1000
var body,bodypack,i
DIM Loot[4]
Loot[0]=0x11F6
Loot[1]=0x0587
Loot[2]=0x0DF9
Loot[3]=0x0FA0
Loot[4]=0x13F6
uo.set('finddistance','2')
while uo.countonground(corpse)>0
uo.waittargetground('0x2006')
uo.usetype('0x13F6')
wait(1000)
uo.findtype(corpse,'-1','ground')
body=uo.getserial('finditem')
uo.useobject('backpack')
repeat
wait(100)
until uo.getserial('lastcontainer')==uo.getserial('backpack')
uo.useobject(body)
repeat
wait(100)
until uo.getserial('lastcontainer')<>uo.getserial('backpack')
bodypack=uo.getserial('lastcontainer')
For i=0 to 1
repeat
UO.FindType(Loot[i],-1,bodypack)
if UO.GetQuantity('finditem') then
UO.MoveItem('finditem','backpack')
repeat
wait(100)
until uo.containerof('finditem')==uo.getserial('backpack')
wait(waittime)
endif
until uo.findcount()==0
next
uo.ignore(body)
wend
endsub
wait(2000)
end sub