EvilB no longer seems to be around (his login to the board no longer exists), I have taken the liberty of updating his excellent foraging script to support MQ2DataTypes.
This is a line-by-line conversion of the original at http://macroquest2.com/phpBB2/viewtopic.php?t=3272, with a few changes. I modified it to use /destroy, so no need to have Fast Item Destroy enabled in EQ, and I fiddled abit with the columns in the statistics.
If you have any problems with the script, or perhaps ideas for improvement, please post below and I'll try and help as best I can.
Code: Select all
| ----------------------------
| FORAGER.MAC
| Forager with ini file support and statistic gathering and reporting
| Version 2.2
|
| Originally posted by EvilB
| Updated to MQ2DataTypes by NotHere
|
| Set this define to the desired .ini file
| Requires a blank .ini file to start. The marco will populate the .ini file automatically for any zone and default to keeping the item.
| Then just change the values in the .ini file to 0 for an item to be automatically destroyed.
#define IniFile "Forager.ini"
#Event ZoneChange "Loading please wait"
#turbo
Sub Main
/declare ForageDelay global
/declare EnableShowStats global
/declare EnableWriteLog global
/declare EnableClear global
| ##### User set variables #####
/varset ForageDelay 1010 | The delay between forage attempts
/varset EnableShowStats 1 | Set to 1 to show foraging statistics
/varset EnableWriteLog 1 | Set to 1 to write statistics to MQLog
/varset EnableClear 1 | Set to 1 to clear before writing stats
| ##### User set variables #####
/declare ForageAttempts global
/declare ForageSuccess global
/declare ForageFailure global
/declare ForageKeeps global
/declare ForageDestroys global
/declare NumItem global
/declare Index global
/declare ItemArray array2
/varset ForageAttempts 0
/varset ForageSuccess 0
/varset ForageFailure 0
/varset ForageKeeps 0
/varset ForageDestroys 0
/varset NumItem 0
/call LoadFromIni
/echo Forager.mac running
:Continue
/doevents
/varset Index 0
/if (${Me.Sitting}) {
/stand
/delay 3
}
/if (${Me.AbilityReady[Forage]}) {
/doability Forage
/varadd ForageAttempts 1
/delay 15
/if (${Cursor.ID}) {
/varadd ForageSuccess 1
/call CheckItem
/call HandleItem
| /beep
} else {
/varadd ForageFailure 1
}
}
/if (@EnableWriteLog==1) /call LogStats
/if (@EnableShowStats==1) /call ShowStats
/delay @ForageDelay
/goto :Continue
/return
| ########## Subroutines ##########
Sub Event_ZoneChange
/delay 1m
/call LoadFromIni
/return
Sub LoadFromIni
/varset NumItem 0
/declare IniPosition local
/declare IniList local
/declare tmpItem local
/varset IniList "${Ini[IniFile,Global]}"
/if (${String[@IniList].Find[|]}) {
/varset IniPosition 0
:CheckGlobalForage
/varadd IniPosition 1
/varadd NumItem 1
/varset ItemArray(0,@NumItem) "${String[@IniList].Arg[@IniPosition,|]}"
/varset ItemArray(1,@NumItem) ${Ini[IniFile,Global,@ItemArray(0,@NumItem)]}
/varset ItemArray(2,@NumItem) 0
/if (${String[@IniList].Arg[${Math.Calc[@IniPosition+1].Int},|].Length}>0) /goto :CheckGlobalForage
}
/varset IniList "${Ini[IniFile,${Zone.Name}]}"
/if (${String[@IniList].Find[|]}) {
/varset IniPosition 0
:CheckZoneForage
/varadd IniPosition 1
/varadd NumItem 1
/varset ItemArray(0,@NumItem) "${String[@IniList].Arg[@IniPosition,|]}"
/varset ItemArray(1,@NumItem) ${Ini[IniFile,${Zone.Name},@ItemArray(0,@NumItem)]}
/varset ItemArray(2,@NumItem) 0
/if (${String[@IniList].Arg[${Math.Calc[@IniPosition+1].Int},|].Length}>0) /goto :CheckZoneForage
}
/return
Sub LogStats
/declare xy local
/if (@EnableClear==1) /mqlog clear
/mqlog ## Time: ${Time.Time24}
/mqlog ## Zone: ${Zone.Name}
/mqlog Attempts = ${Float[@ForageAttempts].Int}
/mqlog Success = ${Float[@ForageSuccess].Int} [${Math.Calc[@ForageSuccess/@ForageAttempts*100].Int}%]
/mqlog Failures = ${Float[@ForageFailure].Int} [${Math.Calc[@ForageFailure/@ForageAttempts*100].Int}%]
/mqlog Keeps = ${Float[@ForageKeeps].Int} [${Math.Calc[@ForageKeeps/@ForageAttempts*100].Int}%]
/mqlog Destroys = ${Float[@ForageDestroys].Int} [${Math.Calc[@ForageDestroys/@ForageAttempts*100].Int}%]
/mqlog [Idx] [Keep] [Qty] [%] [Item]
/mqlog -------------------------------------------
/if (@NumItem>0) {
/for xy 1 to @NumItem
/mqlog [@xy] [@ItemArray(1,@xy)] [${Float[@ItemArray(2,@xy)].Int}] [${Math.Calc[@ItemArray(2,@xy)/@ForageAttempts*100].Int}%] [@ItemArray(0,@xy)]
/next xy
}
/return
Sub ShowStats
/declare xy local
| /if @EnableClear==1 /clear
/echo ## Time: ${Time.Time24}
/echo ## Zone: ${Zone.Name}
/echo Attempts = ${Float[@ForageAttempts].Int}
/echo Success = ${Float[@ForageSuccess].Int} [${Math.Calc[@ForageSuccess/@ForageAttempts*100].Int}%]
/echo Failures = ${Float[@ForageFailure].Int} [${Math.Calc[@ForageFailure/@ForageAttempts*100].Int}%]
/echo Keeps = ${Float[@ForageKeeps].Int} [${Math.Calc[@ForageKeeps/@ForageAttempts*100].Int}%]
/echo Destroys = ${Float[@ForageDestroys].Int} [${Math.Calc[@ForageDestroys/@ForageAttempts*100].Int}%]
/echo [Idx] [Keep] [Qty] [%] [Item]
/echo -------------------------------------------
/if (@NumItem>0) {
/for xy 1 to @NumItem
/echo [@xy] [@ItemArray(1,@xy)] [${Float[@ItemArray(2,@xy)].Int}] [${Math.Calc[@ItemArray(2,@xy)/@ForageAttempts*100].Int}%] [@ItemArray(0,@xy)]
/next xy
}
/return
Sub CheckItem
/declare xy local
/if (@NumItem==0) {
/echo FIRST ITEM!
/varset NumItem 1
/call AddToArray
/varset Index 1
} else {
/for xy 1 to @NumItem
/if (${String[@ItemArray(0,@xy)].Equal[${Cursor.Name}]}) /varset Index @xy
/next xy
/if (@Index==0) {
/varadd NumItem 1
/call AddToArray
} else {
/varadd ItemArray(2,@Index) 1
}
}
/return
Sub AddToArray
/varset ItemArray(0,@NumItem) "${Cursor.Name}"
/varset ItemArray(1,@NumItem) ${Ini[IniFile,${Zone.Name},${Cursor.Name},-1]}
/if (@ItemArray(1,@NumItem)<0) {
/varset ItemArray(1,@NumItem) 1
/ini "IniFile" "${Zone.Name}" "${Cursor.Name}" 1
}
/varset ItemArray(2,@NumItem) 1
/varset Index @NumItem
/return
Sub HandleItem
/if (@ItemArray(1,@Index)==0) {
/echo ${Cursor.Name} should be destroyed.
/varadd ForageDestroys 1
/destroy
} else {
/echo ${Cursor.Name} should be kept.
/varadd ForageKeeps 1
/autoinv
}
/return
Code: Select all
[Skyfire Mountains]
Fishing Grubs=1
[The Plane of Water]
Large Brine Shrimp=0
Cluster of Kelp=1
Pod of Water=1If you use this with an existing ini, it seems that MQ2 now returns zone names in a slighty different way. The script will then add a new zone to the bottom of the ini file, and populate that new zone with items. If you want to use your old item data, simply rename the old zone definition to the name of the new zone, and delete the new one.



