Hunting area limited to box or radius?

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

Moderator: MacroQuest Developers

Zelker
a lesser mummy
a lesser mummy
Posts: 38
Joined: Fri Jan 03, 2003 3:01 pm

Hunting area limited to box or radius?

Post by Zelker » Sat Jan 04, 2003 4:00 pm

Greetings,
I was wondering if there is a way to limit the range or area that i am using my hunting macro in? Either by specifing four points of reference to stay within or a radius. For example if i wanted a home point to be a tower w/guards, is there a way to keep me within a certain box or radius of that homepoint? I suppose I could use some really large avoidloc radiuses but that seems to awkward. Any help would be appreciated.
Thanks,
Z

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

Post by L124RD » Sat Jan 04, 2003 8:20 pm

Salutaitons,

Code: Select all

/target radius 300 <mob>

Zelker
a lesser mummy
a lesser mummy
Posts: 38
Joined: Fri Jan 03, 2003 3:01 pm

Post by Zelker » Sun Jan 05, 2003 12:50 am

Thanks for the reply, but I'm not sure where to add this to my code. I'm just getting started and pieced together code mostly from farmpad.mac (thanks arantius2) and some from your ecmonk(again ty). Plus I had to change some of the sub kill target due to the my charecter running around the target and not be able to attack. Also I added some delays which made my char look like he was more real than automated. My original code for trying to stay within a certain radius was to return him to the homepoint after every fight as you can see below(not all that efficient).

Code: Select all

| WKskin.mac 
| farm quality pelts and in NK 
| for making into leather padding 
#include routines.mac 

sub Main 
   /lootn never 
   /alert clear 1  
   /alert add 1 npc lion 
   /press esc 

   :Start 
      /if n $char(ability,"Sense Heading")&0 /doability "Sense Heading"
      /call findTarget 
      /varset v11 $target(id) 
      /delay 10
      /call killTarget 
      /if n $target(id)==$char(id) /goto :Stop 
      /target corpse 
      /if n $target(id)==$v11 /call lootTarget 
      /call gohome
   /goto :Start 

   :Stop 
   /attack off 
   /call autorun 0 
   /lootn always 
/return 

Sub findTarget 
   /target alert 1 nopcnear 60 
   /delay 2 
/return 

Sub killTarget 
   /varset v60 $target(id) 
   /if $v60==0 /return 
   /varset t0 2m 
   /varset v12 1 
   /varset v80 0 
   /face nopredict 

   :Follow 
      /if n $target(id)==$char(id) /return 
      /if "$target(id)"!="$v60" /goto :KillDone 
      /if "$target(name)"~~"corpse" /goto :KillDone 
      /face nopredict 
      /if n $target(distance)&=12 /call autorun 1 
      /if n $target(distance)&13 { 
         /call autorun 0 
         /if $v12==1 { 
            /if n $target(id)==$char(id) /return 
            /call findTarget            |anti-ks code 

            /if "$target(id)"!="$v60" /goto :KillDone 
            /attack on 
            /varset v12 0 
         } 
      } 
      /if n $t0==0 /press esc 
      /varset v51 $char(x) 
      /varset v52 $char(y) 
      |/delay 1 
      /if n $v51==$char(x) /if $v52==$char(y) /call tree $v12 
   /goto :Follow 
    
   :KillDone 
   /sendkey up up 
   /attack off 
   /delay 3 
/return 

Sub Tree 
   /delay 3 
   /if $p0==0 /return 
   /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 
   /varset v80 0 
/return 

Sub lootTarget 
   /delay 2 
   :gotocorpse 
   /if n $target(distance)&10 { 
      /face 
      /sendkey down up 
      /goto :gotocorpse 
   } 
   /sendkey up up 

   /face 
   /loot 
   /delay 10 
    
   /varset v10 0 
   :LootLoop 
      /click left corpse $v10 
      /delay 5 
      /if "$cursor(name)"=="NULL" /goto :LootDone 
      /if "$cursor(name)"~~"quality" { 
         /click left auto  
      } else { 
         /click left destroy 
         /delay 1 
|        /click left 458 420 
|        /delay 1 
      } 
      /varadd v10 1 
   /goto :LootLoop 
    
   :LootDone 
   /delay 3 
   /press esc 
   /delay 2 
/return

sub gohome
/sendkey down up 
:gohomeloop 
  /face loc -2816,-2233
  /if n $distance(-2816,-2233)&12 /goto :gohomeloop 
/sendkey up up 
/return 

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

Post by L124RD » Sun Jan 05, 2003 3:10 am

Salutations,
replace

Code: Select all

sub Main
   /lootn never
   /alert clear 1 
   /alert add 1 npc lion
   /press esc

   :Start 
with

Code: Select all

sub Main
   /lootn never
   /alert clear 1 
   /alert add 1 npc radius 200 lion
   /press esc

   :Start 

User avatar
tuxracer
Esse Quam Videri
Esse Quam Videri
Posts: 165
Joined: Fri Jul 26, 2002 1:01 am

Post by tuxracer » Sun Jan 05, 2003 4:51 am

hi
[url=http://www.studentpeaceaction.org/][img]http://www.studentpeaceaction.org/images/support.gif[/img][/url]

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

Post by L124RD » Sun Jan 05, 2003 5:45 am

Salutations,
tux...

Zelker
a lesser mummy
a lesser mummy
Posts: 38
Joined: Fri Jan 03, 2003 3:01 pm

Post by Zelker » Sun Jan 05, 2003 1:34 pm

grrr... It looks like the radius code works, but now when it doesn't find the target in the radius it finds a players corpse anywhere in the zone and goes to it. I've tried some things to change when it finds a taget and the way it goes to loot the corpses, but I have'nt had any luck yet. Any suggestions?

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

Post by L124RD » Sun Jan 05, 2003 2:49 pm

Salutations,

Code: Select all

Sub findTarget
   /target alert 1 nopcnear 60
   /delay 2
/return 
replace that with this:

Code: Select all

Sub findTarget
    :findtargetloop
       /target alert 1 nopcnear 60
       /delay 0
     /if $target()!=TRUE /goto :findtargetloop
   /delay 2
/return 
I think that should work...

Zelker
a lesser mummy
a lesser mummy
Posts: 38
Joined: Fri Jan 03, 2003 3:01 pm

Post by Zelker » Sun Jan 05, 2003 6:41 pm

Well I did get it to work with some modifications. I had to put a wait in there so the screen wouldn't spam after it didn't find any targets.

Code: Select all

Sub findTarget 
    :findtargetloop 
       /target alert 1 nopcnear 60 
       /delay 0 
     /if $target()!=TRUE /call wait
   /delay 2 
/return

Code: Select all

sub wait
     /delay 10s
     /call findTarget
/return
I added a doablity under killtarget, but I could only get it to work once at the begging of a fight and not repeat itself like I wanted.

Code: Select all

Sub killTarget 
   /varset v60 $target(id) 
   /if $v60==0 /return 
   /varset t0 1m 
   /varset v12 1 
   /varset v80 0 
   /face nopredict 

   :Follow 
      /if n $target(id)==$char(id) /return 
      /if "$target(id)"!="$v60" /goto :KillDone 
      /if "$target(name)"~~"corpse" /goto :KillDone 
      /face fast nopredict 
      /delay 4
      /if n $target(distance)>=12.00 /call autorun 1 
      /if n $target(distance)<12.01 { 
         /call autorun 0 
         /if $v12==1 { 
            /if n $target(id)==$char(id) /return 
            /call findTarget            |anti-ks code 

            /if "$target(id)"!="$v60" /goto :KillDone 
            /attack on 
            [color=red][b]/if n $char(ability,"kick")>0 /doability kick [/b][/color]
            /varset v12 0 
         } 
      } 
      /if n $t0==0 /press esc 
      /varset v51 $char(x) 
      /varset v52 $char(y) 
      |/delay 1 
      /if n $v51==$char(x) /if $v52==$char(y) /call tree $v12 
   /goto :Follow 
    
   :KillDone 
   /sendkey up up 
   /attack off 
   /delay 3 
/return
The more I fiddle with these scripts the more I am learning. I still want to add more to this one. I started with modifying farmpad because it look the easiest to figure out. I will move on to something like the Hunter when understand more. Thanks for your time and assistance.