Re: Yet Another Forage Macro - yafm
Posted: Sun Apr 05, 2020 11:18 pm
I did quite a bit of revamping to this to let you set the ini to DESTROY for the ones you want to destroy. It will handle multiple foraged items now with no issues. It will stop foraging while you are attacking, have an xtar 1 or 2, or if you are hovering. I may tweak it a bit more to have it as an include for my main autoassist macro, but for now it seems to be working pretty good.
Code: Select all
|yafm2.mac
|Version 2.12
|Yet Another Forage Macro
|Ini File: yafm2.ini
|
|DESTROY = destroy
|x = keep at most x of this item (can set this to anything except 0. 0 will think you don't have it and set it to DefatulMax)
|EXAMPLE INI Settings:
| [Default]
| MaxSave=1000
| [ForageList]
| Air-Infused Spring Water=1000
| Amber Water Worm=DESTROY
|
|New foraged items are added to the ini file automatically and are kept by default.
|
|Macro automatically ends when inventory is full to prevent infinite calls of HandleItem
|
|Release Notes
|v2.12 updated by pettdogg1
|Added some /echo options to let you know what you are foraged and quantities, could get crazier with this if we wanted
|Moved multiple foraged items outside of the handleitem function in to a While loop in the main function so it calls them in proper order
|Added a condition to halt foraging while you are fighting or have a mob on xtarget 1 or 2
#Event InventoryFull "#*#There are no open slots for the held item in your inventory.#*#"
||||||||||||||||||||
| Main
||||||||||||||||||||
sub Main
/echo ${Macro} is now running, enjoy the goodies!!!
/declare DefaultMaxSave int outer
/declare IAmForaging int outer 0 |Lets the macro know you are actually foraging and not just grabbing something, not perfect but it helps
/declare NumberOfItemsForaged int outer 0
/declare WasSitting int outer 0
/declare foragedItemCount int outer 0
/declare destroyedItemCount int outer 0
/declare keptItemCount int outer 0
| Set DefaultMaxSave from Ini
/varset DefaultMaxSave ${Ini[yafm2.ini,Default,MaxSave]}
| If the DefaultMaxSave is not in Ini, enter it
/if (!${DefaultMaxSave}) {
/ini "yafm2.ini" "Default" "MaxSave" "1000"
/varset DefaultMaxSave 1000
}
/echo DefaultMaxSave is ${DefaultMaxSave}
| Verify that we have the ability to forage.
/if (${Me.Skill[Forage]}==0) {
/echo You cannot forage, silly person!
/call Exit
}
|Main Forage Loop
:Forage
| If we can forage then do so as long as you are not fighting or have mobs on extended window
/if (${Me.AbilityReady[Forage]} && !${Me.CombatState.Equal[Combat]} && !${Me.XTarget[1].ID} && !${Me.XTarget[2].ID} && !${Me.Hovering}) {
| Stand up. Can't forage while sitting.
/if (${Me.State.Equal[SIT]}) {
/varset WasSitting 1
/stand
/delay 5
}
|Clears your cursor before attempting a forage
/if (${Cursor.ID}) {
/autoinventory
/delay 5
}
/doability forage
/varset IAmForaging 1
/delay 5
}
|If we successfully foraged something then take care of it. This works for multiple foraged items, hence the while loop.
/while (${Cursor.ID} && ${IAmForaging}) {
/call HandleItem ${Cursor.ID}
/varcalc foragedItemCount ${foragedItemCount}+1
}
/if ( ${WasSitting} && ${Me.Standing} ) {
/echo Sitting back down now.
/delay 2s
/sit
/varset WasSitting 0
}
/if ( ${IAmForaging} ) {
/echo So far you have foraged ${foragedItemCount} items
/echo You have kept ${keptItemCount} items
/echo You have destroyed ${destroyedItemCount} items
}
/varset IAmForaging 0
/goto :Forage
/return
||||||||||||||||||||
| HandleItem
||||||||||||||||||||
sub HandleItem(Item)
/declare ItemSetting int local
/declare ItemsHave int local
|Make sure item currently on cursor is the one we foraged
|Ensures we don't delete things we picked up between forages
/if (${Cursor.ID} == ${Item} && ${IAmForaging}) {
/if (${Ini[yafm2.ini,ForageList,${Cursor.Name}].Equal[DESTROY]}) {
|Look up this item in yafm2.ini and DESTROY it if it's set to DESTROY
/echo Destroying ${Cursor} per your INI Setting
/destroy
/varcalc destroyedItemCount ${destroyedItemCount}+1
} else /if (${Ini[yafm2.ini,ForageList,${Cursor.Name}]}) {
|Keep it if its under your set limit
/varset ItemSetting ${Ini[yafm2.ini,ForageList,${Cursor.Name}]}
/varset ItemsHave ${FindItemCount[=${Cursor}]}
/if (${ItemSetting}>${ItemsHave} && ${IAmForaging}) {
|This will keep the item if you don't have the number set in your ini
/echo You have ${ItemsHave} ${Cursor}. Keeping until ${ItemSetting}.
/autoinventory
|Check to see if our inventory is full
/doevents
/varcalc keptItemCount ${keptItemCount}+1
} else /if (${ItemSetting}<=${ItemsHave} && ${IAmForaging} && ${ItemSetting}>0) {
|This will destroy the item once it reaches the number in your ini
/echo Destroying ${Cursor} because you only wanted ${Math.Calc[${ItemSetting}-1]} and you have ${ItemsHave}
/destroy
/varcalc destroyedItemCount ${destroyedItemCount}+1
}
} else /if (!${ItemSetting} && ${IAmForaging}) {
|Adds it to your ini if you do not have it set yet
/ini "yafm2.ini" "ForageList" "${Cursor}" "${DefaultMaxSave}"
/echo Added ${Cursor} to ini, will keep ${ItemSetting} of them
/varcalc keptItemCount ${keptItemCount}+1
}
}
/delay 5
/return
||||||||||||||||||||
| Event_InventoryFull
||||||||||||||||||||
Sub Event_InventoryFull
/echo Inventory Full
/call Exit
/return
||||||||||||||||||||
| Exit
||||||||||||||||||||
Sub Exit
/echo Exiting
/endmacro
/return