Moderator: MacroQuest Developers

Code: Select all
| There are only two sections of the ini file for this macro and they are described below.
|
|
| The bufs section is the list of buffs you want to keep on the toon while he forages.
| MAKE SURE YOU HAVE THESE SPELLS MEMORIZED!!!!!
| It is best to list the invis spell last or it will get recast until all buffs are done.
|
| [Bufs]
| Buf1=Nature's Might
| Buf2=Protection of the Cabbage
| Buf3=Improved Superior Camouflage
|
|
| The forage section lists all the items you want to DESTORY!!!
| Don't list an item here if you want to keep it.
|
| [Forage]
| Dest1=Ripened Mango
| Dest2=Fresh Tree Sap
| Dest3=Bark Bindings
#turbo
#define INIPATH "autoforage.ini"
#include routines.mac
#event Appear "You appear."
#event Interrupt "Your spell is interrupted."
#event Fizzle "Your spell fizzles!"
#event Recover "You haven't recovered yet..."
Sub Main
/call DefineGlobals
/call DoLog "Starting to forage in $zone."
:loop
/call CheckBufs
/call Forage
/delay 3s
/goto :loop
/endmacro
Sub CheckDestroy
/declare i local
/if n @NumForage==0 /return
/for i 1 to @NumForage
/if $cursor()=="TRUE" {
/if n @i==1 /call DoLog "I foraged a '$cursor(name)'."
/if "$cursor(name)"=="@forage(@i)" {
/call DoLog "I am destroying $cursor(name)."
/if $invpanel!=TRUE /press I
/click left destroy
/call WaitForDrop
}
}
/next i
/if $invpanel==TRUE /press I
/return
Sub Forage
/if n $char(ability,"Forage")!=-2 {
/doability "Forage"
/call WaitForPickup
/call CheckDestroy
/call putaway
}
/return
Sub CheckBufs
/declare i local
/if n @NumBufs==0 /return
/for i 1 to @NumBufs
/if n $char(buff,"@bufs(@i)")==0 /call Rebuf
/next i
/return
Sub ReBuf
/declare i local
/if n @NumBufs==0 /return
/press F1
/sendkey up up
/delay 1s
:DoOver
/varset Zone 0
/for i 1 to @NumBufs
:DoOver
/if n $char(buff,"@bufs(@i)")==0 {
/call DoLog "Casting @bufs(@i)."
/cast "@bufs(@i)"
/call WaitForSpell
/doevents
/if n @Zone==1 /goto :DoOver
}
/next i
/varset Zone 0
/return
Sub Event_Appear
/sendkey up up
/varset Zone 1
/return
Sub Event_Interrupt
/sendkey up up
/varset Zone 1
/return
Sub Event_Fizzle
/sendkey up up
/varset Zone 1
/return
Sub Event_Recover
/sendkey up up
/varset Zone 1
/return
Sub LoadForage
/varset NumForage 0
:Loop
/varadd NumForage 1
/varset forage(@NumForage) "$ini("INIPATH","Forage","Dest$int(@NumForage)")"
/if "@forage(@NumForage)"=="NOTFOUND" {
/varsub NumForage 1
/goto :End
}
/call DoLog "Loaded $ini("INIPATH","Forage","Dest$int(@NumForage)") into array"
/goto :Loop
:End
/call DoLog "NumForage = @NumForage"
/return
Sub LoadBufs
/varset NumBufs 0
:Loop
/varadd NumBufs 1
/varset bufs(@NumBufs) "$ini("INIPATH","Bufs","Buf$int(@NumBufs)")"
/if "@bufs(@NumBufs)"=="NOTFOUND" {
/varsub NumBufs 1
/goto :End
}
/goto :Loop
:End
/call DoLog "Number of bufs loaded @NumBufs"
/return
Sub WaitForPickup
:waiting
/if "$cursor()"=="NULL" /goto :waiting
/return
Sub WaitForDrop
:waiting
/if $cursor()==TRUE /goto :waiting
/return
Sub DoLog
/mqlog @Param0
/echo @Param0
/return
Sub WaitForSpell
:Spell
/delay 1s
/if $char(casting)==TRUE /goto :Spell
/delay 1s
/return
Sub putaway
:Loop
/delay 1s
/if $cursor()==TRUE {
/autoinventory
/goto :Loop
}
/return
Sub DefineGlobals
/declare bufs array
/declare forage array
/declare NumBufs global
/declare Zone global
/declare NumForage global
/varset Zone 0
/call LoadBufs
/call LoadForage
/return
| [Bufs]
| Buf1=Nature's Might
| Buf2=Protection of the Cabbage
| Buf3=Improved Superior Camouflage
|
|
| The forage section lists all the items you want to DESTORY!!!
| Don't list an item here if you want to keep it.
|
| [Forage]
| Dest1=Ripened Mango
| Dest2=Fresh Tree Sap
| Dest3=Bark Bindings
Code: Select all
[Bufs]
Buf1=Nature's Might
Buf2=Protection of the Cabbage
Buf3=Improved Superior Camouflage
[Forage]
Dest1=Ripened Mango
Dest2=Fresh Tree Sap
Dest3=Bark Bindings
Code: Select all
#turbo
#define INIPATH "autoforage.ini"
#include routines.mac
#event Appear "You appear."
#event Interrupt "Your spell is interrupted."
#event Fizzle "Your spell fizzles!"
#event Recover "You haven't recovered yet..."
Sub Main
/call DefineGlobals
/call DoLog "Starting to forage in $zone."
:loop
/call CheckBufs
/call Forage
/delay 3s
/goto :loop
/endmacro
Sub CheckDestroy
/declare i local
/if n @NumForage==0 /return
/for i 1 to @NumForage
/if $cursor()=="TRUE" {
/if n @i==1 /call DoLog "I foraged a '$cursor(name)'."
/if "$cursor(name)"=="@forage(@i)" {
/call DoLog "I am destroying $cursor(name)."
/if $invpanel!=TRUE /press I
/click left destroy
/call WaitForDrop
}
}
/next i
/if $invpanel==TRUE /press I
/return
Sub Forage
/if n $char(ability,"Forage")!=-2 {
/doability "Forage"
/call WaitForPickup
/call CheckDestroy
/call putaway
}
/return
Sub CheckBufs
/declare i local
/if n @NumBufs==0 /return
/for i 1 to @NumBufs
/if n $char(buff,"@bufs(@i)")==0 /call Rebuf
/next i
/return
Sub ReBuf
/declare i local
/if n @NumBufs==0 /return
/press F1
/sendkey up up
/delay 1s
:DoOver
/varset Zone 0
/for i 1 to @NumBufs
:DoOver
/if n $char(buff,"@bufs(@i)")==0 {
/call DoLog "Casting @bufs(@i)."
/cast "@bufs(@i)"
/call WaitForSpell
/doevents
/if n @Zone==1 /goto :DoOver
}
/next i
/varset Zone 0
/return
Sub Event_Appear
/sendkey up up
/varset Zone 1
/return
Sub Event_Interrupt
/sendkey up up
/varset Zone 1
/return
Sub Event_Fizzle
/sendkey up up
/varset Zone 1
/return
Sub Event_Recover
/sendkey up up
/varset Zone 1
/return
Sub LoadForage
/varset NumForage 0
:Loop
/varadd NumForage 1
/varset forage(@NumForage) "$ini("INIPATH","Forage","Dest$int(@NumForage)")"
/if "@forage(@NumForage)"=="NOTFOUND" {
/varsub NumForage 1
/goto :End
}
/call DoLog "Loaded $ini("INIPATH","Forage","Dest$int(@NumForage)") into array"
/goto :Loop
:End
/call DoLog "NumForage = @NumForage"
/return
Sub LoadBufs
/varset NumBufs 0
:Loop
/varadd NumBufs 1
/varset bufs(@NumBufs) "$ini("INIPATH","Bufs","Buf$int(@NumBufs)")"
/if "@bufs(@NumBufs)"=="NOTFOUND" {
/varsub NumBufs 1
/goto :End
}
/goto :Loop
:End
/call DoLog "Number of bufs loaded @NumBufs"
/return
Sub WaitForPickup
:waiting
/if "$cursor()"=="NULL" /goto :waiting
/return
Sub WaitForDrop
:waiting
/if $cursor()==TRUE /goto :waiting
/return
Sub DoLog
/mqlog @Param0
/echo @Param0
/return
Sub WaitForSpell
:Spell
/delay 1s
/if $char(casting)==TRUE /goto :Spell
/delay 1s
/return
Sub putaway
:Loop
/delay 1s
/if $cursor()==TRUE {
/autoinventory
/goto :Loop
}
/return
Sub DefineGlobals
/declare bufs array
/declare forage array
/declare NumBufs global
/declare Zone global
/declare NumForage global
/varset Zone 0
/call LoadBufs
/call LoadForage
/return

Code: Select all
#turbo
Sub Main
/cleanup
/press i
:loop
/if n $char(ability,Forage)>0 {
/delay 2
/doability Forage
/delay 10
/if $cursor()==TRUE {
/echo Keeping $cursor(name) ($count("$cursor(name)"))
/autoinventory
}
}
/delay 10
/goto :loop
/return