ходилка до цели

Ask for help

Moderators: Murderator+, Murderator

Post Reply
Deathclaw
Posts: 31
Joined: 2005-01-21 15:45:19

ходилка до цели

Post by Deathclaw »

Помогите пожалуйста, нашёл скрипт который вроде как сам должен подходить к цели, но работает как-то странно, если идёт то уходит вроде тока на WN вне зависимости где цель, помогите поменять условия так что бы чар держался на растоянии удара от цели. спасибо

Code: Select all

sub main()
WalkN(0,0,'lasttarget')
end sub

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()
         If UO.GetDistance(Target)<1 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 Target<>"" AND uo.GetDistance(Target)<=1 then         
         Exit=1
      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 

sub CheckLag()
   UO.DeleteJournal()
   UO.Click('backpack')
   repeat
      wait(500)
   until UO.InJournal('cliloc# 0x9ED5')
end sub 
Scripts Writer
Posts: 2259
Joined: 2005-04-19 18:00:29
Location: Московская область
Contact:

Post by Scripts Writer »

Запускать:

Code: Select all

sub GoGo()
  uo.AddObject('npc')
  while uo.Targeting()
    wait(100)
  wend
  Go_To(uo.GetX('npc'),uo.GetY('npc')) 
end sub
Вставить в этом же файле:

Code: Select all


sub Step(x,y,mx,my,forstep) 
  if uo.GetX('self') <> x then 
    if uo.GetY('self') <> y then 
      if mx<0 then 
        if my<0 then 
          uo.Press(40) 
          wait(forstep) 
        else 
          uo.Press(39) 
          wait(forstep) 
        end if 
      else 
        if my<0 then 
          uo.Press(37) 
          wait(forstep) 
        else 
          uo.Press(38) 
          wait(forstep) 
        end if 
      end if 
    else 
      if mx<0 then 
        uo.Press(34) 
        wait(forstep) 
      else 
        uo.Press(36) 
        wait(forstep) 
      end if 
    end if 
  else 
    if my<0 then 
      uo.Press(35) 
      wait(forstep) 
    else 
      uo.Press(33) 
      wait(forstep) 
    end if 
  end if 
end sub 

sub Go_To(x,y) 
var mx,my,fx,fy 
  var xx=x 
  var yy=y 
  var DistX=0 
  var DistY=1 
  var forstep=300 
  
  repeat 
    mx=uo.GetX('self')-x 
    my=uo.GetY('self')-y 
    fx=mx+x 
    fy=my+y 
    Step(xx,yy,mx,my,forstep) 
  until x==fx+DistX && y==fy+DistY || x==fx-DistX && y==fy+DistY || x==fx+DistX && y==fy-DistY || x==fx-DistX && y==fy-DistY || x==fx && y==fy 
end sub
Post Reply