Ходилка для леса....

Anything and all.

Moderators: Murderator+, Murderator

Post Reply
Savage
Expert!
Posts: 1205
Joined: 2004-04-04 11:13:54
Location: Балаково, Саратовская обл.
Contact:

Ходилка для леса....

Post by Savage »

Вот потэстите кому не влом...

Вообщем это ходилка лесная, обходит простые препядствия.
Поставить свои координаты, отбежать куда нить и запустить.

Думаю что усложнять чтоб обходила лабиринт - смысла нету. Все таки она планировалось как часть лумберскрипта. Может кому и пригодится.

Использует стандартные клавиши хождения в клиенте. Стрелки и 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
Antoxa
Posts: 8
Joined: 2004-06-02 10:03:56
Contact:

Post by Antoxa »

хорошая ходилка
1 баг нашёл, исправлю потом, сча время нету (завтра посл экзамен)
короче у меня он застопорился, когда чар шел вверх (NW)
там было неск деревьев.. хотя по другим направлениям он прекрасно ходит
Savage
Expert!
Posts: 1205
Joined: 2004-04-04 11:13:54
Location: Балаково, Саратовская обл.
Contact:

Post by Savage »

На стрелках это клиент сам обходит препядствия
Savage
Expert!
Posts: 1205
Joined: 2004-04-04 11:13:54
Location: Балаково, Саратовская обл.
Contact:

Post by Savage »

В ходе тэстирования немного изменил систему обхода препядствий. Теперь он делает шаг назад и потом шаг в сторону. помогает обойти препядствия стоящие друг к другу углами тайлов. Грубо говоря глухой тупик.


Еще подправил. Теперь вроде действует неплохо.

Code: Select all

#==============================================================
#  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
            If StepSucess==-1 Then
               StepSucess=Go(7,38,300) ;WN - UpArrow
               StepSucess=Go(1,39,300) ;NE - RightArrow
               If StepSucess==-1 Then
                  StepSucess=Go(5,37,300) ;SW - LeftArrow
               Endif
            Endif
         Endif

         If dx>0 AND dy<0 Then
            StepSucess=Go(1,39,300) ;NE - RightArrow
            If StepSucess==-1 Then
               StepSucess=Go(5,37,300) ;SW - LeftArrow
               StepSucess=Go(3,40,300) ;SE - DownArrow
               If StepSucess==-1 Then
                  StepSucess=Go(7,38,300) ;WN - UpArrow
               Endif
            Endif
         Endif

         If dx<0 AND dy>0 Then
            StepSucess=Go(5,37,300) ;SW - LeftArrow
            If StepSucess==-1 Then
               StepSucess=Go(1,39,300) ;NE - RightArrow
               StepSucess=Go(7,38,300) ;WN - UpArrow
               If StepSucess==-1 Then
                  StepSucess=Go(3,40,300) ;SE - DownArrow
               Endif
            Endif
         Endif

         If dx<0 AND dy<0 Then
            StepSucess=Go(7,38,300) ;WN - UpArrow
            If StepSucess==-1 Then
               StepSucess=Go(3,40,300) ;SE - DownArrow
               StepSucess=Go(5,37,300) ;SW - LeftArrow
               If StepSucess==-1 Then
                  StepSucess=Go(1,39,300) ;NE - RightArrow
               Endif
            Endif
         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
               StepSucess=Go(2,34,300) ;E - PgDown
            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
               StepSucess=Go(6,36,300) ;W - Home
            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
               StepSucess=Go(4,35,300) ;S - End
            Endif
         Endif
         
         If dy<0 Then
            StepSucess=Go(0,33,300) ;N - PgUp
            If StepSucess==-1 Then
               StepSucess=Go(1,39,300) ;NE - RightArrow
               If StepSucess==-1 Then
                  StepSucess=Go(7,38,300) ;WN - UpArrow
               Endif
               StepSucess=Go(0,33,300) ;N - PgUp
            Endif
         Endif
      Endif
   Wend
end sub


sub Go(dir,key,walkwait)
   VAR x,y, OldDir

   x=UO.GetX()
   y=UO.GetY()
   OldDir=UO.GetDir()

   If UO.GetDir()<>dir Then
      UO.Press(key)
      wait(walkwait)
      If UO.GetDir()<>dir Then
         CheckLag()
      Endif
   Endif

   UO.Press(key)
   wait(walkwait)

   If x==UO.GetX() AND y==UO.GetY() Then
      CheckLag()
   Endif

   If x==UO.GetX() AND y==UO.GetY() AND OldDir<>UO.GetDir() Then
      UO.Press(key)
      wait(walkwait)
   Endif

   If x==UO.GetX() AND y==UO.GetY() Then
      CheckLag()
   Endif
   
   If x==UO.GetX() AND y==UO.GetY() Then
      UO.Print("Zasada!")
      return -1
   Else
      return 1
   Endif
end sub
dUha
Posts: 13
Joined: 2005-07-06 04:57:14
Contact:

Post by dUha »

Неподскажете как ету ходилку пристрастить к моиму скрипту на ламбер ?

вот кусок скрипта главная часть

Code: Select all

sub main() 
var i

DIM Forest[32]

# ,infotile
Forest[0]   = "3277 2492 567 5" 
Forest[1]   = "3277 2500 567 0"
Forest[2]   = "3299 2508 567 0"
--\\--\\--\\--

while true

    for i=0 to 30
        uo.print("Иду рубать: " + str(i) )
        kTree( Forest[i] )
        RubTree( Forest[i] )
        MakeBoards()

wend
end sub
Don SpiL
Posts: 108
Joined: 2005-05-03 11:51:04
Location: KDK Elite Group (c)
Contact:

Post by Don SpiL »

dUha wrote:Неподскажете как ету ходилку пристрастить к моиму скрипту на ламбер ?

вот кусок скрипта главная часть

Code: Select all

sub main() 
var i

DIM Forest[32]

# ,infotile
Forest[0]   = "3277 2492 567 5" 
Forest[1]   = "3277 2500 567 0"
Forest[2]   = "3299 2508 567 0"
--\\--\\--\\--

while true

    for i=0 to 30
        uo.print("Иду рубать: " + str(i) )
        kTree( Forest[i] )
        RubTree( Forest[i] )
        MakeBoards()

wend
end sub


Из того что ты показал тут тебе ниче не сказать куда его врубать .У тебя kTree( Forest[i] ) вот в ней (я так думаю) и идет вызов ходилки с передачей координат x,y. Кинь этот саб там может и увидим да подскажем =)
dUha
Posts: 13
Joined: 2005-07-06 04:57:14
Contact:

Post by dUha »

Вот тот кусок

Code: Select all

sub kTree( Current_Tree ) 
var User_x, User_y          # Mine Coordinates
var User_old_x, User_old_y
var Tree, TreeX, TreeY      # Tree Coordinates
var Distance                #
var Dx, Dy                  #
var MouseX, MouseY
var Stack_step = 0          # Если тормоза

    uo.print("Current_Tree=" + Current_Tree )
         
#   Tree  = Current_Tree
    TreeX = Current_Tree[5]+ Current_Tree[6]+ Current_Tree[7]+ Current_Tree[8]
    TreeY = Current_Tree[10]+Current_Tree[11]+Current_Tree[12]+Current_Tree[13]
   
     uo.print("TreeX="+TreeX + ", TreeY=" + TreeY )
     

# Rule: Go by attitude then by Latitude,
#       If Stuck - change direction

        User_old_x = 1
        User_old_y = 1
       
    Stack_step = 0                  # reset Stack trying counter
    While Distance > 10
        # Мои кординаты
        User_x = uo.getx()
        User_y = uo.gety()
        uo.print("Я по x="+str(User_x)+", Я по y="+str(User_y) )
       
        # Validate for Dead stop.
        if ( (User_old_x - User_x) == 0 AND (User_old_y - User_y) == 0 ) then
            Stack_step = Stack_step + 1
            if ( Stack_step == 3) then
                Stack_Solving()
            endif   
        else
            Stack_step = 0 
        endif
       
        Dx = val(TreeX) - User_x   
        Dy = val(TreeY) - User_y
        Distance = Dx*Dx + Dy*Dy
        uo.print("По x="+str(Dx)+", По ="+str(Dy)+", Дистанция до дорева= "+str(Distance) )
        MouseX = 320+Dx*21
        MouseY = 238+Dy*21
       
        if (MouseX > 634) then
            MouseX = 634
        endif           

        if (MouseX < 10)  then
            MouseX = 10 
        endif           
        if (MouseY > 475) then
            MouseY = 475
        endif
        if (MouseY < 10)  then
            MouseY = 10 
        endif       
       
        uo.print("MouseY="+ str(MouseX) +", MouseY="+ str(MouseY) )
        UO.RClick( MouseX , MouseY )
        wait(200)
        UO.RDblClick( MouseX , MouseY )
       
        wait(1000)
        User_old_x = User_x
        User_old_y = User_y
    wend


     wait(1000)
end sub
dUha
Posts: 13
Joined: 2005-07-06 04:57:14
Contact:

Post by dUha »

Так что кто-то поможет???
Chico
Posts: 46
Joined: 2005-05-02 17:37:12
Contact:

Post by Chico »

Вот эта процедура для разрезания тайла по пробелам
у тебя это 2 и 3 позиция

Sub GetNumb(C,I)
var J,T,K
J=0
K=1
While K>0
J=J+1
If (Mid(C,J,1)==' ') Or (J>=Len(C)-1) Then
If I==0 Then
T=Val(Left(C,J))
Else
T=GetNumb(Right(C,Len(C)-J-1),I-1)
EndIf
K=0
EndIf
wend
UO.Print(T)
return T
endsub
А вот так можно разрезать и получить X Y куда идти
X=GetNumb(Forest,2)
X=GetNumb(Forest,3)
А потом уже вызывать в нужном месте ходилку
dUha
Posts: 13
Joined: 2005-07-06 04:57:14
Contact:

Post by dUha »

Ну ето все хорошо но я еше не настока знаю скрипты инжекта чтоб ето самому переписать
немог бы ктото мне в етом помочь ??
или зделать дополнительный скрипт который будет переделывать параметры чтобы оно переделывало переменные под ето скрипт ???

Заранее весьма блогодарен
dUha
Posts: 13
Joined: 2005-07-06 04:57:14
Contact:

Post by dUha »

Так что нет такого скриптера кто поможет ??
Post Reply