Moderator: MacroQuest Developers
Code: Select all
Sub Main
:Loop
/if (${Cursor.ID}) /autoinventory
/if (${Me.AbillityReady[Forage]}) /doability Forage
/goto :Loop
/returnCode: Select all
Sub Main
:Loop
/if (${Cursor.ID}) /multiline ; /autoi ; /goto :Loop
/if (${Me.AbilityReady[Forage]}) /multiline ; /doability Forage ; /goto :Loop
/return
Code: Select all
/if (${Me.AbilityReady[Forage]}) /multiline ; /doability Forage ; /goto :LoopCode: Select all
/multiline ; /if (${Me.AbilityReady[Forage]}) /doability Forage ; /goto :LoopCode: Select all
Sub Main
:loop
/multiline ; /if (${Cursor.ID}) /autoinv ; /if (${Me.AbilityReady[Forage]}) /doability Forage ; /goto :Loop
/return
Code: Select all
Main Sub
:loop
% ^ #[!@#%$@] :loopCode: Select all
#Event Foraged "#*#You have scrounged#*#"
#Event ForageFail "#*#You fail to locate any food nearby.#*#"
Sub Main
/declare GeneralTimeout timer outer 0
/declare IniFileName string outer ${Me.Name}_IniFile.ini
:MainLoop
/call Main_AutoForage
/goto :MainLoop
/return
Sub Main_AutoForage
/if (${Me.AbilityReady["Forage"]}) {
/if (${Me.Combat}) {
/attack off
/delay 1s !${Me.Combat}
/declare SetCombat int local 1
}
| 2) Massive check for all contitions that prevent foraging.
/if (!${Me.Mount.ID} && !${Me.Casting.ID} && !${Window[SpellBookWnd].Open} && !${Me.Combat} && !${Window[LootWnd].Open} && !${Window[BigBankWnd].Open} && !${Cursor.ID} && !${Window[MerchantWnd].Open}) {
/varset GeneralTimeout 5s
/if (${Me.Sitting}) {
/sit
/delay 5
/doability "Forage"
/sit
} else {
/doability "Forage"
}
/ini "${IniFileName}" "ForageStats" "Attempts" "${Math.Calc[${Ini[${IniFileName},ForageStats,Attempts,0]}+1]}"
:ForageWaitLoop
/doevents Foraged
/doevents ForageFailed
/delay 1
/if (${Macro.Return.NotEqual[FORAGE_DONE]} && ${GeneralTimeout}) /goto :ForageWaitLoop
/call ClearReturn
}
/if (${Defined[SetCombat]}) /attack on
}
/return
|// ------------BEGIN FORAGE--------------
Sub Event_Foraged
| Sub Event_Foraged ()
| For use with an Event that is tiggered on successful forage attempt.
| Returns: FORAGE_DONE on all exits
/call IniScan Forage 0
/return FORAGE_DONE
Sub Event_ForageFail
| Sub Event_ForageFail ()
| For use with an event triggered on failed forage attempt
| Returns: FORAGE_DONE on all exits
/ini "${IniFileName}" "ForageStats" "Failures" "${Math.Calc[${Ini[${IniFileName},ForageStats,Failures,0]}+1]}"
/return FORAGE_DONE
|// ------------ END FORAGE --------------
|// ------------BEGIN SHARED--------------
Sub IniScan(SkillName,EmptyCursor)
| Sub IniScan (SkillName,EmptyCursor)
| For use with an Ini. Scans ini for item on cursor and controls action for that item.
| Stats are written to ini in Key [SkillName]Stats. Item information is written/read from key [ItemList]
| If EmptyCursor is set to 1 then no stats are written to the INI
| Returns: DONE on all exits
| Required Subs: Sub HandleCursor (Command;ItemName)
:WaitForEQ
/if (!${GeneralTimeout}) /return DONE
/if (!${Cursor.ID}) /goto :WaitForEQ
/declare ItemName string local ${Cursor.Name}
/declare ItemID int local ${Cursor.ID}
/ini "${IniFileName}" "Settings" "LastItem${SkillName}" "${ItemName}"
/ini "${IniFileName}" "${SkillName}Totals" "${ItemName}" "${Math.Calc[${Ini[${IniFileName},${SkillName}Totals,${ItemName},0]}+1]}"
/if (!${EmptyCursor}) /ini "${IniFileName}" "${SkillName}Stats" "Success" "${Math.Calc[${Ini[${IniFileName},${SkillName}Stats,Success,0]}+1]}"
| Run a quick check to see if we've ever found this before.
/if (${Ini[${IniFileName},ItemList,${ItemName},NOTFOUND].Equal[NOTFOUND]}) {
/if (${Ini[${IniFileName},Settings,Noise,0]}) /echo Just found << ${ItemName} >> ! Never seen this before. Adding to the list and keeping all of them by default.
/ini "${IniFileName}" "ItemList" "${ItemName}" "-1"
}
| Check to see what to do with this item. Notice default is -1. This is to help prevent destruction of equipment.
/if (${Ini[${IniFileName},ItemList,${ItemName},-1]}) {
| Is there a set max-keep value and how many do we have? If we have too many, send a destroy call.
/if (${Ini[${IniFileName},ItemList,${ItemName},-1]}!=-1) {
/if (${FindItemCount[=${ItemName}]}>=${Ini[${IniFileName},ItemList,${ItemName},-1]}) {
/if (${Ini[${IniFileName},Settings,Noise,0]}) /echo Just found << ${ItemName} >> but we have too many. Destroying it.
/goto :Destroy
}
}
/if (${Ini[${IniFileName},Settings,Noise,0]}) /echo Just found << ${ItemName} >> and I'm sending it to the inventory.
/if (!${EmptyCursor}) /ini "${IniFileName}" "${SkillName}Stats" "Keep" "${Math.Calc[${Ini[${IniFileName},${SkillName}Stats,Keep,0]}+1]}"
/call HandleCursor Loot;${ItemID}
} else {
/if (${Ini[${IniFileName},Settings,Noise,0]}) /echo Just found << ${ItemName} >> but we don't want it. Destroying it.
:Destroy
/if (!${EmptyCursor}) /ini "${IniFileName}" "${SkillName}Stats" "Destroy" "${Math.Calc[${Ini[${IniFileName},${SkillName}Stats,Destroy,0]}+1]}"
/call HandleCursor Destroy;${ItemID}
}
/return DONE
Sub HandleCursor
| Sub HandleCursor (Command;ItemID)
| Does a given command with a given item if and only if that item is currently on the cursor. CHECKS BY ${CURSOR.ID} !!!
| Commands: Destroy -- will destroy item
| Loot -- will loot item
:ReDo
/if (!${Param0.Arg[2,;].Length}) /return
/if (${Cursor.ID}!=${Param0.Arg[2,;]}) /return
/if (${Param0.Arg[1,;].Equal["Destroy"]}) /destroy
/if (${Param0.Arg[1,;].Equal["Loot"]}) /autoinven
/delay 5
/if (!${Cursor.ID}) /return
/if (${Cursor.ID}==${Param0.Arg[2,;]}) /goto :ReDo
/return
Sub ClearReturn
| Sub ClearReturn ""
| Clears ${Macro.Return} of any value
/return ""

Code: Select all
#Event Foraged "#*#You have scrounged#*#"
#Event ForageFail "#*#You fail to locate any food nearby.#*#"
Sub Main
/declare GeneralTimeout timer outer 0
/declare IniFileName string outer ${Me.Name}_IniFile.ini
:MainLoop
/call Main_AutoForage
/goto :MainLoop
/return
Sub Main_AutoForage
/if (${Me.AbilityReady["Forage"]}) {
/if (${Me.Combat}) {
/attack off
/delay 1s !${Me.Combat}
/declare SetCombat int local 1
}
| 2) Massive check for all contitions that prevent foraging.
/if (!${Me.Mount.ID} && !${Me.Casting.ID} && !${Window[SpellBookWnd].Open} &&
!${Me.Combat} && !${Window[LootWnd].Open} && !${Window[BigBankWnd].Open} && !${Cursor.ID} &&
!${Window[MerchantWnd].Open}) {
/varset GeneralTimeout 5s
/if (${Me.Sitting}) {
/sit
/delay 5
/doability "Forage"
/sit
/delay 5
/autoinventory
} else {
/doability "Forage"
/delay 5
/autoinventory
}
/ini "${IniFileName}" "ForageStats" "Attempts"
"${Math.Calc[${Ini[${IniFileName},ForageStats,Attempts,0]}+1]}"
:ForageWaitLoop
/doevents Foraged
/doevents ForageFailed
/delay 1
/if (${Macro.Return.NotEqual[FORAGE_DONE]} && ${GeneralTimeout}) /goto
:ForageWaitLoop
/call ClearReturn
}
/if (${Defined[SetCombat]}) /attack on
}
/return
|// ------------BEGIN FORAGE--------------
Sub Event_Foraged
| Sub Event_Foraged ()
| For use with an Event that is tiggered on successful forage attempt.
| Returns: FORAGE_DONE on all exits
/call IniScan Forage 0
/return FORAGE_DONE
Sub Event_ForageFail
| Sub Event_ForageFail ()
| For use with an event triggered on failed forage attempt
| Returns: FORAGE_DONE on all exits
/ini "${IniFileName}" "ForageStats" "Failures"
"${Math.Calc[${Ini[${IniFileName},ForageStats,Failures,0]}+1]}"
/return FORAGE_DONE
|// ------------ END FORAGE --------------
|// ------------BEGIN SHARED--------------
Sub IniScan(SkillName,EmptyCursor)
| Sub IniScan (SkillName,EmptyCursor)
| For use with an Ini. Scans ini for item on cursor and controls action for that item.
| Stats are written to ini in Key [SkillName]Stats. Item information is written/read from
key [ItemList]
| If EmptyCursor is set to 1 then no stats are written to the INI
| Returns: DONE on all exits
| Required Subs: Sub HandleCursor (Command;ItemName)
:WaitForEQ
/if (!${GeneralTimeout}) /return DONE
/if (!${Cursor.ID}) /goto :WaitForEQ
/declare ItemName string local ${Cursor.Name}
/declare ItemID int local ${Cursor.ID}
/ini "${IniFileName}" "Settings" "LastItem${SkillName}" "${ItemName}"
/ini "${IniFileName}" "${SkillName}Totals" "${ItemName}"
"${Math.Calc[${Ini[${IniFileName},${SkillName}Totals,${ItemName},0]}+1]}"
/if (!${EmptyCursor}) /ini "${IniFileName}" "${SkillName}Stats" "Success"
"${Math.Calc[${Ini[${IniFileName},${SkillName}Stats,Success,0]}+1]}"
| Run a quick check to see if we've ever found this before.
/if (${Ini[${IniFileName},ItemList,${ItemName},NOTFOUND].Equal[NOTFOUND]}) {
/if (${Ini[${IniFileName},Settings,Noise,0]}) /echo Just found >;>; ${ItemName} << !
Never seen this before. Adding to the list and keeping all of them by default.
/ini "${IniFileName}" "ItemList" "${ItemName}" "-1"
}
| Check to see what to do with this item. Notice default is -1. This is to help prevent
destruction of equipment.
/if (${Ini[${IniFileName},ItemList,${ItemName},-1]}) {
| Is there a set max-keep value and how many do we have? If we have too many, send a
destroy call.
/if (${Ini[${IniFileName},ItemList,${ItemName},-1]}!=-1) {
/if (${FindItemCount[=${ItemName}]}<=${Ini[${IniFileName},ItemList,${ItemName},-1]}) {
/if (${Ini[${IniFileName},Settings,Noise,0]}) /echo Just found >> ${ItemName} << but
we have too many. Destroying it.
/goto :Destroy
}
}
/if (${Ini[${IniFileName},Settings,Noise,0]}) /echo Just found >> ${ItemName} << and I'm
sending it to the inventory.
/if (!${EmptyCursor}) /ini "${IniFileName}" "${SkillName}Stats" "Keep"
"${Math.Calc[${Ini[${IniFileName},${SkillName}Stats,Keep,0]}+1]}"
/call HandleCursor Loot;${ItemID}
} else {
/if (${Ini[${IniFileName},Settings,Noise,0]}) /echo Just found >> ${ItemName} << but we
don't want it. Destroying it.
:Destroy
/if (!${EmptyCursor}) /ini "${IniFileName}" "${SkillName}Stats" "Destroy"
"${Math.Calc[${Ini[${IniFileName},${SkillName}Stats,Destroy,0]}+1]}"
/call HandleCursor Destroy;${ItemID}
}
/return DONE
Sub HandleCursor
| Sub HandleCursor (Command;ItemID)
| Does a given command with a given item if and only if that item is currently on the
cursor. CHECKS BY ${CURSOR.ID} !!!
| Commands: Destroy -- will destroy item
| Loot -- will loot item
:ReDo
/if (!${Param0.Arg[2,;].Length}) /return
/if (${Cursor.ID}!=${Param0.Arg[2,;]}) /return
/if (${Param0.Arg[1,;].Equal["Destroy"]}) /destroy
/if (${Param0.Arg[1,;].Equal["Loot"]}) /autoinven
/delay 5
/if (!${Cursor.ID}) /return
/if (${Cursor.ID}==${Param0.Arg[2,;]}) /goto :ReDo
/return
Sub ClearReturn
| Sub ClearReturn ""
| Clears ${Macro.Return} of any value
/return ""
