Farming Macro

Post your completed (working) macros here. Only for macros using MQ2Data syntax!

Moderator: MacroQuest Developers

jacensolo
a snow griffon
a snow griffon
Posts: 427
Joined: Wed Feb 14, 2007 8:51 am
Location: Right behind you

Farming Macro

Post by jacensolo » Thu Apr 12, 2007 8:12 pm

When it came time to farm a million spider silks, high quality lion pelts, and other assorted tailoring junk to raise my skill, I made myself a little macro that accepts a full or partial mob name and a full or partial loot name, and slaughters the zone killing matching mobs and looting matching items until the end of time (or until you tell it to stop). To use it, type "/mac farm mobname lootname". If the mob name or loot name is more than 1 word, use quotes. This macro will use autoattack and will spam hotkey 1, which I set to be Bash. It could be easily modded to use spells or other skills.

WARNING: Do not use this in zones where mobs which you will pass are kos to you and can kill you.

farm.mac:

Code: Select all

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| Farming
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

#event Farm_looting "You have slain#*#"
#event Farm_talk "#*#tells you#*#"

Sub Main(mob,loot)
   :startpoint
   /doevents
   /if (${Target.Name.Equal[${Me.Name}]}) {
      /delay 100
      /goto :startpoint
   }
   /squelch /target npc ${mob}
   /if (!${Target.ID}) /delay 10s
   /if (${Target.ID}) /call Combat
   /squelch /target clear
   /doevents Farm_looting
   /if (!${Me.FreeInventory}) {
      /beep
      /endmac
   }
   /if (${Me.PctHPs}<80) /call MedBreak
   /goto :startpoint
/return   

Sub Combat
   :combatloop
   /if (${Target.ID}) /face fast nolook
   /if (${Target.Distance}>7) {
      /face fast nolook
      /keypress forward hold
      :moveloop
      /if (${Target.ID}) /face fast nolook
      /if (${Me.PctHPs}<80) /call MedBreak
      /if (${Target.Distance}>7) /goto :moveloop
      /keypress forward
   }
   /if (${Me.AbilityReady[Bash]} && !${Me.Casting.ID}) /nomodkey /keypress 1
   /doevents
   /if (${Target.Distance}<15 && !${Me.Combat}) /keypress q
   /if (${Target.ID}) /goto :combatloop
/return

Sub Event_Farm_looting
   /declare x int local
   /target corpse radius 50
   /delay 5
   /face fast
   /delay 5
   /loot 
   /delay 2s
   /for x 1 to 5
      /if (${Corpse.Item[${x}].Name.Find[${loot}]} || ${Corpse.Item[${x}].Name.Find[all]}) {
         /itemnotify loot${x} rightmouseup
         /delay 1s
      }
   /next x
   /delay 5
   /notify LootWnd DoneButton leftmouseup 
   /delay 5
   /target clear
   /look
   /if (${Me.PctHPs}<80) /call MedBreak
/return

Sub Event_Farm_talk
   /beep
   /beep
   /if (${afkset}) {
      /camp
      /unload
   }
/return

Sub MedBreak
   /beep
   /beep
   /beep
   /target clear
   /keypress 9
   /if (!${Me.Sitting}) /sit
   :medloop
   /if (!${Me.Sitting}) /call Combat
   /delay 10
   /if (!${Me.Sitting}) /sit
   /delay 5s
   /if (${Me.PctHPs}<95 || ${Me.PctMana}<95) /goto :medloop
/return

neurocrime
decaying skeleton
decaying skeleton
Posts: 6
Joined: Sun Apr 29, 2007 11:18 pm

Doesnt loot item

Post by neurocrime » Mon Apr 30, 2007 4:50 am

Does not loot item.

Ive tried full and partial name of an item, as well as case sensitive.

Any help?

Thanks

NC

jacensolo
a snow griffon
a snow griffon
Posts: 427
Joined: Wed Feb 14, 2007 8:51 am
Location: Right behind you

Hmm....

Post by jacensolo » Mon Apr 30, 2007 6:47 am

I pulled it up a second ago to check it, and it seems you're right. I don't know how it happened, since thats the same code I farmed 5 or 6 backpacks of spider silks with, but its definitely just leaving corpses to rot now. I've gotta head off to work now, but when I get back this afternoon I'll see what I can do to fix this.

neurocrime
decaying skeleton
decaying skeleton
Posts: 6
Joined: Sun Apr 29, 2007 11:18 pm

Thanks

Post by neurocrime » Mon Apr 30, 2007 6:51 am

Appreciate that, look forward to reading the update.

NC

zanomo
a hill giant
a hill giant
Posts: 285
Joined: Thu Jun 24, 2004 11:21 pm

Post by zanomo » Mon Apr 30, 2007 8:33 am

May be:

Code: Select all

Sub Main

/declare mob  string outer ${param0}
/declare loot string outer ${param1}
...

neurocrime
decaying skeleton
decaying skeleton
Posts: 6
Joined: Sun Apr 29, 2007 11:18 pm

thanks

Post by neurocrime » Mon Apr 30, 2007 12:10 pm

I added the change, and got an error that the the name was already in use.

im assuming that the macro is setting 2 different variables with the same name, and that the macro would take further editing, but the concept, for many hours tonight, has evaded me.

NC

neurocrime
decaying skeleton
decaying skeleton
Posts: 6
Joined: Sun Apr 29, 2007 11:18 pm

Post by neurocrime » Mon Apr 30, 2007 3:12 pm

zanomo wrote:May be:

Code: Select all

Sub Main

/declare mob  string outer ${param0}
/declare loot string outer ${param1}
...
It is case sensitive, i found out, thanks to fearless and ccomp5950, as below:

Code: Select all

/declare mob  string outer ${Param0}
/declare loot string outer ${Param1}
[/code]

Thank you very much zanomo.
NC

jacensolo
a snow griffon
a snow griffon
Posts: 427
Joined: Wed Feb 14, 2007 8:51 am
Location: Right behind you

Argh...

Post by jacensolo » Mon Apr 30, 2007 11:53 pm

I spent over an hour trying to tweak the loot code, and ended up writing another complete version of the macro. This new version is makes much more logical sense to me, and I have added comments to explain each step it takes. I thought maybe my use of the ${Corpse} TLO was wrong, so I made this new macro pick up each item with /itemnotify loot${x} leftmouseup, and then evaluate the item while it's on the cursor. Unfortunately, I'm still experiencing the same problem. This time, it will pick up the item with leftmouseup, but fails to loot. It misses that line entirely, and destroys every drop. Then it tries to pick up the next item, and so on. At least now I think I've isolated the problem to one line, but for the life of me I can't figure out what I did wrong. Any help would be much appreciated.

Here's the new version: (Loot code is tested, and fails, rest of code is freshly written and untested. It probably has at least 1 or 2 dumb mistakes, but I can't get on EQ right now to test it.)

Code: Select all

|||
|
| Farming Macro by Jacen Solo
|
| Usage:  Type "/mac farm MobName LootName". You can use partial names, and for names longer than 1 word, use quotes.
| 	Using "all" for LootName will result in looting everything.
|
| !**!WARNING!**!
|	This macro includes a line that destroys the item on the cursor during looting, if it does not match with you loot parameters.
| 	I am usually not moving around items when I farm, but for those of you that do, be warned.
| !**!WARNING!**!
|e
|||

#chat tell
#event Killed "You have slain#*#"
Sub Main

 | Checks if MobName has been given. If not, ends macro.
   /if (!${Defined[Param0]}) {
      /echo No mob name defined.
      /endmacro
   }

 | Sets mob and loot variables. Defaults to loot all. If other LootName is given, uses that.
   /declare mob string outer ${Param0}
   /declare loot string outer all
   /if (${Defined[Param1]}) /varset loot ${Param1}

   :startpoint
   /doevents

 | If my health is below 50% and I don't have a target, will sit and med. (My code is set to use Hide. For classes without hide, just delete that line)
   /if (${Me.PctHPs}<50 && !${Target.ID}) {
      /doability Hide
      /sit
      /delay 20m (${Target.ID} || ${Me.PctHPs}==100)
   }

 | Checks to see if I have targeted myself. If so, waits until I am not the target. Lets me easily pause macro.
   /if (${Target.ID}==${Me.ID}) /delay 99999m (${Target.ID}!=${Me.ID})

 | If I don't have a target, try to target the mob I want.
   /if (!${Target.ID}) /squelch /target npc ${mob}
   /delay 5

 | If there aren't any mobs that match the MobName, delay, then start over.
   /if (!${Target.ID}) {
      /delay 1s
      /goto :startpoint
   }

 | Follows target.
   /if (${Target.Distance}>15 && ${Me.Combat}) /keypress q
   /if (${Target.ID}) /face fast nolook
   /if (${Target.Distance}>7) {
      /face fast nolook
      /keypress forward hold
      /goto :startpoint
   }
   /if (${Target.Distance}<8) /keypress forward

 | Fights mob. (Add any code here for spells or abilities you want it to use.)
   /if (${Target.ID} && !${Me.Combat} && ${Target.Distance}<10) /keypress q
   /if (${Me.AbilityReady[Bash]} && !${Me.Casting.ID}) /doability Bash

   /goto :startpoint
/return

| If you get a tell, beep twice.
Sub Event_Chat
   /beep
   /beep
/return

Sub Event_Killed
   /delay 5

 | Target the corpse. Wait for targetting. Open loot window. Wait for window to open.
   /target corpse   
   /delay 10m ${Target.ID}
   /loot
   /delay 10s ${Window[LootWnd].Open}
   /delay 1s

 | This is the block of code that handles keeping/trashing loot. The problem is somewhere in here.
   /declare x int local
   /for x 1 to ${Corpse.Items}

 | This picks up each item, then waits until it is picked up. This line works for me.
      /itemnotify loot${x} leftmouseup
      /delay 10s ${Cursor.ID}

 [color=red]| This checks to see if variable "loot" is set to loot all items, or if "loot" is found in the item name. The problem seems to be on this line.
      /if (${loot.Equal[all]} || ${Cursor.Name.Find[${loot}]}) /autoinventory[/color]
      /delay 1s

 | If item is still on cursor, meaning it didn't meet the above looting criteria, this destroys it.
      /if (${Cursor.ID}) /destroy

   /next x
   /notify LootWnd DoneButton leftmouseup
/return

bam
a ghoul
a ghoul
Posts: 149
Joined: Thu May 13, 2004 11:53 pm

Post by bam » Tue May 01, 2007 2:18 am

This macro includes a line that destroys the item on the cursor during looting, if it does not match with you loot parameters.
yah.. just say no to that logic.
Keep if unknown and destroy if known and dont want. How do you track this all you might say? OMG AN INI!!!!!

Go check out yafm its the easiest and best way to go. I dont want to misclick and destroy by Armor of the Uber!

neurocrime
decaying skeleton
decaying skeleton
Posts: 6
Joined: Sun Apr 29, 2007 11:18 pm

operates

Post by neurocrime » Tue May 01, 2007 5:05 am

This rewrite seems to work, with one exception...it also loots any item with the word "all" in the name. For example "small cloth gloves" etc. Its the same as your original with the exception of the /declare lines at top.
Once again Im an amateur, but looks like

Code: Select all

/if (${Corpse.Item[${x}].Name.Find[${loot}]} || ${Corpse.Item[${x}].Name.Find[all]}) {
is where this occurs.
Anyway thought it was heading in the right direction, it does seem to loot the correct item as well.

Code: Select all

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| Farming
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

#event Farm_looting "You have slain#*#"
#event Farm_talk "#*#tells you#*#"

Sub Main

/declare mob  string outer ${Param0}
/declare loot string outer ${Param1} 
   :startpoint
   /doevents
   /if (${Target.Name.Equal[${Me.Name}]}) {
      /delay 100
      /goto :startpoint
   }
   /squelch /target npc ${mob}
   /if (!${Target.ID}) /delay 10s
   /if (${Target.ID}) /call Combat
   /squelch /target clear
   /doevents Farm_looting
   /if (!${Me.FreeInventory}) {
      /beep
      /endmac
   }
   /if (${Me.PctHPs}<80) /call MedBreak
   /goto :startpoint
/return   

Sub Combat
   :combatloop
   /if (${Target.ID}) /face fast nolook
   /if (${Target.Distance}>7) {
      /face fast nolook
      /keypress forward hold
      :moveloop
      /if (${Target.ID}) /face fast nolook
      /if (${Me.PctHPs}<80) /call MedBreak
      /if (${Target.Distance}>7) /goto :moveloop
      /keypress forward
   }
   /if (${Me.AbilityReady[Bash]} && !${Me.Casting.ID}) /nomodkey /keypress 1
   /doevents
   /if (${Target.Distance}<15 && !${Me.Combat}) /keypress q
   /if (${Target.ID}) /goto :combatloop
/return

Sub Event_Farm_looting
   /declare x int local
   /target corpse radius 50
   /delay 5
   /face fast
   /delay 5
   /loot
   /delay 2s
   /for x 1 to 5
      /if (${Corpse.Item[${x}].Name.Find[${loot}]} || ${Corpse.Item[${x}].Name.Find[all]}) {
         /itemnotify loot${x} rightmouseup
         /delay 1s
      }
   /next x
   /delay 5
   /notify LootWnd DoneButton leftmouseup
   /delay 5
   /target clear
   /look
   /if (${Me.PctHPs}<80) /call MedBreak
/return

Sub Event_Farm_talk
   /beep
   /beep
   /if (${afkset}) {
      /camp
      /unload
   }
/return

Sub MedBreak
   /beep
   /beep
   /beep
   /target clear
   /keypress 9
   /if (!${Me.Sitting}) /sit
   :medloop
   /if (!${Me.Sitting}) /call Combat
   /delay 10
   /if (!${Me.Sitting}) /sit
   /delay 5s
   /if (${Me.PctHPs}<95 || ${Me.PctMana}<95) /goto :medloop
/return
[/code]

jacensolo
a snow griffon
a snow griffon
Posts: 427
Joined: Wed Feb 14, 2007 8:51 am
Location: Right behind you

Whoops. duh

Post by jacensolo » Tue May 01, 2007 6:49 am

Hmm... I don't know while it's doing that. Maybe naming my variable "loot" is conflicting with the "loot" slotnames on the corpse? I'll run some more tweaks through it later today.

And Bam, my question to you is, what are you trying to move while having it farm that you couldn't have time to autoinventory when it killed something, before it looted the corpse. Most of the time when I run this macro, the most moving around I do is to shuffle items that I've already looted. The macro would just autoinventory them again, because they STILL match the criteria. Also, as far as an INI to list known things I don't want, when I farm giants for lambent stones, the list of things I don't want is about 6 miles long. Far easier to destroy all else, knowing that I'm intelligent enough to not pick up my gear while it's farming for me.

jacensolo
a snow griffon
a snow griffon
Posts: 427
Joined: Wed Feb 14, 2007 8:51 am
Location: Right behind you

Found problem

Post by jacensolo » Thu May 03, 2007 8:56 am

The problem was eluding me for like 4 hours, I ran around in game trying to replicate what you said happened, to no avail. Then, thinking I might have missed something, I came back to look at the forum, and POOF, it hit me. I was running my tests with my new version, posted above, and the problem you found was from the original. Short version: you just need to replace the part that says ${Corpse.Item[${x}].Name.Find[all]} to ${loot.Equal[all]} . That should fix the problem.

warcriminal
decaying skeleton
decaying skeleton
Posts: 1
Joined: Tue Aug 28, 2007 2:53 pm

Post by warcriminal » Tue Aug 28, 2007 2:56 pm

This is a nice macro, and I've been using it, but I'm wondering if a leash function can be added into it?

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Tue Aug 28, 2007 3:06 pm

Yes, a leash function could be added to this.
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

big_daddy
a lesser mummy
a lesser mummy
Posts: 73
Joined: Thu Sep 15, 2005 8:29 pm

Post by big_daddy » Fri Jan 04, 2008 10:40 pm

There any way that can add 2 mobs names into the macro? If so can someone point me into the direction to be able to incorporate it into the macro? For example: I am killing Walrus and also want to kill Uthlok for faction.