Little help with a farming macro...

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

bardwithbadwrists
decaying skeleton
decaying skeleton
Posts: 6
Joined: Tue Jul 22, 2003 2:49 pm

Little help with a farming macro...

Post by bardwithbadwrists » Fri Feb 20, 2004 12:31 am

Okay, I'm trying to make a macro to farm some tradeskill components... It's mostly just grimjack's hunter with a few pieces of code changed slightly for my means (wanting to be stationary and using the bards bellow to pull)

(Changed code in Cyan, and yes I know its very sloppy)

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) "etched" 
   /varset MainArray(1,1) "block" 
   /varset MainArray(1,2) "brick" 
   /varset MainArray(1,3) "opal" 
   /varset MainArray(1,4) "emerald" 
   /varset MainArray(1,5) "windstone" 
   /varset MainArray(1,6) "piece" 
   /varset MainArray(1,7) "peridot"
| Add as many of these  as you want but make sure you 
| increase LootTotal 
   /varset MainArray(2,0) "grimling" 
| Add as many of these as you want but make sure you 
|  increase MobArraySize 
   /varset LootTotal 8 
   /varset KSRadius 60 
   /varset HasTarget 0 
   /varset ObstCount 0 
   /varset MobArraySize 1 
   :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 



[color=cyan]Sub MoveToMob 
/face fast 
/alt activate 199
/stopsong
/cast 1
/delay 32
/stopsong
/cast 2
/delay 32
/stopsong
/cast 3
/delay 3s
/return [/color]

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
/click left done 
/sendkey down down
/delay 3
/sendkey down up
/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
Only problem with it is the way I set in the songtwist requires the whole twist to finish before looting, then before targeting another, etc... any suggestions? Was trying to find a way to put twisting into an include file, but couldn't quite figure it out.