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
However, even with the updates, I'd highly recommend Preoct's foraging macro. Does everything this does, but better.


