Page 1 of 1

Go To Place

Posted: 2004-05-05 02:17:02
by Fonzy
I need a script with a function that, given X and Y coordinates of the world, makes the character move to them. Of course the problem is avoid the obstacles. Anyone has something like that?

Posted: 2004-05-06 11:11:49
by Lord Ruslan Nightmare
There is two ways:
1) Difficult, complex script with intelligence obstacle-avoiding system.
Also large 2d array with passability may be used...
2) Use bulid-in client pathfinding. Use special formula to unproject world's tile coords. to uo window coords and make a right double click (of course, this will allow you to go only to tile you see on your screen)

It is good idea to combine thease methods (if script fails to find the way to destination point - it will calculate some waypoints and use pathfinding to go across them (if desination tile is not on your screen, otherwise it will just go to destination)).

Posted: 2004-05-07 09:02:41
by Spirito
like this?

Code: Select all

sub Move(x,y) 
  var cx,cy,e=0,dir=1,M="-40-231-657" 
  while dir<>0 
     cx=uo.getx() 
     cy=uo.gety() 
     dir=(cy<y)+2*(cy>y)+4*(cx<x)+8*(cx>x) 
     if dir<>0 then 
        MoveK(val(M[dir])) 
        if cx==uo.getx() && cy==uo.gety() then 
           e=e+1 
           if e>=2 then 
              stack_solving()
           endif 
           if e==40 then 
              return 0
           endif 
          else 
             e=0 
        endif 
     endif 
  wend 
  return 1 
endsub 

sub MoveK(dir) 
  var x,y,time,Key="06172435" 
  if UO.GetDir()<>dir then 
     UO.Press(val(Key[dir])+33) 
     time=500 
     if UO.GetDir()<>dir then 
        if time==0 then 
           return 0 
        endif 
        wait(5) 
        time=time-5 
     endif 
  endif 
  x=UO.GetX() 
  y=UO.GetY() 
  time=500 
  UO.Press(val(Key[dir])+33) 
  while x==UO.GetX() && y==UO.GetY() && time>0 
     time=time-5 
     wait(5) 
  wend 
  return time>0    
end sub 

sub stack_solving()
        uo.print("Son Incastrato!Stuck Solving Scelgo Te!")
        uo.press(36)
        uo.press(36)
        uo.press(36)
        uo.press(35)
        uo.press(35)
end sub

Posted: 2004-05-08 18:45:05
by Fonzy
I'm interested in what u wrote, but i think the code has been modified by the forum.. it's unusable. Could you send me it via mail? It's robyfonzypubbl@yahoo.it. Thanks.