noclickhunt.mac -A non-clicking autohunter

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

Moderator: MacroQuest Developers

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

noclickhunt.mac -A non-clicking autohunter

Post by Malachi » Tue Feb 11, 2003 11:58 pm

No, I did not write this script. That credit goes to Fippy. He's the man, I'm the weiner.

All I did was comment out the looting routine. I didn't even delete it, since it works pretty well when click's working...

Notice the changes to the included qeynos.mac file. I had to add "corpse" to the "avoid" list so that it wouldn't target corpses it had already killed.

Additionally, I took one of the monk abilities out and replaced it with "taunt", so that you'll chain-taunt during battle instead of mending or flying kicking or something, I forget what I took out.

I also added the HP check during the battle routine, because I use this script w/ Luc' Dragon's speed trainer so I want him to run like a fairy if he's getting stomped on. :)

I'm having trouble with this part I think, but I'm not getting below 15% very often either, so it's hard to test. Feel free to make corrections.

This script DOES NOT LOOT, mostly because I couldn't figure out a way to do it w/o clicking. Pressing U does not work.

Code: Select all

| noclickhunt.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,"Taunt")>0 /doability "Taunt" 
      /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

      |If we're getting wrecked, run like a fairy!
      /if n $char(hp,pct)<15 /call RestUp 

      | 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 

Lol, I just realized that maybe the reason he wasn't running home for me was that I had accidentally saved this macro in the old MQ macros directory, haha. Nice. Anyway, I'm not really sure if it should be calling the "runhome" loop or the "restup" loop, but I'm pretty sure restup routine is the right one.

And here's the modified Qeynos.mac that you'll be needing. Just edit the alerts in 1 to reflect the level variances/mobs you want to hunt. These are the ones I started for a baby SK ogre. The first ones don't have level designations because it was for a level 1 that wasn't twinked. I left the level variations there to suit your needs. Also, all the "checkobstacle" locs have been commented, but you can add them if you feel the need. Lol, obviously this started out as WestCommons.mac, hehe.

Also, like I said before, the "corpse" is on the avoid list so that you don't inadvertently target the corpse of something you already killed.

Code: Select all

| qeynos.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 1000 bat
   /alert add 1 npc radius 1000 skele
   /alert add 1 npc radius 1000 tad
   |/alert add 1 npc range $calc($char(level)-4) $calc($char(level)+1) bat
   |/alert add 1 npc range $calc($char(level)-4) $calc($char(level)+1) tad
   |/alert add 1 npc range $calc($char(level)-4) $calc($char(level)+1) skele
    |/alert add 1 npc range $calc($char(level)-4) $calc($char(level)-1) puma
    |/alert add 1 npc range $calc($char(level)-4) $calc($char(level)-1) scarab
    |/alert add 1 npc range $calc($char(level)-4) $calc($char(level)-1) orc
   |/alert add 1 npc radius 500 skeleton
   |/alert add 1 npc radius 500 bat
   |/alert add 1 npc radius 500 gnoll 
   |/alert add 1 npc radius 500 large
   |/alert add 1 npc radius 500 spiderling 

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

   |/alert clear 2 
   |/alert add 2 npc radius 1000 lion 
   |/alert add 2 npc radius 1000 large 
   |/alert add 2 npc radius 1000 bear 
   |/alert add 2 npc radius 1000 puma 
   |/alert add 2 npc radius 1000 spiderling 
    
| Setup Alerts for the next most important mobs here (common) 
| 
   |/alert clear 3 
   |/alert add 3 npc lion 
   |/alert add 3 npc kodiak 
   |/alert add 3 npc bear 
   |/alert add 3 npc puma 
   |/alert add 3 npc spiderling 
    

| Setup Alerts for Scary mobs here 
| 
   |/alert clear 4 
   /alert add 4 npc radius 10 corpse
   |/alert add 4 npc radius 100 lioness
   |/alert add 4 npc radius 100 lion

/return 


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

   /varset a(1,0) "silk" 
   /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 884.00, 
   /varset HomeY 1465.00 
   /mqlog Home Point is $HomeX, $HomeY 

/return 


| This sub does the checks to make sure we avoid certain specified areas 
sub CheckObstacles 

| this sub just calls avoidloc for each area i want to avoid in EC 
      
   | Single Hut Near WF Zone 
   |/call avoidloc 184 -856 30 
    
   | 2 Huts Near WF Zone 
   |/call avoidloc -154 -816 75 

   | Inn 1 Complex 
   |/call avoidloc -137 118 165 
    
   | Guard Post 
   |/call avoidloc 564 973 125 

   | Single Hut on path between inn1 and inn2 
   |/call avoidloc -106 1670 50 
    
   | Inn 2 Complex 
   /call avoidloc -320 3042 130 
    
   | Undead Ruins 
   |/call avoidloc -963 2841 180 
    
   | Orc 1 
   |/call avoidloc 1004 2642 180 
    
   | Druids 
   |/call avoidloc 418 3800 100 

   | Hut Near Druids 
   |/call avoidloc 337 4063 30 
    
   | Orc 2 
   |/call avoidloc 974 4627 60 
    
   | Hidden Inn 
   |/call avoidloc 997 3692 90 
    
   | Altunic Jartins Hut 
   |/call avoidloc -118 4732 30 
    
   | Inn 3 
   |/call avoidloc 221 4835 140    
    
/return 
~Oh danny boy, the pipes the pipes are calling.~

younglove
a lesser mummy
a lesser mummy
Posts: 38
Joined: Fri Jul 26, 2002 3:17 am
Location: Jacksonville Fl
Contact:

Post by younglove » Wed Feb 12, 2003 7:44 am

Nice job now if only one of us could figure out how to get the /click feature to work for the newUI it will be perfect for farming stuff for tradeskills

Vendor001
Cheezily Banned
Cheezily Banned
Posts: 78
Joined: Wed Nov 13, 2002 1:37 pm

Evul idea

Post by Vendor001 » Thu Feb 20, 2003 6:23 pm

Malachi,
Can you modify the loot code to just do /echos(like /echo loot from(x,y) to(x,y) to loot from location to location, /echo click(x,y) to open a bag) ?

That way you can run xylobot too, have it watch the log for the specified "click" commands and act accordingly?


Maybe if we just develop a simple communication interface with scripts between the two, we don't need "click" working in MQ to have a viable solution.

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

probably

Post by Malachi » Thu Feb 20, 2003 8:50 pm

Probably, and that's a tight idear, but let's wait to see what happens on the 24th before we throw much effort into that...

I'm thinking that someone (certainly not me, I suck at C) could probably easily fix it up, since MQ doesn't actively CHANGE any offsets, it just sticks its nose into them sometimes.

I'll be very interested to see what people can glean from post-patch monitoring of the .exe, and to see what they're looking for.

~malachi
~Oh danny boy, the pipes the pipes are calling.~