Hunter.mac - Hunting script --- Updated

Macro depository for macros written before the user variable changes that broke all of them.

Moderator: MacroQuest Developers

Macromancer
orc pawn
orc pawn
Posts: 11
Joined: Thu Oct 31, 2002 8:34 pm

might anyone be so kind..

Post by Macromancer » Mon Nov 04, 2002 11:44 pm

as to help me with the loot syntax..? I can't get it to work..(i need to loot ruined, and pelts of any quality.. )

Code: Select all

| This sub sets up the list loot we wish to keep. 
| 
sub SetLootList 

/varset a(1,0) "silk" 
/varset a(1,1) "Ruined"
/varset a(1,2) "Quality"

| Put number of items in list here. 
/varset LootTotal 5 

/return 
is in eastcommons.mac

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Tue Nov 05, 2002 2:10 am

might want to change your loot total to 3

Code: Select all

| Put number of items in list here. 
/varset LootTotal 3

Dazzler
decaying skeleton
decaying skeleton
Posts: 5
Joined: Sat Nov 09, 2002 9:45 am

Post by Dazzler » Sat Nov 09, 2002 9:49 am

My hunter.mac is crashing me to desktop. I've look thru countless posts and cant find a resolution. Perhaps I am missing something?

The script runs fun up untill it gets a target. The split secnd it targets something it crashs me to desktop. Any ideas greatly apreciated.

User avatar
Fippy
a snow griffon
a snow griffon
Posts: 499
Joined: Tue Jul 16, 2002 10:42 am

Post by Fippy » Sat Nov 09, 2002 10:48 am

Can you try just doing a simple test.

do all this in the eqclient

first type

/alert clear 1

then

/alert add 1 <name of a mob nearby>

then

/target alert 1

if you have no problems with that then post back with the last few lines in the hunter.mac.log.
Fippy

This is my girl. But Rizwank had her first :-)
[img]http://www.btinternet.com/~artanor/images/fairy_bounce09.gif[/img]

Dazzler
decaying skeleton
decaying skeleton
Posts: 5
Joined: Sat Nov 09, 2002 9:45 am

Post by Dazzler » Sat Nov 09, 2002 11:34 am

/alert add 1
/target alert 1

Both worked no problem and got the target. Here is the script I am useing...

Code: Select all

| Hunter.mac 
| 
| The ultimate melee class.zone farming script 
| 
#turbo 
#include routines.mac 
#include Stormfeather.mac 

#define LootTotal v50 
#define KSRadius v51 
#define NoLOS v38 
#define TooFarAway v39 
#define MyTarget v40 
#define MyHeading v41 
#define TargetHeading v42 
#define HeadingDelta v43 
#define TargetDead v44 
#define MyXLoc v46 
#define MyYLoc v47 
#define KSCheck v49 
#define TargetLooted v52 
#define LootSlot v54 
#define CheckLoot v55 
#define AttackedMe v56 
#define BackHome v57 
#define HomeY v58 
#define HomeX v59 
#define Attacker v60 


#event CannotSee "You cannot see your target" 
#event TooFar "Your target is too far away" 
#event HitsYou "YOU for" 

sub Main 

/zapvars 
   /mqlog Hunter script v 20021007a started 

   | Set up Alert lists 
   /call SetAlerts 

   | Set up List of Loot to keep 
   /call SetLootList 

   | Set Home Point 
   /call SetHomePoint 

   | Set KS radius below. The script will not target a mob if a PC is within this radius of it. 
   |/varset KSRadius 60 
    
   | Set Loot nodrop 
   |/lootn never 
    
| 
| First off put clean up any open windows and make sure modifier keys are reset 
   /press esc 
   /press esc 
   /press esc 
   /press esc 
   /press alt 
   /press shift 
   /press ctrl 

| Start of main Loop 
| 
:Start 

   | RestUp 
   /call RestUp 

   | Aquire nearest target to attack 
   /call GetTarget 

   | Advance 
   /call Advance 

   | Loot 
   /call Loot 

   /delay 0 
/goto :Start 

/return 



| RestUp 
sub RestUp 
    
   | Run to Home Base if needed 
   /if n $char(hp,pct)>50 /goto :NoRest 

   |Low on HP's running home    
   /mqlog HPs at $char(hp,pct) heading home 
   /call HomeBase 
    
   | If we didnt make it home we dont want to rest 
   /if n $return!=1 { 
      /mqlog Didnt make it home aborting run home 
      /goto :NoRest 
   } 
    
   | Make sure we are sat down. 
   /mqlog Reached home base resting 
   /sit on 
   :Rest 
      | Check if something has aggroed and attack it if it has. 
      /if n $AttackedMe==1 { 
         /mqlog aggroed whilst sitting 
         /sit off 
         /goto :NoRest 
      } 
      /delay 5 
      /if $char(ability,"Mend")>0 /doability "Mend" 
   /if n $char(hp,pct)<100 /goto :Rest 
   /mqlog Hps at $char(hp,pct) Off hunting again 
} 
:NoRest 
/stand 
/return 

| Acquire Target subroutine 
sub GetTarget 
   :Acquire 
      /if AttackedMe==1 { 
         /mqlog Targeted "$v13" who jumped me 
         /target "$v13" 
         /varset AttackedMe 0 
      } else /if "$alert(1)"=="TRUE" { 
         /target npc alert 1 notnearalert 4 nopcnear $KSRadius 
         /mqlog Targeted $target(name) range $target(distance) on alert list 1 
      } else /if "$alert(2)"=="TRUE" { 
         /target npc alert 2 notnearalert 4 nopcnear $KSRadius 
         /mqlog Targeted $target(name) range $target(distance) on alert list 2 
      } else { 
         /target npc alert 3 notnearalert 4 nopcnear $KSRadius 
         /mqlog Targeted $target(name) range $target(distance) on alert list 3 
      } 
      /varset MyTarget $target(id) 
      /varset TargetDead 0 
      /doevents 
      /delay 0 
   /if n $target(id)==0 /goto :Acquire 
/return 

| Advance to mob subroutine 
sub Advance 

   :Engage 

         |Process any events 
         /doevents 
          
         |Work on sense heading skill 
         /if $char(ability,"Sense Heading")>0 /doability "Sense Heading"          
          
         | Turn towards target 
         /face nopredict 
          
         | If we are not within melee range then make sure we are on autorun 
         /if n $target(distance)>15 /call autorun2 1 
          
         | If we are still a distance away from target search for a closer one 
         /if n $target(distance)>200 { 
            /call GetTarget 
         } 
          

         | Save our current x,y loc 
         /varset MyXLoc $char(x) 
         /varset MyYLoc $char(y) 
         | Wait a then check loc again if we are on same spot call the obstacle routine to try and get around it 
         /delay 1 
         /if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle 
          
         | If we are within melee range stop running check Target again for other players engaged and attack if all OK. 
         /if n $target(distance)<15 { 
            /mqlog In melee range 
            /call autorun2 0 
            /varset KSCheck $target(id) 
            /call GetTarget 
            /if n $KSCheck==$MyTarget /call Melee 
            } 
            
         /call checkobstacles 
         /delay 0 
   /if n $TargetDead!=1 /goto :Engage 
   /mqlog Target is dead 
   /target id $MyTarget 
/return 

| Melee with mob subroutine 
sub Melee 

   /mqlog Started melee 
   /attack on 

   :Combat 
      | Check events 
      /doevents flush 
      
      | Make sure were staring the critter out 
      /face nopredict 
      
      | If we are too far away close in 
      /if n $target(distance)>15 { 
         /face nopredict 
         /delay 2 
         /call autorun2 1 
         /mqlog $target(distance,nopredict) from $target(name) 
      } 
        
      | If we are in melee range stop running 
      /if n $target(distance)<15 { 
         /call autorun2 0 
         /delay 2 
         /face fast nopredict 
         /mqlog In melee with $target(name) at $target(hp,pct) I am at $char(hp,pct) 
      } 
      
      /doevents 
      
      | If we cannot see the target backup and face it again. 
      /if n $NoLOS==1 { 
         /mqlog Cannot see 
         /face nopredict 
         /sendkey down down 
         /delay 4 
         /sendkey up down 
         /varset NoLOS 0 
         /delay 3 
      } 
      
      | If we are too far away close in 
      /if n $TooFarAway==1 { 
         /face nopredict 
         /delay 2 
         /call autorun2 1 
         /varset TooFarAway 0 
      } 
      
      /if $char(ability,"Round Kick")>0 /doability "Round Kick" 
      /if $char(ability,"Kick")>0 /doability "Kick" 
      /if $char(ability,"Mend")>0 /doability "Mend" 
      /if $char(ability,"Slam")>0 /doability "Slam" 
      
      
      | Check if target is dead or we have lost it 
      /if n $target(id)==0 /varset TargetDead 1 

      | Check for any obstacles we are supposed to avoid 
      /call checkobstacles 
      
      | If target is still alive keep at it 
      /if n $TargetDead!=1 /goto :Combat 
      
      | Target is dead so stop attacking 
      /attack off 
      
      /varset AttackedMe 0 
      
/return 

| Loot mob 
sub Loot 
    
   /varset TargetLooted 0 

   :Approach 
    
      /mqlog Advancing to corpse 
      |Process any events 
      /doevents 
      
      | Check we still have a target if not dont try to  loot it 
      /if n $target(id)==0 /goto :Looted 
                  
      | Turn towards target 
      /face nopredict 
      
      | If we are within range loot corpse 
      /if n $target(distance)<15 { 
         /call autorun2 0 
         /loot 
         /goto :AtTarget 
         } 

      | If we are not within range then make sure we are on autorun 
      /if n $target(distance)>12 /call autorun2 1 

      | Save our current x,y loc 
      /varset MyXLoc $char(x) 
      /varset MyYLoc $char(y) 
      
      | Wait and then check loc again if we are on same spot call the obstacle routine to try and get around it 
      /delay 1 
      /if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle 

      | Check for any obstacles we are supposed to avoid 
      /call checkobstacles 
      
      /delay 0 
   /goto :Approach 
   :AtTarget          
    
   |Begin Looting 
    
   /mqlog starting to loot 
   /delay 10 
    
   | Cycle through each loot slot 
   /varset LootSlot 0 
   :LootLoop 
      /delay 1 
      /click left corpse $LootSlot 
      /delay 3 
      /if "$cursor()"!="TRUE" /goto :NoLoot 

      | Scan list of loot to keep and auto drop it if we are keeping it. 
      /varset CheckLoot 0 
      :GetLoot 
         /if "$cursor(name)"~~"$a(1,$CheckLoot)" { 
            /mqlog  Looted $cursor(name) 
            /click left auto 
            /goto :Looted 
         } 
          
         /varadd CheckLoot 1 
         /delay 0 
         /if n $CheckLoot<$LootTotal /goto :GetLoot 
          
         | Checked list of loot to keep with no matches so destroy (must turn on fast destroy) 
         /mqlog Destroying $cursor(name) 
         /click left destroy 
          
         :Looted 
         /varadd LootSlot 1 
      /delay 0 
      /goto :LootLoop 
   :NoLoot        
      
   /delay 3 
   /press esc 
   /delay 2 
/return 



sub HomeBase 

   /mqlog Heading Home 

   :RunHome 

         |Process any events 
         /doevents 
          
         |Work on sense heading skill 
         /if $char(ability,"Sense Heading")>0 /doability "Sense Heading"          
          
         |Check if we have aggroed something and stop running home if we have 
         /if n $AttackedMe==1 { 
            /mqlog $v13 Atacked be on the way home 
            /return 
         } 
          
         | Turn towards target 
         /face loc $HomeY,$HomeX 
          
         | If we are not within melee range then make sure we are on autorun 
         /if n $distance($HomeY,$HomeX)>15 /call autorun2 1 

         | Save our current x,y loc 
         /varset MyXLoc $char(x) 
         /varset MyYLoc $char(y) 

         | Wait a then check loc again if we are on same spot call the obstacle routine to try and get around it 
         /delay 1 
         /if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle 
          
         | Check for any obstacles we are supposed to avoid 
         /call checkobstacles 
          
         | If we are within melee range stop running check Target again for other players engaged and attack if all OK. 
         /if n $distance($HomeY,$HomeX)<15 { 
            /mqlog Reached Home 
            /call autorun2 0 
            /varset BackHome 1 
         } 
            
          /delay 0 
   /if n $BackHome!=1 /goto :RunHome 
   /varset BackHome 0 

/return 1 

sub Obstacle 

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


sub AvoidLoc 
| Pass in 3 numbers first two are the Y and X locs of the point to avoid third one is the distance you want to keep from it. 
| This sub will check if you are within the distance specified and turn you away from the loc and run you until you are the correct 
| distance away. Too many calls to this sub will slow your main loop down badly so keep the areas large and infrequent for best results. 
| i.e. if there are a few huts together set a loc and radius that will cover the whole area rather than each individual hut. 

/if n $distance($p0,$p1)>$p2 /goto :OK 
    /mqlog close to $p0 $p1 
    /if n $calc($heading($p0,$p1)-$char(heading)<0 { 
       /face heading $calc($heading($p0,$p1)-95) 
    } else { 
       /face heading $calc($heading($p0,$p1)+95) 
    } 
    :RunAway 
    /call autorun2 1 
    /delay 1 
    /if n $distance($p0,$p1)<$p2 /goto :RunAway 
:OK 
  
/return 

Sub AutoRun2 
   /if $p0==1 /sendkey down up 
   /if $p0==0 /sendkey up up 
/return 


sub Event_TooFar 
   /varset TooFarAway 1 
/return 

sub Event_CannotSee 
   /varset NoLOS 1 
/return 

sub Event_HitsYou 
   /if "$combat"=="TRUE" /goto :StillEngaged 
    /varset AttackedMe 1 
    /varset v10 "$left($calc($instr("YOU","$p0")-1),"$p0")" 
    /varset v11 $strlen("$v10") 
    :WalkString 
       /if "$mid($v11,1,"$v10")"==" " { 
          /varset v12 $v11 
          /goto :DoneWalkString 
      } 
    /varsub v11 1 
    /delay 0 
    /goto :WalkString 
    :DoneWalkString 
   /varset Attacker "$left($v12,"$v10")" 
   /mqlog Being Hit by $Attacker 
   :StillEngaged 
/return 
Its essential a cut and past from this thread. I changed the eastcommons.mac to suite my needs depending on what I am doing...

Code: Select all

| Stormfeather.mac 
| 
| Zone specific Info for Hunter Script 
#define HomeY v58 
#define HomeX v59 

| This Sub sets up the alert lists for the mobs we want to hunt 
| 
sub SetAlerts 
| Setup Alerts for the most important mobs here (rare) 
| 
   /alert clear 1 
   /alert add 1 npc radius 800 Stormfeather 
   
   /alert clear 2
   /alert add 2 npc radius 100 cougar

/return 


| This sub sets up the list loot we wish to keep. 
| 
sub SetLootList 

   /varset a(1,0) "map" 
   /varset a(1,1) "piece" 
  
   | Put number of items in list here. 
   /varset LootTotal 2 

/return 



| This sub sets our home point we return to if low on health 
| 
sub SetHomePoint    

   | Set home to be entrance of tunnel 
   /varset HomeX 781.00, 
   /varset HomeY 5720.00 
   /mqlog Home Point is $HomeX, $HomeY 

/return 
Again essentially a cut and past from a different posted script. Changed the mob names to match the mob I am hunting. The problem...

/macro Hunter
Macros starts and runs up until it gets a cougar on target. The split second the cougar gets on target, crash to desktop. Only thing in the log is that I targeted the cougar. Did I miss a post about an update or something? Wrong offset somewhere maybe? Seems the problem is related to the "Go and Kill Target" portion, but I can't figure out where. I'm not very good at programming, but I know enough to change the key points to suite my needs. Any help is greatly apreciated.[/code]

User avatar
Fippy
a snow griffon
a snow griffon
Posts: 499
Joined: Tue Jul 16, 2002 10:42 am

Post by Fippy » Sat Nov 09, 2002 11:40 am

Make sure your running the latest version

http://macroquest2.com/IRC-latest.zip
Fippy

This is my girl. But Rizwank had her first :-)
[img]http://www.btinternet.com/~artanor/images/fairy_bounce09.gif[/img]

Dazzler
decaying skeleton
decaying skeleton
Posts: 5
Joined: Sat Nov 09, 2002 9:45 am

Post by Dazzler » Sat Nov 09, 2002 3:52 pm

Ok so I thought I had the latest version. Well, I did a fast test to see if it would crash me and it didnt. I will work on the scripting and testing further till I get it right. Thanks Fippy, guess I was'nt going a little crazy. Just needed to update... again hehhe

Dazzler
decaying skeleton
decaying skeleton
Posts: 5
Joined: Sat Nov 09, 2002 9:45 am

Post by Dazzler » Sat Nov 09, 2002 4:44 pm

Seems the whole script is foobared for me. Atleast it dousnt crash me to desktop anymore. Now once it gets a target it moves in that direction for a second then Ends the Macro. I have no clue wahts going on with it so I am gonna try and write my own. Be back in an hour with more questions hehhe

Dazzler
decaying skeleton
decaying skeleton
Posts: 5
Joined: Sat Nov 09, 2002 9:45 am

Post by Dazzler » Sat Nov 09, 2002 8:18 pm

Well I got it to work finally. Thanks Fippy for suplying the core of the script. I took a lot from your script and managed to tweak it. Works like a champ now.

Malachi
a hill giant
a hill giant
Posts: 227
Joined: Tue Nov 19, 2002 1:29 am
Contact:

Post by Malachi » Tue Nov 19, 2002 1:39 am

Here's my trouble.

Mostly just for fun, I started a monkey in Qeynos. I start the script, and I'm flooded with "There are no " around here".

YES, I did modify the eastcommons.mac file, even made a qeynos.mac file, although I commented out all the avoidance locs. Eventually I uncommented one...but that hasn't helped. I thought it might get confused calling an empty variable.

Anyway, the script about halfway works...it stands...never runs. It won't target anything unless I click on it, at which point it chases down and murders or gets murdered. It will loot...but will not destroy or equip anything.

Here's what might be important snippets of code...any further suggestions would be greatly appreciated. I'm a macroquest noob, coming from the annals of the xylobot world...

from Qeynos.mac--

Code: Select all

sub SetAlerts 
| Setup Alerts for the most important mobs here (rare) 
| 
   /alert clear 1 
   /alert add 1 npc radius 500 large rat 
   /alert add 1 npc radius 500 gopher 
(repeated for the rest of the alerts except the avoid one...)


| This sub sets up the list loot we wish to keep.
|

Code: Select all

sub SetLootList 

   /varset a(1,0) "eye" 
   /varset a(1,1) "quality" 
  
   | Put number of items in list here. 
   /varset LootTotal 2 
just stands there with the first item on the clicker...doesn't destroy, drop, or equip.

it says it can't parse this....

| This sub sets our home point we return to if low on health
|

Code: Select all

sub SetHomePoint    

   | Set home to be entrance of tunnel 
   /varset HomeX 310,
   /varset HomeY 143
   /mqlog Home Point is $HomeX, $HomeY 

/return 
This might be part of the problem....although it really doesn't try to move...

Code: Select all

| this sub just calls avoidloc for each area i want to avoid in EC 
      
   | Single Hut Near WF Zone 
   /call avoidloc 184 -856 30 
And this is all that I've changed from hunter.mac

Code: Select all

#turbo 
#include routines.mac 
#include qeynos.mac
I think my error's in the qeynos.mac file...the above pieces are what I changed. Sorry in advance for the long post.

He kills pretty well, kicks and mends effectively. he won't run home, he won't auto target, and he's almost LD'ing me by generating so much spam of "there are no " around here"....thanks in advance....anyone?

User avatar
Fippy
a snow griffon
a snow griffon
Posts: 499
Joined: Tue Jul 16, 2002 10:42 am

Post by Fippy » Tue Nov 19, 2002 4:10 am

Firstly you need to old ui. clicking doesnt work in the new ui so looting wont work properly. Also turn on fast destroy or anything you loot will not be destroyed if you dont want it.

As for the there are no " around here. I think there is a bug with alert in MQ. It would seems that the line /if "$alert(1)"=="TRUE" sometimes becomes true even if there are no mobs matching alert 1. It may help if you just remove the radius 500 command from the alert to increase the chance of something triggering alert 1.

I will do some more testing of this when the servers come back up (They are due to go down in a couple of hours at the time or writing).
Fippy

This is my girl. But Rizwank had her first :-)
[img]http://www.btinternet.com/~artanor/images/fairy_bounce09.gif[/img]

Nerfy
a lesser mummy
a lesser mummy
Posts: 72
Joined: Tue Oct 15, 2002 11:37 am

Post by Nerfy » Tue Nov 19, 2002 9:29 am

I had a similar problem. Remove the quotes. This is a problem with MQ. I have never been able to specify specific targets using alerts - only similar ones. So that if I try:

Code: Select all

/alert 1 add "a fire beetle"
/alert 1 add a fire beetle
/alert 1 add beetle
The first one will look for a mob called ". There are no mobs with the name " so it will tell you just that. The second alert will look for a mob called a. Here you will get quite a few hits. a bat, a wolf, etc. Similar to the first word. The last will return all beetles.

Problem with this is that you want 'a fire beetle' and not 'a dragon beetle' which is level 50+ with a bad attitude.

My solution? Well, the alerts were done so that you would have a convient way of defining what to target. Just specify your targets. I have made a FindTarget routine that doesn't rely on MQ at all. It's a pain to customize, but I feel safer using it. I'm at work right now, but here's the way it runs as best as I can remember.

Code: Select all

sub FindTarget
   | Successful Find Flag
   /varset v1 0  

   | Start Loop
   :TryTarget

      | Order these from least to most wanted
      /target "a fire beetle"
      /target "a decaying skeleton"

      | Make sure we found one of 
      | what we were looking for - MQ
      | often will target anything if it can't
      | find what we wanted
      /if $target(name)=="a fire beetle" /varset  v1 1
      /if $target(name)=="a decaying skeleton" /varset v1 1

      | Make sure it's less of a level then me
      /if n $target(level)>=$char(level) /varset v1 0

   /if n $v1!=1 /goto :TryTarget
/return

Again, that's written from memory with no testing so there's no garuntee that it'll work - but you get the idea. Actually I think that I set the MOBs that I want to hunt in an array, but I'll let you do that on your own.

This way we get beasties that are named exactly what we want, and that are not as strong as we are. Only thing I'd add is anti KS code with the PC radius. Anyway, have fun.
----------
* Nerfy *

quasit
orc pawn
orc pawn
Posts: 14
Joined: Sun Oct 27, 2002 11:51 am

hunter not working for me, what am i doing wrong

Post by quasit » Tue Nov 19, 2002 8:13 pm

im running:

old ui
latest offsets for patch
runnin 1024 version

it says unable to add macro line....

i have never heard of this problem before, any help please


thanks all,


Q

Malachi
a hill giant
a hill giant
Posts: 227
Joined: Tue Nov 19, 2002 1:29 am
Contact:

Working

Post by Malachi » Tue Nov 19, 2002 9:19 pm

I got this script working, very nice. I'll cut and paste what I have for those people trying to make it work. I've had to comment out the running home routine because it says it can't parse the loc.

This is fine so long as I have good buffs up...it SUCKS when ya don't, cuz you die real fast w/o resting.

If someone can help me...here's my snippet of code for my home location..

| This sub sets our home point we return to if low on health
|
sub SetHomePoint

| Set home to be near guards in Qeynos Hills
/varset HomeX 517.00,
/varset HomeY 166.00
/mqlog Home Point is $HomeX, $HomeY

/return

It still says it can't parse that. Anyone have idears?

here's what I have for hunter...it chases them down, kills, and abandons loot, hehe.

| Hunter.mac
|
| The ultimate melee class.zone farming script
|
#turbo
#include routines.mac
#include qeynos.mac

#define LootTotal v50
#define KSRadius v51
#define NoLOS v38
#define TooFarAway v39
#define MyTarget v40
#define MyHeading v41
#define TargetHeading v42
#define HeadingDelta v43
#define TargetDead v44
#define MyXLoc v46
#define MyYLoc v47
#define KSCheck v49
#define TargetLooted v52
#define LootSlot v54
#define CheckLoot v55
#define AttackedMe v56
#define BackHome v57
#define HomeY v58
#define HomeX v59
#define Attacker v60


#event CannotSee "You cannot see your target"
#event TooFar "Your target is too far away"
#event HitsYou "YOU for"

sub Main

/zapvars
/mqlog Hunter script v 20021007a started

| Set up Alert lists
/call SetAlerts

| Set up List of Loot to keep
/call SetLootList

| Set Home Point
call SetHomePoint

| Set KS radius below. The script will not target a mob if a PC is within this radius of |it.
|/varset KSRadius 60

| Set Loot nodrop
|/lootn never

|
| First off put clean up any open windows and make sure modifier keys are reset
/press esc
/press esc
/press esc
/press esc
/press alt
/press shift
/press ctrl

| Start of main Loop
|
:Start

| RestUp
/call RestUp

| Aquire nearest target to attack
/call GetTarget

| Advance
/call Advance

| Loot
/call Loot

/delay 0
/goto :Start

/return



| RestUp
sub RestUp

| Run to Home Base if needed
/if n $char(hp,pct)>50 /goto :NoRest

|Low on HP's running home
/mqlog HPs at $char(hp,pct) heading home
/call HomeBase

| If we didnt make it home we dont want to rest
/if n $return!=1 {
/mqlog Didnt make it home aborting run home
/goto :NoRest
}

| Make sure we are sat down.
/mqlog Reached home base resting
/sit on
:Rest
| Check if something has aggroed and attack it if it has.
/if n $AttackedMe==1 {
/mqlog aggroed whilst sitting
/sit off
/goto :NoRest
}
/delay 5
/if $char(ability,"Mend")>0 /doability "Mend"
/if n $char(hp,pct)<100 /goto :Rest
/mqlog Hps at $char(hp,pct) Off hunting again
}
:NoRest
/stand
/return

| Acquire Target subroutine
sub GetTarget
:Acquire
/if AttackedMe==1 {
/mqlog Targeted "$v13" who jumped me
/target "$v13"
/varset AttackedMe 0
} else /if "$alert(1)"=="TRUE" {
/target npc alert 1 notnearalert 4 nopcnear $KSRadius
/mqlog Targeted $target(name) range $target(distance) on alert list 1
} else /if "$alert(2)"=="TRUE" {
/target npc alert 2 notnearalert 4 nopcnear $KSRadius
/mqlog Targeted $target(name) range $target(distance) on alert list 2
} else {
/target npc alert 3 notnearalert 4 nopcnear $KSRadius
/mqlog Targeted $target(name) range $target(distance) on alert list 3
}
/varset MyTarget $target(id)
/varset TargetDead 0
/doevents
/delay 0
/if n $target(id)==0 /goto :Acquire
/return

| Advance to mob subroutine
sub Advance

:Engage

|Process any events
/doevents

|Work on sense heading skill
/if $char(ability,"Sense Heading")>0 /doability "Sense Heading"

| Turn towards target
/face nopredict

| If we are not within melee range then make sure we are on autorun
/if n $target(distance)>15 /call autorun2 1

| If we are still a distance away from target search for a closer one
/if n $target(distance)>200 {
/call GetTarget
}


| Save our current x,y loc
/varset MyXLoc $char(x)
/varset MyYLoc $char(y)
| Wait a then check loc again if we are on same spot call the obstacle routine to |try and get around it
/delay 1
/if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle

| If we are within melee range stop running check Target again for other players |engaged and attack if all OK.
/if n $target(distance)<15 {
/mqlog In melee range
/call autorun2 0
/varset KSCheck $target(id)
/call GetTarget
/if n $KSCheck==$MyTarget /call Melee
}

|/call checkobstacles
/delay 0
/if n $TargetDead!=1 /goto :Engage
/mqlog Target is dead
/target id $MyTarget
/return

| Melee with mob subroutine
sub Melee

/mqlog Started melee
/attack on

:Combat
| Check events
/doevents flush

| Make sure were staring the critter out
/face nopredict

| If we are too far away close in
/if n $target(distance)>15 {
/face nopredict
/delay 2
/call autorun2 1
/mqlog $target(distance,nopredict) from $target(name)
}

| If we are in melee range stop running
/if n $target(distance)<15 {
/call autorun2 0
/delay 2
/face fast nopredict
/mqlog In melee with $target(name) at $target(hp,pct) I am at $char(hp,pct)
}

/doevents

| If we cannot see the target backup and face it again.
/if n $NoLOS==1 {
/mqlog Cannot see
/face nopredict
/sendkey down down
/delay 4
/sendkey up down
/varset NoLOS 0
/delay 3
}

| If we are too far away close in
/if n $TooFarAway==1 {
/face nopredict
/delay 2
/call autorun2 1
/varset TooFarAway 0
}

/if $char(ability,"Round Kick")>0 /doability "Round Kick"
/if $char(ability,"Kick")>0 /doability "Kick"
/if $char(ability,"Mend")>0 /doability "Mend"
/if $char(ability,"Slam")>0 /doability "Slam"


| Check if target is dead or we have lost it
/if n $target(id)==0 /varset TargetDead 1

| Check for any obstacles we are supposed to avoid
|/call checkobstacles

| If target is still alive keep at it
/if n $TargetDead!=1 /goto :Combat

| Target is dead so stop attacking
/attack off

/varset AttackedMe 0

/return

| Loot mob
sub Loot

/varset TargetLooted 0

:Approach

/mqlog Advancing to corpse
|Process any events
/doevents

| Check we still have a target if not dont try to loot it
/if n $target(id)==0 /goto :Looted

| Turn towards target
/face nopredict

| If we are within range loot corpse
/if n $target(distance)<15 {
/call autorun2 0
/loot
/goto :AtTarget
}

| If we are not within range then make sure we are on autorun
/if n $target(distance)>12 /call autorun2 1

| Save our current x,y loc
/varset MyXLoc $char(x)
/varset MyYLoc $char(y)

| Wait and then check loc again if we are on same spot call the obstacle routine to try and get around it
/delay 1
/if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle

| Check for any obstacles we are supposed to avoid
|/call checkobstacles

/delay 0
/goto :Approach
:AtTarget

|Begin Looting

/mqlog starting to loot
/delay 10

| Cycle through each loot slot
/varset LootSlot 0
:LootLoop
/delay 1
/click left corpse $LootSlot
/delay 3
/if "$cursor()"!="TRUE" /goto :NoLoot

| Scan list of loot to keep and auto drop it if we are keeping it.
/varset CheckLoot 0
:GetLoot
/if "$cursor(name)"~~"$a(1,$CheckLoot)" {
/mqlog Looted $cursor(name)
/click left auto
/goto :Looted
}

/varadd CheckLoot 1
/delay 0
/if n $CheckLoot<$LootTotal /goto :GetLoot

| Checked list of loot to keep with no matches so destroy (must turn on fast destroy)
/mqlog Destroying $cursor(name)
/click left destroy

:Looted
/varadd LootSlot 1
/delay 0
/goto :LootLoop
:NoLoot

/delay 3
/press esc
/delay 2
/return



sub HomeBase

/mqlog Heading Home

:RunHome

|Process any events
/doevents

|Work on sense heading skill
/if $char(ability,"Sense Heading")>0 /doability "Sense Heading"

|Check if we have aggroed something and stop running home if we have
/if n $AttackedMe==1 {
/mqlog $v13 Atacked be on the way home
/return
}

| Turn towards target
/face loc $HomeY,$HomeX

| If we are not within melee range then make sure we are on autorun
/if n $distance($HomeY,$HomeX)>15 /call autorun2 1

| Save our current x,y loc
/varset MyXLoc $char(x)
/varset MyYLoc $char(y)

| Wait a then check loc again if we are on same spot call the obstacle routine to |try and get around it
/delay 1
/if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle

| Check for any obstacles we are supposed to avoid
|/call checkobstacles

| If we are within melee range stop running check Target again for other players |engaged and attack if all OK.
/if n $distance($HomeY,$HomeX)<15 {
/mqlog Reached Home
/call autorun2 0
/varset BackHome 1
}

/delay 0
/if n $BackHome!=1 /goto :RunHome
/varset BackHome 0

/return 1

sub Obstacle

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


sub AvoidLoc
| Pass in 3 numbers first two are the Y and X locs of the point to avoid third one is the |distance you want to keep from it.
| This sub will check if you are within the distance specified and turn you away from the loc and run you until you are the correct
| distance away. Too many calls to this sub will slow your main loop down badly so keep the areas large and infrequent for best results.
| i.e. if there are a few huts together set a loc and radius that will cover the whole area rather than each individual hut.

/if n $distance($p0,$p1)>$p2 /goto :OK
/mqlog close to $p0 $p1
/if n $calc($heading($p0,$p1)-$char(heading)<0 {
/face heading $calc($heading($p0,$p1)-95)
} else {
/face heading $calc($heading($p0,$p1)+95)
}
:RunAway
/call autorun2 1
/delay 1
/if n $distance($p0,$p1)<$p2 /goto :RunAway
:OK

/return

Sub AutoRun2
/if $p0==1 /sendkey down up
/if $p0==0 /sendkey up up
/return


sub Event_TooFar
/varset TooFarAway 1
/return

sub Event_CannotSee
/varset NoLOS 1
/return

sub Event_HitsYou
/if "$combat"=="TRUE" /goto :StillEngaged
/varset AttackedMe 1
/varset v10 "$left($calc($instr("YOU","$p0")-1),"$p0")"
/varset v11 $strlen("$v10")
:WalkString
/if "$mid($v11,1,"$v10")"==" " {
/varset v12 $v11
/goto :DoneWalkString
}
/varsub v11 1
/delay 0
/goto :WalkString
:DoneWalkString
/varset Attacker "$left($v12,"$v10")"
/mqlog Being Hit by $Attacker
:StillEngaged
/return


Notice please, that much is commented out cuz it didn't work for me.
Here's my qeynos.mac file.

| EastCommons.mac
|
| Zone specific Info for Hunter Script
#define HomeY v58
#define HomeX v59

| This Sub sets up the alert lists for the mobs we want to hunt
|

sub SetAlerts
| Setup Alerts for the most important mobs here (rare)
|
/alert clear 1
/alert add 1 npc radius 800 rat
/alert add 1 npc radius 800 gopher
/alert add 1 npc radius 800 gnoll


| Setup Alerts for the next most important mobs here (uncommon)
|

|/alert clear 2
|/alert add 2 npc radius 800 gnoll pup
|/alert add 2 npc radius 800 large rat


| Setup Alerts for the next most important mobs here (common)
|
|/alert clear 3
|/alert add 3 npc rat
|/alert add 3 npc bat
|/alert add 3 npc bear


| Setup Alerts for Scary mobs here
|
|/alert clear 4
|/alert add 4 npc warrior
|/alert add 4 npc worker
|/alert add 4 npc snake

/return


| This sub sets up the list loot we wish to keep.
|
sub SetLootList

/varset a(1,0) "eye"
/varset a(1,1) "quality"

| Put number of items in list here.
/varset LootTotal 2

/return



| This sub sets our home point we return to if low on health
|
sub SetHomePoint

| Set home to be entrance of tunnel
/varset HomeX 517.00,
/varset HomeY 166.00
/mqlog Home Point is $HomeX, $HomeY

/return


If anyone (fipster?) could help me understand what's wrong with the parsing of my locs...please do. I'm assuming since it's a parse error it's in my syntax of the loc...I think it would be a variable error if the call in hunter.mac was messed up?

Good luck people, and nice work Fippy.

~Malachi

Oh...and I'm on the newest 11-19 offsets...the newest IRC release
PIV 1.5
Win XP
256Mb
32Mb Geforce 2
not so l33t. ;)
~Oh danny boy, the pipes the pipes are calling.~

Nerfy
a lesser mummy
a lesser mummy
Posts: 72
Joined: Tue Oct 15, 2002 11:37 am

Post by Nerfy » Tue Nov 19, 2002 11:38 pm

Just a guess, but at the top you have:

Code: Select all

/varset HomeX 517.00, 
Remove that comma.
----------
* Nerfy *