follow.mac

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

viewsonic
decaying skeleton
decaying skeleton
Posts: 1
Joined: Thu Jan 23, 2003 2:51 am

follow.mac

Post by viewsonic » Thu Jan 23, 2003 2:52 am

Why doesn't this maintain the distance of 17? When I get out of the range of 17 it will move me back, but when i get closer than 17 it doesn't push me back. Can anyone fix it?

#turbo
Sub Main
:Loop
/if n $target(distance)>17 /sendkey down up
/if n $target(distance)<17 /sendkey up up
/face fast
/delay 0
/if "$target()"=="TRUE" /goto :Loop

/return

Ariain
a ghoul
a ghoul
Posts: 88
Joined: Fri Oct 11, 2002 10:35 am

....

Post by Ariain » Thu Jan 23, 2003 3:06 am

Its really late so I have no idea what Iam talking about but

Code: Select all

#turbo 
Sub Main 
:Loop 
/if n $target(distance)>17 /sendkey down up 
/if n $target(distance)<17 /sendkey down down
/face fast 
/delay 0 
/if "$target()"=="TRUE" /goto :Loop 

/return
and whats /face fast do?

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Thu Jan 23, 2003 5:00 am

Salutations,
Faces without turning, so you're instantly facing the correct direction. anyway... the problem with your current macro is that it takes FOREVER to get exactly 17. You want to do something like...

Code: Select all

#define Distance 17

sub main
 /echo Begining to follow $target(name,clean), staying about Distance clicks behind...
 /varset v0 $target(name,clean)
 /fast fast
 :followloop
   /if n $target(distance)<=$calc(Distance-3) /sendkey down down
   /if n $target(distance)>$calc(Distance-3) /sendkey down up

   /if n $target(distance)>=$calc(Distance+3) /sendkey up down
   /if n $target(distance)<$calc(Distance+3) /sendkey up up
   /face
   /delay 0
  /if $target()!=NULL /goto :followloop
  /echo No longer following $v0
/return
Just change Distance to be however far behind. YOu had hard coded it, so I did to, just made it a little easier to change, You can figure out how to make it $p0 I'm sure...[/code]