Вообщем это ходилка лесная, обходит простые препядствия.
Поставить свои координаты, отбежать куда нить и запустить.
Думаю что усложнять чтоб обходила лабиринт - смысла нету. Все таки она планировалось как часть лумберскрипта. Может кому и пригодится.
Использует стандартные клавиши хождения в клиенте. Стрелки и Home,End,PgUp,PgDown.
sub tst()
WalkN(2102,2082,'')
end sub
Code: Select all
#==============================================================
# CheckLag() - click on backpack and awaiting "backpack"
# message in journal.
#
# Journal has been deleted!!!
#--------------------------------------------------------------
sub CheckLag()
UO.DeleteJournal()
UO.Click('backpack')
Repeat
wait(500)
Until UO.InJournal('backpack')
end sub
#==============================================================
# WalkN(X,Y,Serial) - char is walking by dX and dY step
# sub using Home, End, PgUp, PgDown keys
# d'not rebind this key from default action!
# serial - Serial of target or "" - string
# walkwait - delay after keypress
# Example:
# WalkN(2080,2113,'') - go to coordinates
# WalkN(0,0,'0x12345678') - go to target position
#--------------------------------------------------------------
sub WalkN(x,y,Target)
VAR i,StepSucess
VAR dx,dy,Exit=0
While Exit<>1
If Target<>"" Then
dx=UO.GetX(Target)-UO.GetX()
dy=UO.GetY(Target)-UO.GetY()
; UO.Print("Target locked!")
If UO.GetDistance(Target)<2 Then
Exit=1
Endif
Else
dx=x-UO.GetX()
dy=y-UO.GetY()
If dx==0 AND dy==0 Then
Exit=1
Endif
Endif
If dx<>0 AND dy<>0 Then
If dx>0 AND dy>0 Then
StepSucess=Go(3,40,300) ;SE - DownArrow
Endif
If dx>0 AND dy<0 Then
StepSucess=Go(1,39,300) ;NE - RightArrow
Endif
If dx<0 AND dy>0 Then
StepSucess=Go(5,37,300) ;SW - LeftArrow
Endif
If dx<0 AND dy<0 Then
StepSucess=Go(7,38,300) ;WN - UpArrow
Endif
Endif
If dx<>0 AND dy==0 Then
If dx>0 Then
StepSucess=Go(2,34,300) ;E - PgDown
If StepSucess==-1 Then
StepSucess=Go(3,40,300) ;SE - DownArrow
If StepSucess==-1 Then
StepSucess=Go(1,39,300) ;NE - RightArrow
Endif
Endif
Endif
If dx<0 Then
StepSucess=Go(6,36,300) ;W - Home
If StepSucess==-1 Then
StepSucess=Go(7,38,300) ;WN - UpArrow
If StepSucess==-1 Then
StepSucess=Go(5,37,300) ;SW - LeftArrow
Endif
Endif
Endif
Endif
If dx==0 AND dy<>0 Then
If dy>0 Then
StepSucess=Go(4,35,300) ;S - End
If StepSucess==-1 Then
StepSucess=Go(3,40,300) ;SE - DownArrow
If StepSucess==-1 Then
StepSucess=Go(5,37,300) ;SW - LeftArrow
Endif
Endif
Endif
If dy<0 Then
StepSucess=Go(0,33,300) ;N - PgUp
If StepSucess==-1 Then
StepSucess=Go(7,38,300) ;WN - UpArrow
If StepSucess==-1 Then
StepSucess=Go(1,39,300) ;NE - RightArrow
Endif
Endif
Endif
Endif
Wend
end sub
sub Go(dir,key,walkwait)
VAR x,y
x=UO.GetX()
y=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 x==UO.GetX() AND y==UO.GetY() Then
CheckLag()
Endif
If x==UO.GetX() AND y==UO.GetY() Then
return -1
Else
return 1
Endif
end sub