autogo.inc - Walks you from point A to point B

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot.

Moderator: MacroQuest Developers

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

autogo.inc - Walks you from point A to point B

Post by Mckorr » Mon Jan 26, 2004 3:52 pm

A very basic movement routine with obstacle avoidance. If you hit something you back up and strafe left or right and try again. Usage is

Code: Select all

/call Goto X,Y

Code: Select all

Sub goto

  /declare Xcur global
  /declare Ycur global
  /declare ThereYet global

  :GoToPoint
   /varset ThereYet 0
   /face loc @Param1,@Param0

         | If we are not within melee range then make sure we are on autorun
         /if n $distance(@Param1,@Param0)>15 /sendkey down up

         | Current Loc
         /varset Xcur $char(x)
         /varset Ycur $char(y)

         | Obstacle routine if stuck
         /delay 1
         /if @Xcur==$char(x) /if @Ycur==$char(y) /call Obstacle

         | End movement when near to point.
         /if n $distance(@Param1,@Param0)<5 {
            /sendkey up up
            /varset ThereYet 1
         }

          /delay 0
   /if @ThereYet!=1 /goto :GoToPoint
   /echo Here we are.
/return


sub Obstacle

   | We appear to be stuck so try and backup and strafe sideways
   /sendkey up up
   /sendkey down down
   /delay 2
   /sendkey up down
   /sendkey down ctrl
   /if n $rand(99)>50 {
      /sendkey down right
   } else {
      /sendkey down left
   }
   /delay 3
   /sendkey up right
   /sendkey up left
   /sendkey up ctrl
   /sendkey down up
/return

bob_the_builder
a hill giant
a hill giant
Posts: 275
Joined: Tue Jul 22, 2003 1:22 pm

Post by bob_the_builder » Mon Mar 01, 2004 10:44 pm

Suggest clearing variables:

Code: Select all

   /echo Here we are. 
[color=red]   /zapvars[/color]
/return 
I believe that it only clears the variables defined in the include?
I was having issues with multiple /call goto X,Y until I added the /zapvars.

Hope this is correct.

Bob