Yet Another Forage Macro - yafm

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

Moderator: MacroQuest Developers

bootyjuice
decaying skeleton
decaying skeleton
Posts: 7
Joined: Fri Jan 23, 2004 11:44 am

Yet Another Forage Macro - yafm

Post by bootyjuice » Fri Apr 30, 2004 12:19 pm

Just another stupid forage macro with .ini file. Nothing special about this forage macro except that it's clean, simple, commented, and I've actually tested it.

Really it's a piece of junk. The only interesting feature is that it supports changes to the .ini file on the fly.

Let me know if anyone has any problems with it.

bootyjuice

Code: Select all

|yafm.mac 
|
|Yet Another Forage Macro
|
|Ini File: yafm.ini
|
| 0 = destroy
| 1 = keep
|
|New foraged items are added to the ini file automatically and are kept by default.


||||||||||||||||||||
| Main
||||||||||||||||||||
sub Main 

   /cleanup 

   | Verify that we have the ability to forage.
   /if (${Me.Skill[Forage]}==0) {
      /echo You cannot forage, silly person!
      /goto :Exit
   }

   :Forage 

   | Stand up.  Can't forage while sitting.
   /if (${Me.State.NotEqual[STAND]}) { 
      /stand 
      /delay 5 
   } 

   /delay 1s 

   | If we can forage then do so.
   /if (${Me.AbilityReady[Forage]}) {
      /doability forage 
   }

   | If we successfully foraged something then take care of it.
   /if (${Cursor.ID}) { 
      /call HandleItem
   }

   /goto :Forage 

:Exit
/return 

||||||||||||||||||||
| HandleItem
||||||||||||||||||||
sub HandleItem 

   /declare ItemSetting int local
   /declare NotFound int local 

   /varset NotFound -1

   | Look up this item in yafm.ini
   /varset ItemSetting ${Ini[yafm.ini,ForageList,${Cursor.Name},${NotFound}]}

   /delay 5 

   | If the item isn't in the .ini file then add it.
   /if (${ItemSetting}==${NotFound}) { 

      /ini "yafm.ini" "ForageList" "${Cursor.Name}" "1" 

      /varset ItemSetting 1

   }

   | If we're keeping this item then stash it in our bags.
   | Otherwise, just destroy it.
   /if (${ItemSetting}==1) {

      :LootIt
      /autoinventory 
      /delay 5 
      /if (${Cursor.ID}) /goto :LootIt 

   } else {

      /destroy 

   }

/return  
[/code]

A_Druid_00
Macro Maker Extraordinaire
Posts: 2378
Joined: Tue Jul 13, 2004 12:45 pm
Location: Rolling on the Lawn Farting

Post by A_Druid_00 » Mon Jul 19, 2004 2:10 pm

Love this macro for normal playing, but I added

Code: Select all

/delay 30s
before the stand up command so that I can use it while adventuring and still be able to do other things like mem spells, med for short periods, etc.
[quote]<DigitalMocking> man, A_Druid_00 really does love those long ass if statements
<dont_know_at_all> i don't use his macro because i'm frightened of it[/quote]
[quote][12:45] <dont_know_at_all> never use a macro when you can really fuck up things with a plugin[/quote]

PhoenixZorn
Macro Czar
Posts: 127
Joined: Fri Dec 12, 2003 2:20 pm
Contact:

Post by PhoenixZorn » Mon Aug 30, 2004 12:48 pm

This macro is my choice for the MQ2 Forage macro. It will be packaged with the OOW release. Bootyjuice, please clean it up JUST A LITTLE... I like tight little macros... and while yours is clean, it isn't tight... too many spaces. =)

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Mon Aug 30, 2004 1:25 pm

It wouldn't take much to make this an INC so that you could run your normal macro.

Code: Select all

|** 8/30/04
 yafm.mac 
 Yet Another Forage Macro 
 Ini File: yafm.ini 
 0 = destroy 
 1 = keep 
 Originally created by bottyjuice, modified by aChallenged to include a toggle.
 New foraged items are added to the ini file automatically and are kept by default.
 You will need a hotkey as follows to toggle it in game.

 HOTKEY toggle switch:
 Page2Button2Name=FrgSwch
 Page2Button2Color=15
 Page2Button2Line1=/docommand ${If[${Forage},/varset Forage 0,/varset Forage 1]}
**|


|||||||||||||||||||| 
| Main 
|||||||||||||||||||| 
sub Main 

/declare Forage int outer
/varset Forage 1

   /cleanup 
   | Verify that we have the ability to forage. 
   /if (${Me.Skill[Forage]}==0) { 
      /echo You cannot forage, silly person! 
      /goto :Exit 
   } 

   :Forage 
   | Stand up.  Can't forage while sitting. 
   /if (${Me.State.NotEqual[STAND]}) { 
      /stand 
      /delay 5 
   } 
   /delay 1s 
   | If we can forage then do so. 
   /if ( ${Forage}==1 && ${Me.AbilityReady[Forage]}) { 
      /doability forage 
   } 
   | If we successfully foraged something then take care of it. 
   /if (${Cursor.ID}) { 
      /call HandleItem 
   } 
   /goto :Forage 

:Exit 
/return 
|||||||||||||||||||| 
| HandleItem 
|||||||||||||||||||| 
sub HandleItem 

   /declare ItemSetting int local 
   /declare NotFound int local 
   /varset NotFound -1 
   | Look up this item in yafm.ini 
   /varset ItemSetting ${Ini[yafm.ini,ForageList,${Cursor.Name},${NotFound}]} 
   /delay 5 
   | If the item isn't in the .ini file then add it. 
   /if (${ItemSetting}==${NotFound}) { 
      /ini "yafm.ini" "ForageList" "${Cursor.Name}" "1" 
      /varset ItemSetting 1 
   } 
   | If we're keeping this item then stash it in our bags. 
   | Otherwise, just destroy it. 
   /if (${ItemSetting}==1) { 
      :LootIt 
      /autoinventory 
      /delay 5 
      /if (${Cursor.ID}) /goto :LootIt 
   } else { 
      /destroy 
   } 

/return
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

mdar
orc pawn
orc pawn
Posts: 23
Joined: Mon Aug 16, 2004 2:26 pm

Post by mdar » Tue Aug 31, 2004 1:39 pm

Just to really mess the thread up - here's another version...

Changes:
* Moved item handling into main loop - items are only cleared from cursor immediately after forage.
* Changed keep/delete ini to keep at max... Setting of 0 will destroy all, setting of 20 will keep at most one stack, and delete any additional. Set roots=20 to always stay fed, but not overflowing with roots...
* Added defaultmax, this is the number that will automatically be saved for a new item type.
******WARNING****** DO NOT set defaultmax to 0. If you are using your inventory when a forage happens, it will on occasion treat an item you have in your hand as a forage result, and as such, will be added into your ini file. If DefaultMax = 0, the item will be DELETED.

Code: Select all

|yafm.mac
|
|Yet Another Forage Macro
|
|Ini File: yafm.ini
|
| 0 = destroy
| x = keep at most x of this item
|
|New foraged items are added to the ini file automatically and are kept by default.


||||||||||||||||||||
| Main
||||||||||||||||||||
sub Main

    /declare DefaultMaxSave int outer

    /varset DefaultMaxSave ${Ini[yafm.ini,Default,MaxSave,${NotFound}]}
    /if (${DefaultMaxSave}==${NotFound}) {
    	/ini "yafm.ini" "Default" "MaxSave" "100"
        /varset DefaultMaxSave 100
    }

   /cleanup

   | Verify that we have the ability to forage.
   /if (${Me.Skill[Forage]}==0) {
      /echo You cannot forage, silly person!
      /goto :Exit
   }

   :Forage

   | If we can forage then do so.
   /if (${Me.AbilityReady[Forage]}) {
	   | Stand up.  Can't forage while sitting.
	   /if (${Me.State.NotEqual[STAND]}) {
	      /stand
	      /delay 5
	   }

      /doability forage
   }

   | If we successfully foraged something then take care of it.
   /if (${Cursor.ID}) {
      /call HandleItem
   }

   /goto :Forage

:Exit
/return

||||||||||||||||||||
| HandleItem
||||||||||||||||||||
sub HandleItem

	/declare ItemSetting int local
	/declare NotFound int local
	/declare ItemsHave int local

	/varset NotFound -1

	:LootIt

	| Look up this item in yafm.ini
	/varset ItemSetting ${Ini[yafm.ini,ForageList,${Cursor.Name},${NotFound}]}
	/delay 5

	| If the item isn't in the .ini file then add it.
	/if (${ItemSetting}==${NotFound}) {
	    /ini "yafm.ini" "ForageList" "${Cursor.Name}" "${DefaultMaxSave}"
	    /varset ItemSetting ${DefaultMaxSave}
	}

	/varset ItemsHave ${FindItem=${Cursor.Name}}

	| If we're keeping this item then stash it in our bags.
	| Otherwise, just destroy it.
	/if (${ItemSetting}>=${ItemsHave}) {
	  /autoinventory
	} else {
	  /destroy
	}

	/delay 5
	/if (${Cursor.ID}) /goto :LootIt

/return

Skate4mindgame
decaying skeleton
decaying skeleton
Posts: 4
Joined: Sat Mar 06, 2004 11:51 pm

Post by Skate4mindgame » Mon Sep 06, 2004 1:24 pm

Macro isnt destroying items i have set to "0" for some reason any suggestions? It is just throwing everything in my inventory

[Default]
MaxSave=100
[ForageList]
Roots=0
Bookworm=0
Pod of Water=0
Miller Carrot=0
Berries=100
Vegetables=100
Fishing Grubs=0
Fruit=100
Griffon Eggs=100
Rabbit Meat=100

There's my ini file if you see any problems.

Moeymoejoe
a snow griffon
a snow griffon
Posts: 363
Joined: Sun Jul 18, 2004 10:17 pm

Post by Moeymoejoe » Sun Sep 19, 2004 11:01 am

To fix the Mdar code repalce :
/varset ItemsHave ${FindItem=${Cursor.Name}}

with

/varset ItemsHave ${FindItemCount[=${Cursor.Name}]}

(i havent tested, but think this will work)

User avatar
peach
a hill giant
a hill giant
Posts: 156
Joined: Fri Sep 10, 2004 8:20 pm

Post by peach » Sun Sep 19, 2004 10:32 pm

mdar's wont work for me, it doesnt destroy anything set to 0 and it doesnt destroy anything when it exceeds the set amount

User avatar
Fibby
a lesser mummy
a lesser mummy
Posts: 58
Joined: Mon Nov 15, 2004 2:18 am

Post by Fibby » Sat Nov 27, 2004 6:07 pm

I modified the forage loop so that I could run it more or less full time..

Code: Select all

   :Forage

   /delay 1s

   | If we can forage then do so.
   /if (${Me.AbilityReady[Forage]}) {
      /if (!${Me.Combat}) {
      	  /varset lv_CurState ${Me.State}
      	  /stand
      	  /delay 2
          /doability forage
          /if (${String[${lv_CurState}].Equal[SIT]}) {
              /sit
          }
      }
   }

   | If we successfully foraged something then take care of it.
   /if (${Cursor.ID}) {
      /call HandleItem
   }

   /goto :Forage
True genius is not knowing all the answers
It's knowing where to find them.

User avatar
Jon100
a hill giant
a hill giant
Posts: 161
Joined: Mon Sep 22, 2003 6:15 am
Location: UK

Post by Jon100 » Thu Dec 02, 2004 4:18 am

There's a small bug in the logic that means you always loot one more item than you set in your ini. This means if you set your rabbit meat=0 it will still loot one, and if you set it to 20, you loot 21.

I was wondering for ages why it always seemed to keep a single rabbit meat and pod of water :)

change:

Code: Select all

   /if (${ItemSetting}>=${ItemsHave}) { 
to:

Code: Select all

   /if (${ItemSetting}>${ItemsHave}) { 

Twen
orc pawn
orc pawn
Posts: 19
Joined: Fri Dec 10, 2004 1:41 pm

Post by Twen » Thu Feb 24, 2005 12:22 pm

just curious cant read code well but, does yafm take into effect natures bounty aa? chance to forage 2 items with one forage attempt?

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Thu Feb 24, 2005 1:01 pm

Under HandleItem in the code it should autoinventory or destroy until cursor is clear.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

User avatar
FallenAngel
decaying skeleton
decaying skeleton
Posts: 3
Joined: Thu Feb 10, 2005 6:41 pm

Post by FallenAngel » Thu Feb 24, 2005 7:35 pm

this works fairly well however it keeps autoinventoring anything i pick up lol even when not foraging what would be the best way to fix it so it only autoinventories when foraging? and not when i pick up an item from my bags. :?:
thanks in advance lol and i hope im not missing something easy
FallenAngel

Heaven doesnt want her, and Hell is afraid she will take over.

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Thu Feb 24, 2005 7:51 pm

Search: autoskills plugin
If you are VIP also search autodestroy
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

User avatar
FallenAngel
decaying skeleton
decaying skeleton
Posts: 3
Joined: Thu Feb 10, 2005 6:41 pm

Post by FallenAngel » Thu Feb 24, 2005 7:57 pm

thank you challenged =)
FallenAngel

Heaven doesnt want her, and Hell is afraid she will take over.