Page 1 of 1

Yet another foraging macro

Posted: Sun May 02, 2004 12:15 pm
by Glasscoin
Here's Mr. Coin's forage macro.

What it'll do:
- Wait until your cursor is empty before doing any forages (so you won't have to worry about any important items that might be on your cursor being destroyed!)
- Stand, if you're sitting, and turn off auto-attack before attempting to forage.
- Turn on attack if you were previously attacking and sit if you were previously sitting after foraging.
- Use an *.ini file to see whether to keep or destroy any foraged items.
- Keep track of the total number of forages and total number of each item foraged in the zone by you (you guys might not find it useful, but I like it because it allows me to know which zones have the best yield for certain desirable items).

What it won't do:
- Keep a specified number of any particular item, based on the value in the *.ini file (a lot of other forage macros have this, but I don't eat/drink foraged items, so it wasn't really necessary for me. I'll add it in if anyone wants it, though.)
- Keep ANY water or food you forage if you're out of drink or food, respectively. This will be added to a future release when ${Me.Hunger/Thirst} is fixed.

And now, the good stuff.

Forage.mac:

Code: Select all

Sub Main

   | Forage.mac... Do we *really* need another one?
   | Auto-forage macro with INI support and stat tracking
   | 05.02.2004 by Glasscoin

   /declare wasSitting    bool outer FALSE
   /declare wasAttacking  bool outer FALSE
   /declare totForage     int  outer 0
   /declare newForage     int  outer 0

   /echo Nature calls.  Let's pick up food off the ground and eat it!

   :Loop

   /delay 1s

   /if (${Me.AbilityReady["Forage"]}) {

      /if (${Cursor.ID}) {

         /if (${Me.FreeInventory[4]}>=1) {
            /echo Forage ready, but item on cursor.  Dropping to inventory.
            /autoinventory
         }

      } else {

         /varset wasSitting FALSE
         /varset wasAttacking FALSE

         /if (${Me.Combat}) {
            /varset wasAttacking TRUE
            /attack off
         }

         /if (${Me.Sitting}) {
            /varset wasSitting TRUE
            /stand
         }

         /delay 5
         /doability "Forage"

         /if (${wasAttacking}) /attack on
         /if (${wasSitting}) /sit

         /delay 2s

         /if (${Cursor.ID}) {

            /if (${Ini[forage_stats.log,${Zone.Name},"Total Forages"].Equal["NULL"]}) {
               /varset totForage 0
            } else {
               /varset totForage ${Ini[forage_stats.log,${Zone.Name},"Total Forages"]}
            }

            /if (${Ini[forage_stats.log,${Zone.Name},${Cursor.Name}].Equal["NULL"]}) {
               /varset newForage 0
            } else {
               /varset newForage ${Ini[forage_stats.log,${Zone.Name},${Cursor.Name}]}
            }

            /varset totForage ${Math.Calc[${totForage}+1]}
            /varset newForage ${Math.Calc[${newForage}+1]}

            /ini "forage_stats.log" "${Zone.Name}" "Total Forages" "${totForage}"
            /ini "forage_stats.log" "${Zone.Name}" "${Cursor.Name}" "${newForage}"

            /if (${Ini[forage.ini,${Zone.Name},${Cursor.Name}].Equal["-1"]} || ${Ini[forage.ini,"Global",${Cursor.Name}].Equal["-1"]}) {
               /autoinventory
            } else /if (${Ini[forage.ini,${Zone.Name},${Cursor.Name}].Equal["0"]} || ${Ini[forage.ini,"Global",${Cursor.Name}].Equal["0"]}) {
               /destroy
            } else /if (${Ini[forage.ini,${Zone.Name},${Cursor.Name},NULL].Equal[NULL]} || ${Ini[forage.ini,"Global",${Cursor.Name},NULL].Equal[NULL]}) {
               /ini "forage.ini" "${Zone.Name}" "${Cursor.Name}" "-1"
               /autoinventory
            } else {
               /if (${FindItemCount[=${Cursor.Name}]}>${Ini[forage.ini,${Zone.Name},${Cursor.Name},99]} || ${FindItemCount[=${Cursor.Name}]}>${Ini[forage.ini,"Global",${Cursor.Name},99]}) {
                  /destroy
               } else {
                  /autoinventory
               }
            }

         }

      }
   }
   /goto :Loop

/endmacro
Edit: Okay, updated so that it won't freeze if you have an item on your cursor, it'll now autoinventory the item if you have space. Also changed it so -1 is keep all, 0 is destroy, and any higher number will keep that number of items.

However, even with the updates, I'd highly recommend Preoct's foraging macro. Does everything this does, but better.

please!

Posted: Tue May 18, 2004 12:05 pm
by shadowdragon
i would love the mac with a setting for keeping a certain number of items! i use my druid to forage for baking and those pods of water take up too much space! will check back here regularly and ahead of time, THANK YOU for the time!!

Re: please!

Posted: Tue May 18, 2004 1:31 pm
by Chill
shadowdragon wrote:i would love the mac with a setting for keeping a certain number of items!
One simple non-macro solution to that problem...fill up all your available inventory slots with 1 unstacked piece of the item(s) you want. As you forrage more of those item(s) the stacks will fill up. Unwanted items, such as your Pods of Water, will fall to the ground once your 1 or 2 stacks of them fill up.

Posted: Tue May 18, 2004 2:24 pm
by Preocts
Actually, with this macro it would be as easy as adding two more if statements.

A little rewritten but this outta work.

Code: Select all

/if (${Ini[forage.ini,${Zone.Name},${Cursor.Name}].Equal["1"]} || ${Ini[forage.ini,"Global",${Cursor.Name}].Equal["1"]}) {
  /autoinventory
} else /if (${Ini[forage.ini,${Zone.Name},${Cursor.Name}].Equal["0"]} || ${Ini[forage.ini,"Global",${Cursor.Name}].Equal["0"]}) {
  /destroy
} else /if (${Ini[forage.ini,${Zone.Name},${Cursor.Name},NULL].Equal[NULL]} || ${Ini[forage.ini,"Global",${Cursor.Name},NULL].Equal[NULL]}) {
  /ini "forage.ini" "${Zone.Name}" "${Cursor.Name}" "1"
  /autoinventory
} else {
  /if (${FindItemCount[=${Cursor.Name}]}>${Ini[forage.ini,${Zone.Name},${Cursor.Name},99]} || ${FindItemCount[=${Cursor.Name}]}>${Ini[forage.ini,"Global",${Cursor.Name},99]}) {
    /destroy
  } else {
    /autoinventory
  }
}

Posted: Wed May 19, 2004 4:38 pm
by shadowdragon
after some major searching i went with the forage mac you put up for me Preocts, does everything i want all in one package, thanks for the replies!

Anyone having a problem with this mac?

Posted: Wed Jun 02, 2004 1:40 pm
by VirusX
Im having a problem with this. It seems to "lock" when I get a lag spike. Its like the timing is throw off for the autoinventory and I end up keeping the item I forage in my hand and it stops foraging basically. Anyone had this problem?

Posted: Wed Jun 02, 2004 8:08 pm
by Glasscoin
Updated with various improvements, but I'd recommend using Preoct's macro over this one.