Page 1 of 1

Ламбер

Posted: 2018-01-15 07:29:37
by vertijok2000
помогите с этим скриптом он автоламбер и жутко тупит если можно зделать по координатам типа как на мининг типа вот так

Code: Select all

   Walker(0000,001,0)
   doMineTree()
   Walker(0000,002,0)
   doMineTree()
   Walker(0000,003,0)
   doMineTree()

Code: Select all

var hatchet = "0x0F43"
sub searchTree()
   var i, x, y, t, stp, max_search = 24 ; ???????????? ????????? ??? ????????? ?????????.
   var cx = uo.getX()
   var cy = uo.getY()
   for i = 1 to max_search
      for x =-i to i
         stp = 1
         if not i == abs( x ) then
            stp = abs( i ) * 2
         endif
         for y = -i to i step stp
            if NOT uo.getGlobal( 't:' + str( x + cx ) + "," + str( y + cy ) ) == "empty" then
               t = IsTreeTile( x + cx, y + cy )
               if not t == false then
                  uo.setGlobal( "tree_x", str( x + cx ) )
                  uo.setGlobal( "tree_y", str( y + cy ) )
                  uo.setGlobal( "tree_t", str( t ) )
                  return false
               else
                  uo.setGlobal( 't:' + str( x + cx ) + "," + str( y + cy ), 'empty' )
               endif
            endif
         next
      next
   next
   uo.print( "Found no tree, exit." )
   uo.exec( "terminate main" )
   return false
endsub
sub main()
   searchTree()
   doMineTree()
endsub
Sub doMineTree()
   var x, y, t, w
   repeat
      x = val( uo.getGlobal( "tree_x" ) )
      y = val( uo.getGlobal( "tree_y" ) )
      t = val( uo.getGlobal( "tree_t" ) )
      uo.setGlobal( 't:' + str( x ) + "," + str( y ), "empty" )
      Walker( x, y, "" )
      uo.exec( "exec searchTree" )
      repeat
         if uo.waiting() then
            uo.canceltarget()
         endif
         checklag()
         uo.waittargettile(str(t), str(x), str(y), str(uo.getZ()))
         uo.print(str(t)+ " " +str(x)+ " " +str(y)+ " " +str(uo.getZ()))
         uo.usetype(hatchet)
         w = waitforore()
      until w == 1
      while uo.getGlobal( "tree_x" ) == str( x ) && uo.getGlobal( "tree_y" ) == str( y )
         wait( 100 )
      wend
   until uo.dead()
endsub
Sub deljournal( msg )
   while uo.injournal( msg )
      uo.setjournalline( uo.injournal( msg ) -1, '' )
   wend
endsub
Sub IsTreeTile( x, y )
   var i, tree_count = 22
   DIM tree[ val( str( tree_count ) ) ]
   tree[0] = 3274
   tree[1] = 3275
   tree[2] = 3276
   tree[3] = 3277
   tree[4] = 3280
   tree[5] = 3283
   tree[6] = 3286
   tree[7] = 3289
   tree[8] = 3291
   tree[9] = 3292
   tree[10] = 3294
   tree[11] = 3295
   tree[12] = 3296
   tree[13] = 3299
   tree[14] = 3302
   tree[15] = 3394
   tree[16] = 3395
   tree[17] = 3417
   tree[18] = 3440
   tree[19] = 3461
   tree[20] = 15300
   tree[21] = 15305
   
   #    if checkIgnore( x, y ) then
   #        return false
   #    endif
   
   for i = 0 to tree_count -1
      if uo.privategettile( x, y, -1, tree[i], tree[i] ) then
         return tree[i]
      endif
   next
   return false
endsub
Sub checkIgnore( x, y )
   VAR i, cX, cY
   DIM ignore[5]
   ignore[0] = "1942,414"
   ignore[1] = "1995,331"
   ignore[2] = "1996,330"
   ignore[3] = "1999,331"
   for i=0 to 3
      cX = VAL( left( ignore[i], 4 ) )
      cY = VAL( right( ignore[i], 3 ) )
      if x == cX and y == cY then
         return true
      endif
   next
   return false
endsub
sub waitforore()
   var n
   for n=0 to 50
      if uo.injournal("appears immune|nothing here|reach this|reach that|????????????|nothing there|lumberjacking skill|too far away") then
         return 1
      endif
      if uo.injournal('but fail|You put') then
         return 0
      endif
      wait(500)
   next
   return 1
endsub
sub checklag() 
   repeat 
      UO.DeleteJournal() 
      UO.Click('backpack') 
   until backpack()==1 
endsub 
sub backpack() 
   var n 
   for n=0 to 200 
      if uo.injournal('cliloc# 0xFEA1B') then 
         return 1 
      endif 
      wait(200) 
   next 
endsub
sub hiding()
   if uo.warmode() <> 0 then
      uo.warmode(0)
   endif
   uo.useskill('Hiding')
endsub
Sub Abs(X)
   if X>0 then
      return X
   else
      return (-X)
   end if
end sub
sub Walker(x,y,Target) ########################################## ??????? 
   VAR LastTimer=UO.Timer() 
   VAR distance=1
   VAR i 
   VAR dir,ldir,rdir,key,olddir 
   VAR dx,dy,Exit=0 
   VAR CacheLimit=9,CacheIndex="Text" 
   DIM CacheX[10], CacheY[10] 
   
   CacheX[0]="Test" 
   uo.say('')
   While Exit<>1
      
      If Target<>"" Then 
         dx=UO.GetX(Target)-UO.GetX() 
         dy=UO.GetY(Target)-UO.GetY()         
         If UO.GetDistance(Target)<2 OR LastTimer+100<UO.Timer() Then 
            wait(1000) 
            return
         Endif 
      Else 
         dx=x-UO.GetX() 
         dy=y-UO.GetY() 
         If (Abs(dx)<=distance AND Abs(dy<=distance)) OR LastTimer+100<UO.Timer() Then 
            return 
         Endif 
      Endif    
      If dx<>0 AND dy<>0 Then 
         If dx>0 AND dy>0 Then ; GoSE 
            dir=3 
            ldir=2 
            rdir=4 
            key=40 ; DownArrow 
            olddir=UO.GetDir() 
            If StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) Then 
               If olddir==2 Then ; GoNE 
                  dir=1 
                  ldir=0 
                  rdir=1 
                  key=39 ; RightArrow 
                  While UO.GetDir()<>1 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Else ; GoSW 
                  dir=5 
                  ldir=5 
                  rdir=6 
                  key=37 ; LeftArrow 
                  While UO.GetDir()<>5 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Endif 
            Endif 
         Endif 
         If dx>0 AND dy<0 Then ; GoNE 
            dir=1 
            ldir=0 
            rdir=2 
            key=39 ; RightArrow 
            olddir=UO.GetDir() 
            If StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) Then 
               If olddir==0 Then ; GoWN 
                  dir=7 
                  ldir=6 
                  rdir=7 
                  key=38 ; UpArrow 
                  While UO.GetDir()<>7 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Else ; GoSE 
                  dir=3 
                  ldir=3 
                  rdir=4 
                  key=40 ; DownArrow 
                  While UO.GetDir()<>3 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Endif 
            Endif 
         Endif 
         If dx<0 AND dy>0 Then ; GoSW 
            dir=5 
            ldir=4 
            rdir=6 
            key=37 ; LeftArrow 
            olddir=UO.GetDir() 
            If StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) Then 
               If olddir==6 Then ; GoWN 
                  dir=7 
                  ldir=7 
                  rdir=0 
                  key=38 ; UpArrow 
                  While UO.GetDir()<>7 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Else ; GoSE 
                  dir=3 
                  ldir=2 
                  rdir=3 
                  key=40 ; DownArrow 
                  While UO.GetDir()<>3 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Endif 
            Endif 
         Endif 
         If dx<0 AND dy<0 Then ; GoWN 
            dir=7 
            ldir=6 
            rdir=0 
            key=38 ; UpArrow 
            olddir=UO.GetDir() 
            If StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) Then 
               If olddir==0 Then ; GoNE 
                  dir=1 
                  ldir=1 
                  rdir=2 
                  key=39 ; RightArrow 
                  While UO.GetDir()<>1 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Else ; GoSW 
                  dir=5 
                  ldir=4 
                  rdir=5 
                  key=37 ; LeftArrow 
                  While UO.GetDir()<>5 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Endif 
            Endif 
         Endif 
      Endif 
      If dx<>0 AND dy==0 Then 
         If dx>0 Then ; GoE 
            dir=2 
            key=34 ; PgDown 
            olddir=UO.GetDir() 
            If StepEdit(UO.GetX(),UO.GetY(),dir,key) Then 
               If olddir==2 Then ; GoSE 
                  dir=3 
                  ldir=3 
                  rdir=4 
                  key=40 ; DownArrow 
                  While UO.GetDir()<>3 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Else ; GoNE 
                  dir=1 
                  ldir=1 
                  rdir=0 
                  key=39 ; RightArrow 
                  While UO.GetDir()<>1 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Endif 
            Endif 
         Endif        
         If dx<0 Then ; GoW 
            dir=6 
            key=36 ; Home key 
            olddir=UO.GetDir() 
            If StepEdit(UO.GetX(),UO.GetY(),dir,key) Then 
               If olddir==0 Then ; GoWN 
                  dir=7 
                  ldir=7 
                  rdir=0 
                  key=38 ; UpArrow 
                  While UO.GetDir()<>7 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Else ; GoSW 
                  dir=5 
                  ldir=4 
                  rdir=5 
                  key=37 ; LeftArrow 
                  While UO.GetDir()<>5 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Endif 
            Endif 
         Endif 
      Endif 
      If dx==0 AND dy<>0 Then 
         If dy>0 Then ; GoS 
            dir=4 
            key=35 ; End 
            If StepEdit(UO.GetX(),UO.GetY(),dir,key) Then 
               If olddir==2 Then ; GoSE 
                  dir=3 
                  ldir=2 
                  rdir=3 
                  key=40 ; DownArrow 
                  While UO.GetDir()<>3 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Else ; GoSW 
                  dir=5 
                  ldir=6 
                  rdir=5 
                  key=37 ; LeftArrow 
                  While UO.GetDir()<>5 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Endif 
            Endif 
         Endif     
         If dy<0 Then ;GoN 
            dir=0 
            key=33 ; PgUp 
            olddir=UO.GetDir() 
            If StepEdit(UO.GetX(),UO.GetY(),dir,key) Then 
               If olddir==2 Then ; GoNE 
                  dir=1 
                  ldir=1 
                  rdir=2 
                  key=39 ; RightArrow 
                  While UO.GetDir()<>1 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Else ; GoWN 
                  dir=7 
                  ldir=7 
                  rdir=6 
                  key=38 ; UpArrow 
                  While UO.GetDir()<>7 
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) 
                  Wend 
               Endif 
            Endif 
         Endif 
      Endif 
   Wend 
end sub 
sub StepEdit(x,y,dir,key) 
   VAR walkwait=250
   VAR ErrLevel=0 
   If UO.GetDir()<>dir Then 
      UO.Press(key) 
   Endif 
   UO.Press(key) 
   wait(walkwait) 
   If x==UO.GetX() AND y==UO.GetY() Then 
      CheckLag() 
      If x==UO.GetX() AND y==UO.GetY() Then 
         ;zatik 
         ErrLevel=1 
      Endif 
   Endif 
   Return ErrLevel 
end sub 
sub StepArrow(x,y,dir,ldir,rdir,key) 
   VAR walkwait=250 
   VAR ErrLevel=0 
   If UO.GetDir()<>dir Then
      UO.Press(key)
      wait(walkwait)
      If UO.GetDir()<>dir AND UO.GetDir()<>ldir AND UO.GetDir()<>rdir Then 
         CheckLag()
      Endif
   Endif 
   If UO.GetX()==x AND UO.GetY()==y Then
      UO.Press(key) 
      wait(walkwait)
      If UO.GetDir()==dir AND UO.GetX()==x AND UO.GetY()==y Then 
         CheckLag() 
         If UO.GetDir()==dir AND UO.GetX()==x AND UO.GetY()==y Then 
            ;zatik          
            ErrLevel=1 
         Endif 
      Endif 
   Endif 
   Return ErrLevel 
end sub
вот сам скрипт