hunter.mac simple hunt macro with loot capability.

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

hunter.mac simple hunt macro with loot capability.

Post by grimjack » Fri Oct 03, 2003 9:23 am

Hunter.mac:
Updated to remove all nopredict and look references. They are now the default and the flags where removed.

Code: Select all

| hunter.mac
| v3.1
| Hunt script with loot for new loot parser.
| As always much of this script is inspired or taken directly from
| pieces of macro's found at macroquest2.com's macro depot
| Thank you to all the people who have donated their scripts which
| made this possible.  And thank you to the MQ developers.
|
| Edit  /varset MainArray(1,0) "silk" and /varset MainArray(1,1) "skin"
| Also edit /varset MainArray(2,0) "widow" and /varset MainArray(2,1) "wolf"
| You can also make these arrays bigger.  If you want to search for
| wolfs, widows and orcs you would have this
| /varset MainArray(2,0) "widow"
| /varset MainArray(2,1) "wolf"
| /varset MainArray(2,2) "orc"
| /varset MobArraySize 3
| This picks a random number based on MobArraySize to pick which
| Type of mob it will chose from the array.
|
| What type of loot you want can be expanded in a similar way to
| the mobs you want to hunt.  Just add your array entry and update
| /varset LootTotal 2 to be /varset LootTotal [# of loot entries]
|
| Another thing, for the code to actualy destroy items you don't want to
| keep you must have fast item destroy turned on in the game.  I would
| test the script for a while on your machine before doing this.  It would
| really suck if it picks up your Eyepatch of Plunder and destroies it
| due to a bug.

#turbo 90

Sub Main
   /declare MobToHunt global
   /declare MainArray array2
   /declare MyXLOC global
   /declare MyYLOC global
   /declare KSRadius global
   /declare NotSee global
   /declare TooFar global
   /declare MyTarget global
   /declare TargetDead global
   /declare HasTarget global
   /declare ObstCount global
   /declare LootSlot global
   /declare CheckLoot global
   /declare LootTotal global
   /declare MobArraySize global
   /declare RangeMax global
   /declare RangeMin global
   /declare FastRange global
   /press esc
   /press esc
   /press esc
   /press esc
   /press alt
   /press shift
   /press ctrl
   /varset RangeMax 12
   /varset RangeMin 10
   /varset FastRange 14
   /varset LootSlot 0
   /varset CheckLoot 0
   /varset MainArray(1,0) "silk"
   /varset MainArray(1,1) "quality"
| Add as many of these  as you want but make sure you
| increase LootTotal
   /varset MainArray(2,0) "widow"
   /varset MainArray(2,1) "wolf"
| Add as many of these as you want but make sure you
|  increase MobArraySize
   /varset LootTotal 2
   /varset KSRadius 60
   /varset HasTarget 0
   /varset ObstCount 0
   /varset MobArraySize 2
   :Start
   /call GetTarget
   /if @HasTarget=="1" /call MoveToMob
   /if @HasTarget=="1" /call CombatSub
   /if @HasTarget=="1" /call MoveToMob
   /if @HasTarget=="1" /call LootMob
   /call ResetSub
   /goto :Start
/return



sub GetTarget
   :Aquire
   /target nopcnear @KSRadius npc "@MainArray(2,$rand(@MobArraySize))"
   /varset MyTarget $target(id)
   /varset TargetDead 0
   /if n $target(id)==0 /goto :Aquire
   /if $target()=="False" /goto :Aquire
   /varset HasTarget 1
   /varset MobToHunt $target(name)
/return



Sub MoveToMob
   /face fast
   /if n $target(distance)>=@FastRange /call Fastmove
   /if n $target(distance)>@RangeMax {
      /press up
   }
   /if n $target(distance)<@RangeMin {
      /press down
   }
/return

Sub Fastmove
   /varset MyXLOC $char(x)
   /varset MyYLOC $char(y)
   /varset ObstCount 0
   :fastmoveloop
   /if $target()=="FALSE" {
      /sendkey up up
      /if $combat=="TRUE" {
         /attack off
         /return
      }
   }
   /face fast
   /if n $target(distance)>@FastRange {
      /sendkey down up
   }
   /if n $target(distance)<=@FastRange {
      /sendkey up up
      /return
   }
   /varadd ObstCount 1
   /if n @ObstCount>=3 {
      /call CheckObst
   }
   /goto :fastmoveloop
/return

sub CombatSub
   /if $target()=="FALSE" {
      /varset HasTarget 0
      /return
   }
   /attack on
   :combatloop
   /face fast
   /if $char(class)==Rogue /call BackstabIt
   /call MoveToMob
   /face fast
   /if n $target(id)==0 /varset TargetDead 1
   /if n @TargetDead!=1 /goto :combatloop
   /sendkey up up
   /delay 1s
   /target corpse
   /lootn never
   /delay 2s
/return

sub LootMob
   /loot
   /delay 2s
   :lootloop
   /if n @LootSlot>=9 /goto :doneloot
   /click left corpse @LootSlot
   /delay 1s
   /if "$cursor()"!="TRUE" /goto :doneloot
   :lootChecker
   /if "$cursor(name)"~~"@MainArray(1,@CheckLoot)" {
      /delay 1s
      /click left auto
      /delay 1s
      /varadd LootSlot 1
      /goto :lootloop
   }
   /varadd CheckLoot 1
   /if "$cursor()"=="TRUE" {
      /if n @CheckLoot<@LootTotal /goto :lootchecker
   }
   /if "$cursor()"=="TRUE" {
      /delay 1s
      /click left destroy
      /delay 1s
   }
   /varadd LootSlot 1
   /varset CheckLoot 0
   /goto :lootloop
   :doneloot
   /lootn always
   /varset LootSlot 0
/return

sub ResetSub
   /sendkey up up
   /press esc
   /press esc
   /press esc
   /press esc
   /press alt
   /press shift
   /press ctrl
   /varset CheckLoot 0
   /varset HasTarget 0
   /varset ObstCount 0
   /delay 1s
/return

sub CheckObst
   /if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) /call HitObst 5
   /varset MyXLOC $char(x)
   /varset MyYLOC $char(y)
   /varset ObstCount 0
/return

sub HitObst
   /sendkey up up
   /sendkey down down
   /if n $rand(99)>50 {
      /delay 3s
      /sendkey up down
      /sendkey down Right
      /delay @Param0
      /sendkey up Right
      /sendkey down up
      /delay 3s
      /sendkey up up
   } else {
      /delay 3s
      /sendkey up down
      /sendkey down left
      /delay @Param0
      /sendkey up left
      /sendkey down up
      /delay 3s
      /sendkey up up       
   }
   /sendkey up down
   /sendkey up Right
   /sendkey up Left
   /sendkey down up
/return

Sub BackstabIt
   /if n $char(ability,"Backstab")!=-2 {
      /if $target()=="TRUE" {
         /face fast
         /doability "Backstab"
      }
   }
/return
Last edited by grimjack on Fri Nov 07, 2003 9:06 pm, edited 14 times in total.
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

User avatar
Slice
a hill giant
a hill giant
Posts: 189
Joined: Wed Oct 30, 2002 2:52 pm

Post by Slice » Fri Oct 03, 2003 9:36 am

Can you add a feature to handle Shadowed Man camps in here? When you kill one of them, they all rush you. My pet kills them all but it only loots the one originally targetted. Perhaps a 20 second pause after the original target is dead if it's a shadow man and then a loop looking for any shadow man corpses to loot?
Slice

mackster
a ghoul
a ghoul
Posts: 95
Joined: Mon Sep 09, 2002 3:02 pm

Post by mackster » Fri Oct 03, 2003 9:54 pm

Been trying to get this to work but it won't loot the mobs it kills. It looks like it's running a /loot command with no corpse targeted, then targeting the corpse and trying to loot items, but there's no loot window up.

Any ideas?

mekaniak
a hill giant
a hill giant
Posts: 290
Joined: Thu Sep 18, 2003 3:21 pm

Post by mekaniak » Tue Oct 07, 2003 12:32 am

Hey, I'm putzing (spelling?) around with your code here, and I noticed that you have a /target corpse @MobToHunt in the combatSub, could that be the reason it doesnt target anything when trying to loot the corpse???

EDIT: ok i checked it out myself, and answered my own question...It still lost the corpse target. Maybe its a start though???

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Saw a few problems.

Post by grimjack » Tue Oct 07, 2003 3:40 am

I found a few problems in this macro. I have updated the top but I have not been able to test this yet. I will test it when I get home and make any additional changes that are needed.

Thanks
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

mekaniak
a hill giant
a hill giant
Posts: 290
Joined: Thu Sep 18, 2003 3:21 pm

Post by mekaniak » Tue Oct 07, 2003 11:12 am

Hey Grim, I'm using the new code and I noticed it does do a few things better. For one, it actually follows the mobs when they run now. Second, it doesnt go through and tell em like 15 times that "rat" can not be found. The only problem, so far, that I have found is it still doesnt loot the corpses for me, it will target the corpse but then lose it before it loots it.

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Fixed

Post by grimjack » Tue Oct 07, 2003 8:51 pm

This should now be fixed.
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

theafkxper
a hill giant
a hill giant
Posts: 207
Joined: Sun Sep 08, 2002 6:41 pm

Post by theafkxper » Thu Oct 16, 2003 1:18 am

Mod'd to track mobs based on priority

Code: Select all

   /declare LootTotal global 
   /declare MobArraySize global
   [color=red]/declare MobPriority global[/color]
   /press esc 
   /press esc 



sub GetTarget
   [color=red]/varset MobPriority 0[/color]
   :Aquire
   [color=red]/target nopcnear @KSRadius npc "@MainArray(2,@MobPriority)" [/color]
   |/target nopcnear @KSRadius npc "@MainArray(2,$rand(@MobArraySize))" 
   /varset MyTarget $target(id) 
   /varset TargetDead 0 
   /if n $target(id)==0 {
   /delay 5s
   [color=red]/varadd MobPriority 1
   /if n @MobPriority>=@MobArraySize /varset MobPriority 0
   /goto :Aquire 
   }[/color]
   /if $target()=="False" /goto :Aquire 
   /varset HasTarget 1 
   /varset MobToHunt $target(name) 
/return 



User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Fri Oct 17, 2003 5:08 am

Fixed movement code to be more like genbots.
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

Guest

Post by Guest » Fri Oct 17, 2003 6:50 pm

Can't get it to work....

I am hunting IG's w/ a Warrior.

I have altered the target array to be giant and giant....

I type in
/macro hunter

get some stuff spit out at me... the IG winds up targeted, but he does not attack.

What am I doing wrong?

Diggler
> Oid
Posts: 120
Joined: Thu Oct 09, 2003 3:28 pm
Location: Lexington, KY

Post by Diggler » Fri Oct 17, 2003 7:21 pm

GJ: Fastmove sub had an error, you had listed /varset MyXLoc and MyYLoc instead of MyXLOC and MyYLOC. So if you got the fastmove version, it won't work unless you capitalize all of the word LOC in the Fastmove sub.

tac8357
orc pawn
orc pawn
Posts: 25
Joined: Fri Oct 17, 2003 5:18 pm
Contact:

small problem

Post by tac8357 » Fri Oct 17, 2003 8:56 pm

Hunter.mac works great but i notice when you get close to the mob and you go into attack mode my character gets alll gittery jumping back and forth in little incerments. Looks pretty weird just dont wanna draw attention to myself.

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Re: small problem

Post by grimjack » Sat Oct 18, 2003 2:40 pm

tac8357 wrote:Hunter.mac works great but i notice when you get close to the mob and you go into attack mode my character gets alll gittery jumping back and forth in little incerments. Looks pretty weird just dont wanna draw attention to myself.
Tweak the Min Max and Fast range vars.
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

weapon
a ghoul
a ghoul
Posts: 101
Joined: Tue Oct 01, 2002 7:20 pm

Post by weapon » Mon Oct 20, 2003 10:51 am

Once again grim thanks for making automated PL possible. This is one fix I found. I added some more target logic I'll post when I get back from work.

Code: Select all

Sub Fastmove 
   /varset MyXL[color=red]OC[/color] $char(x) 
   /varset MyYL[color=red]OC[/color] $char(y) 
   /varset ObstCount 0 
   :fastmoveloop 
   /if $target()=="FALSE" { 
      /sendkey up up 
      /if $combat=="TRUE" { 
         /attack off 
         /return 
      } 
   } 
   /face fast look nopredict 
   /if n $target(distance,nopredict)>@FastRange { 
      /sendkey down up 
   } 
   /if n $target(distance,nopredict)<=@FastRange { 
      /sendkey up up 
      /return 
   } 
   /varadd ObstCount 1 
   /if n @ObstCount>=3 { 
      /call CheckObst 
   } 
   /goto :fastmoveloop 
/return 

weapon
a ghoul
a ghoul
Posts: 101
Joined: Tue Oct 01, 2002 7:20 pm

Post by weapon » Mon Oct 20, 2003 10:58 am

Ehh screw it the comments should tell ya the extra logic. Ran this for an hour without problems. Take what ya want leave the rest for the dogs.

Code: Select all

| hunter.mac
| v2.1
| Hunt script with loot for new loot parser.
| As always much of this script is inspired or taken directly from
| pieces of macro's found at macroquest2.com's macro depot
| Thank you to all the people who have donated their scripts which
| made this possible.  And thank you to the MQ developers.
|
| Edit  /varset MainArray(1,0) "silk" and /varset MainArray(1,1) "skin"
| Also edit /varset MainArray(2,0) "widow" and /varset MainArray(2,1) "wolf"
| You can also make these arrays bigger.  If you want to search for
| wolfs, widows and orcs you would have this
| /varset MainArray(2,0) "widow"
| /varset MainArray(2,1) "wolf"
| /varset MainArray(2,2) "orc"
| /varset MobArraySize 3
| This picks a random number based on MobArraySize to pick which
| Type of mob it will chose from the array.
|
| What type of loot you want can be expanded in a similar way to
| the mobs you want to hunt.  Just add your array entry and update
| /varset LootTotal 2 to be /varset LootTotal [# of loot entries]
|
| Another thing, for the code to actualy destroy items you don't want to
| keep you must have fast item destroy turned on in the game.  I would
| test the script for a while on your machine before doing this.  It would
| really suck if it picks up your Eyepatch of Plunder and destroies it
| due to a bug.


Sub Main
   /declare MobToHunt global
   /declare MainArray array2
   /declare MyXLoc global
   /declare MyYLoc global
   /declare KSRadius global
   /declare NotSee global
   /declare TooFar global
   /declare MyTarget global
   /declare TargetDead global
   /declare HasTarget global
   /declare ObstCount global
   /declare LootSlot global
   /declare CheckLoot global
   /declare LootTotal global
   /declare MobArraySize global
   /declare RangeMax global
   /declare RangeMin global
   /declare AttackRange global
   /declare MobArraySize global
   /declare WaitForAdds global
   /press esc
   /press esc
   /press esc
   /press esc
   /press alt
   /press shift
   /press ctrl
   /varset RangeMax 12
   /varset RangeMin 10
   /varset AttackRange 15
   /varset LootSlot 0
   /varset CheckLoot 0
   /varset KSRadius 60
   /varset HasTarget 0
   /varset ObstCount 0
   /varset WaitForAdds 1
| Add as many of these as you want but make sure you increase LootTotal
   /varset LootTotal 2
   /varset MainArray(1,0) "silk"
   /varset MainArray(1,1) "quality"
| Add as many of these as you want but make sure you increase MobArraySize
   /varset MobArraySize 12
   /varset MainArray(2,0) "griffawn"
   /varset MainArray(2,1) "wolf"
   /varset MainArray(2,2) "lioness"
   /varset MainArray(2,3) "stalker"
   /varset MainArray(2,4) "lion"
   /varset MainArray(2,5) "hound"
   /varset MainArray(2,6) "gnoll"
   /varset MainArray(2,7) "reaver"
   /varset MainArray(2,8) "werewolf"
   /varset MainArray(2,9) "spiderling"
   /varset MainArray(2,10) "bear"
   /varset MainArray(2,11) "kodiak"

   :Start
   /call GetTarget
   /if @HasTarget==1 /call MoveToMob
   /if @HasTarget=="1" /call CombatSub
   /if @HasTarget=="1" /call MoveToMob
   /if @HasTarget=="1" /call LootMob
   /call ResetSub
   /goto :Start
/return

Sub GetTarget
   /declare MobNumber local
   /declare NumberOfMobsFound local
   /declare CurrentMobToCheck local
   /declare ClosestMob local

   /varset TargetDead 0

   :Aquire

   |Wait 3 seconds to see if you have an add on you
   /if @WaitForAdds==1 {
      /delay 3s
      /if n $target(id)!=0 /goto  :HaveMob
      /if $target()!="False" /goto  :HaveMob
   }

   |Check if your pet is attacking anything
   /if $char(pet)!=0 {
       /target id $char(pet)
       /assist %t
       /if n $target(id)==$char(pet) /goto  :PetDoesntHaveTarget
       /if n $target(hp,cur)<1 /goto :PetDoesntHaveTarget
   }

   |Loop through the mob list and get the distance of every mob
   :PetDoesntHaveTarget

   /varset MobNumber "0"
   /varset NumberOfMobsFound 0

   :MobListCycle
       /target nopcnear @KSRadius npc "@MainArray(2,@MobNumber)"
       /if $target()!="False" {
          /varset MainArray(3,@NumberOfMobsFound) $target(id)
          /varadd NumberOfMobsFound 1
       }
       /varadd MobNumber 1
       /if n @MobNumber==@MobArraySize /goto :DoneMobListCycle
       /goto :MobListCycle
   :DoneMobListCycle

   |Do a check to see which mob in the mobs list is the closest
   /varset CurrentMobToCheck 0
   /varset ClosestMob 0

   :MobListClosest
       /if n $spawn(@MainArray(3,@CurrentMobToCheck),distance)<$spawn(@MainArray(3,@ClosestMob),distance) {
          /varset ClosestMob @CurrentMobToCheck
       }
       /varadd CurrentMobToCheck 1
       /if n @CurrentMobToCheck==@NumberOfMobsFound /goto :DoneMobListClosest
       /goto :MobListClosest
   :DoneMobListClosest

   /target id @MainArray(3,@ClosestMob)
   /varset MyTarget $target(id)

   /if n $target(id)==0 /goto :Aquire
   /if $target()=="False" /goto :Aquire

   :HaveMob
   /varset HasTarget 1
   /varset MobToHunt $target(name)
/return

sub MoveToMob
   /if n $target(distance)<=@AttackRange {
      /face fast look nopredict
      /return
   }
   /sendkey down up
   :Movementloop
       /delay .5s
       /varset MyXLoc $char(x)
       /varset MyYLoc $char(y)
       /varadd ObstCount 1
       /if $target()=="FALSE" {
          /varset HasTarget 0
          /return
       }
       /face fast look nopredict
       /if n $target(distance)<=@AttackRange {
          /face fast look nopredict
          /sendkey up up
          /return
       }
       /if @ObstCount>=3 {
          /call CheckObst
          /goto :Movementloop
       }
   /if n $target(distance)>@AttackRange /goto :MovementLoop
   /doability "sneak"
/return

Sub CombatSub
   /if $target()=="FALSE" {
      /varset HasTarget 0
      /return
   }
   :CombatLoop
      /attack on
      :CombatMove
         /delay .5s
         /varset MyXLoc $char(x)
         /varset MyYLoc $char(y)
         |Check if we still have target to chase
         /if n $target(id)==0 /goto :WeKilledIt
         |Check if we are in range
         /if n $target(distance)>=@AttackRange {
           /face fast look nopredict
           /sendkey down up
           /goto :CombatMove
         }

         /varadd ObstCount 1

         /face fast look nopredict
         /if n $target(distance)<=@AttackRange {
           /face fast look nopredict
           /sendkey up up
           /goto :InAttackRange
         }
         /if @ObstCount>=3 {
           /call CheckObst
           /goto :CombatMove
         }
      /if n $target(distance)>@AttackRange /goto :CombatMove
      :InAttackRange
   /if n @TargetDead!=1 /goto :CombatLoop
   
   :WeKilledIt
   /sendkey up up
/return

Sub LootMob
   /varset LootSlot 0
   /delay 1s
   /target corpse
   /delay 1s
   /loot
   |Wait for loot window to come up
   /delay 2s

   :lootloop
       /lootn never
       /if n @LootSlot>=9 /goto :doneloot
       /click left corpse @LootSlot
       /delay 1s
       /if "$cursor()"!="TRUE" /goto :doneloot
       
       :lootChecker
       /if "$cursor(name)"~~"@MainArray(1,@CheckLoot)" {
          /delay 1s
          /click left auto
          /delay 1s
          /varadd LootSlot 1
          /goto :lootloop
       }
       /varadd CheckLoot 1
       /if "$cursor()"=="TRUE" {
          /if n @CheckLoot<@LootTotal /goto :lootchecker
       }
       /if "$cursor()"=="TRUE" {
          /delay 1s
          /click left destroy
          /delay 1s
       }
       /varadd LootSlot 1
       /varset CheckLoot 0
   /goto :lootloop
   :doneloot
/return

Sub ResetSub
   /sendkey up up
   /press esc
   /press esc
   /press esc
   /press esc
   /press alt
   /press shift
   /press ctrl
   /varset CheckLoot 0
   /varset HasTarget 0
   /varset ObstCount 0
   /delay 1s
/return

Sub CheckObst
   /if n @MyXLoc==$char(x) /if n @MyYLoc==$char(y) /call HitObst 5
   /varset MyXLoc $char(x)
   /varset MyYLoc $char(y)
   /varset ObstCount 0
/return

Sub HitObst
   /sendkey up up
   /sendkey down down
   /if n $rand(99)>50 {
      /delay 3s
      /sendkey up down
      /sendkey down Right
      /delay @Param0
      /sendkey up Right
      /sendkey down up
      /delay 3s
      /sendkey up up
   } else {
      /delay 3s
      /sendkey up down
      /sendkey down left
      /delay @Param0
      /sendkey up left
      /sendkey down up
      /delay 3s
      /sendkey up up
   }
   /sendkey up down
   /sendkey up Right
   /sendkey up Left
   /sendkey down up
/return

Sub BackstabIt
   /if n $char(ability,"Backstab")!=-2 {
      /if $target()=="TRUE" {
         /face fast nopredict
         /doability "Backstab"
      }
   }
/return