ForageINI.mac a forage macro with ini support

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

LordGiddion
a snow griffon
a snow griffon
Posts: 352
Joined: Sat Sep 13, 2003 6:12 pm
Contact:

Post by LordGiddion » Tue Oct 28, 2003 2:00 pm

I see what's wrong with this script, It uses an array "ItemArray" to determine what needs to be kept and what needs to be destroyed. The array is never populated from the ini. So everytime something is foraged it isn't in the array so it is kept and then added to the array and ini . Seeing as the array load function needs to be built it would be easy to have it load a "global" zone's settings as well as the current zone's settings.
I would also add a check to the availablity of the forage skill and only incriment the counters and such if it's avail. This would also allow someone to tweak the timer lower and have the bot forage as soon as the skill pops.

I'll see about fixing this next time I get free time - maybe Thursday if no one else fixes it first.

MrSmallie
a hill giant
a hill giant
Posts: 167
Joined: Fri Oct 11, 2002 11:18 am

Post by MrSmallie » Thu Oct 30, 2003 1:29 pm

A little change I made....

Sub Forage
:MinorLoop
/if n $char(skill,Forage)==-2 {
/delay 200
/goto :MinorLoop
} else
/if n $char(skill,Forage)==-1 {
/echo You don't have that skill!
/endmacro
}
| /sitoff
/doability Forage
/varadd ForageAttempts 1
| /delay 15
/return

LordGiddion
a snow griffon
a snow griffon
Posts: 352
Joined: Sat Sep 13, 2003 6:12 pm
Contact:

Post by LordGiddion » Sun Nov 02, 2003 3:49 pm

Here is my update for this macro. It adds the read from macro that the orig was missing. Also added support for a "global" area of the ini and a reload of the array from the ini whenever you zone.

Code: Select all

|---------------------------- 
| Forager with ini file support and 
| statistic gathering and reporting 
| version 2.1 

| 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 (requires FastItemDestroy 
| be turned on in the options window) 

#define INIFile "forage.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 0         | Set to 1 to write statistics to MQLog 
  /varset EnableClear 0            | 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

:Continue 
  /doevents
  /varset Index 0 
  /if $char(state)=SIT {
      /stand
      /delay 3
  }
  /if n $char(ability,"Forage")>0 { 
     /doability Forage 
     /varadd ForageAttempts 1 
     /delay 15 
     /if "$cursor(name)"=="NULL" { 
       /varadd ForageFailure 1 
     } else { 
       /varadd ForageSuccess 1 
       /call CheckItem 
       /call HandleItem 
       /beep 
     } 
  }
  /if @EnableShowStats==1 /call ShowStats 
  /if @EnableWriteLog==1 /call LogStats 
  /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
   /varset IniList "$ini(@IniFile,"Global")"  
   /if "@IniList"!="NOTFOUND" { 
      /varset IniPosition 0
      :CheckGlobalForage
         /varadd IniPosition 1
         /varadd NumItem 1
         /varset ItemArray(0,@NumItem) "$arg($int(@IniPosition),"@IniList",|)"
         /varset ItemArray(1,@NumItem) $ini(@IniFile,"Global",@ItemArray(0,@NumItem))
      /if "$arg($int($calc(@IniPosition+1)),"@IniList",|)"!="" /goto :CheckGlobalForage
   /varset IniList "$ini(@IniFile,"$zone")"  
   /if "@IniList"!="NOTFOUND" { 
      /varset IniPosition 0
      :CheckZoneForage
         /varadd IniPosition 1
         /varadd NumItem 1
         /varset ItemArray(0,@NumItem) "$arg($int(@IniPosition),"@IniList",|)"
         /varset ItemArray(1,@NumItem) $ini(@IniFile,"Global",@ItemArray(0,@NumItem))
      /if "$arg($int($calc(@IniPosition+1)),"@IniList",|)"!="" /goto :CheckZoneForage
   } 
/return

Sub LogStats 
  /declare xy local  
  /if @EnableClear==1 /mqlog clear 
  /mqlog ############################################# 
  /mqlog Attempts = $int(@ForageAttempts) 
  /mqlog Success  = $int(@ForageSuccess)  [$int($calc(@ForageSuccess/@ForageAttempts*100))%] 
  /mqlog Failures = $int(@ForageFailure)  [$int($calc(@ForageFailure/@ForageAttempts*100))%] 
  /mqlog Keeps    = $int(@ForageKeeps)    [$int($calc(@ForageKeeps/@ForageAttempts*100))%] 
  /mqlog Destroys = $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%] 
  /mqlog [Idx] [Item] [Keep] [Qty] [%] 
  /mqlog ------------------------------------------- 
  /if n @NumItem>0 { 
    /for xy 1 to @NumItem 
       /mqlog [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%] 
    /next xy 
  } 
/return 

Sub ShowStats 
  /declare xy local 
  /if @EnableClear==1 /clear 
  /echo Attempts = $int(@ForageAttempts) 
  /echo Success  = $int(@ForageSuccess)  [$int($calc(@ForageSuccess/@ForageAttempts*100))%] 
  /echo Failures = $int(@ForageFailure)  [$int($calc(@ForageFailure/@ForageAttempts*100))%] 
  /echo Keeps    = $int(@ForageKeeps)    [$int($calc(@ForageKeeps/@ForageAttempts*100))%] 
  /echo Destroys = $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%] 
  /echo [Idx] [Item] [Keep] [Qty] [%] 
  /echo ------------------------------------------- 
  /if n @NumItem>0 { 
    /for xy 1 to @NumItem 
      /echo [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%] 
    /next xy 
  } 
/return 

Sub CheckItem 
  /declare xy local 
  /if @NumItem==0 { 
    /varset NumItem 1 
    /call AddToArray 
    /varset Index 1 
  } else { 
    /for xy 1 to @NumItem 
      /if "@ItemArray(0,@xy)"=="$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","$cursor(name)") 
    /if "@ItemArray(1,@NumItem)"=="NOTFOUND" { 
      /varset ItemArray(1,@NumItem) 1 
      /ini "INIFile" "$zone" "$cursor(name)" 1 
    } 
    /varset ItemArray(2,@NumItem) 1 
/return 

Sub HandleItem 
  /if @ItemArray(1,@Index)==0 { 
    /varadd ForageDestroys 1 
    /click left destroy 
  } else { 
    /varadd ForageKeeps 1 
    /autoinv 
  } 
/return 


DontShoot
a lesser mummy
a lesser mummy
Posts: 58
Joined: Thu Jun 20, 2002 11:20 am

Post by DontShoot » Mon Nov 03, 2003 9:34 am

Just one change to fix the auto-stand feature in LordG's code:

Code: Select all

/if $char(state)=SIT { 
      /stand 
      /delay 3 
  } 
should be changed to:

Code: Select all

/if $char(state)==SIT {
      /sit  
      /delay 3 
  } 

at least, it wouldn't work for me until I did that :)

Guest

Post by Guest » Fri Nov 07, 2003 6:36 am

i get this when i run the updated code above from LordG...

Code: Select all

Ending macro: Calculate encountered unparsable text ''
for.mac@136 (ShowStats): /echo [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%]
for.mac@68 (Main): /if @EnableShowStats==1 /call ShowStats
Cleared the following: Timers Vars Arrays
The current macro has ended.
Error: Calculate encountered a unparsed variable '?ItemArray(2,?xy'
Error: Calculate encountered a unparsed variable '?ItemArray(1,?xy'
Error: Calculate encountered a unparsed variable '?xy'
[MacroQuest] [-1] [@ItemArray(0,@xy)] [-1)] [-1)] [-1%]

DontShoot
a lesser mummy
a lesser mummy
Posts: 58
Joined: Thu Jun 20, 2002 11:20 am

Post by DontShoot » Fri Nov 07, 2003 8:22 am

I think i was getting the same errors, until I disabled the forage stats... seemed to work.

Kaitain
a ghoul
a ghoul
Posts: 109
Joined: Fri Oct 10, 2003 1:49 pm

Post by Kaitain » Mon Nov 17, 2003 7:21 am

<deleted>
Last edited by Kaitain on Thu Apr 15, 2004 5:17 pm, edited 1 time in total.

Teh_ish
UI Guru
Posts: 168
Joined: Wed Nov 05, 2003 12:18 am

Post by Teh_ish » Sun Nov 23, 2003 2:44 am

Nudge. Can someone make gideon's script work? :\
OMGWTFBBQ

Guest

Post by Guest » Tue Nov 25, 2003 12:41 am

Here's the whole thing since I can't remember exactly which lines I fixed. Remember to set FastItemDestroy on and make sure you keep the inventory window open (things I found out on my own).

Code: Select all

|---------------------------- 
| Forager with ini file support and 
| statistic gathering and reporting 
| version 2.1 

| 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 (requires FastItemDestroy 
| be turned on in the options window) 

#define IniFile "forage.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 0            | 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 

:Continue 
  /doevents 
  /varset Index 0 
  /if $char(state)==SIT { 
      /stand
      /delay 3 
  } 
  /if n $char(ability,"Forage")>0 { 
     /doability Forage 
     /varadd ForageAttempts 1 
     /delay 15 
     /if "$cursor(name)"=="NULL" { 
       /varadd ForageFailure 1 
     } else { 
       /varadd ForageSuccess 1 
       /call CheckItem 
       /call HandleItem 
|       /beep 
     } 
  } 
  /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 "@IniList"!="NOTFOUND||" { 
      /varset IniPosition 0 
      :CheckGlobalForage 
         /varadd IniPosition 1 
         /varadd NumItem 1 
         /varset ItemArray(0,@NumItem) "$arg($int(@IniPosition),"@IniList",|)" 
         /varset ItemArray(1,@NumItem) $ini(IniFile,"Global","@ItemArray(0,@NumItem)")
|  Setting the second column to 0 in the array at zoneout/in.  Originally wasn't getting set and would cause stats to bail.
         /varset ItemArray(2,@NumItem) 0
      /if "$arg($int($calc(@IniPosition+1)),"@IniList",|)"!="" /goto :CheckGlobalForage
   }
   /varset IniList "$ini(IniFile,"$zone")"
   /if "@IniList"!="NOTFOUND||" { 
      /varset IniPosition 0 
      :CheckZoneForage 
         /varadd IniPosition 1 
         /varadd NumItem 1 
         /varset ItemArray(0,@NumItem) "$arg($int(@IniPosition),"@IniList",|)" 
         /varset ItemArray(1,@NumItem) $ini(IniFile,$zone,"@ItemArray(0,@NumItem)") 
         /varset ItemArray(2,@NumItem) 0
      /if "$arg($int($calc(@IniPosition+1)),"@IniList",|)"!="" /goto :CheckZoneForage 
   } 
/return 

Sub LogStats 
  /declare xy local  
  /if @EnableClear==1 /mqlog clear 
  /mqlog ############################################# 
  /mqlog For Zone: $zone
  /mqlog Attempts = $int(@ForageAttempts) 
  /mqlog Success  = $int(@ForageSuccess)  [$int($calc(@ForageSuccess/@ForageAttempts*100))%] 
  /mqlog Failures = $int(@ForageFailure)  [$int($calc(@ForageFailure/@ForageAttempts*100))%] 
  /mqlog Keeps    = $int(@ForageKeeps)    [$int($calc(@ForageKeeps/@ForageAttempts*100))%] 
  /mqlog Destroys = $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%] 
  /mqlog [Idx] [Item] [Keep] [Qty] [%] 
  /mqlog -------------------------------------------
  /if n @NumItem>0 { 
    /for xy 1 to @NumItem 
       /mqlog [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%] 
    /next xy 
  } 
/return 

Sub ShowStats 
  /declare xy local 
  /if @EnableClear==1 /clear 
  /echo ############################################# 
  /echo For Zone: $zone
  /echo Attempts = $int(@ForageAttempts) 
  /echo Success  = $int(@ForageSuccess)  [$int($calc(@ForageSuccess/@ForageAttempts*100))%] 
  /echo Failures = $int(@ForageFailure)  [$int($calc(@ForageFailure/@ForageAttempts*100))%] 
  /echo Keeps    = $int(@ForageKeeps)    [$int($calc(@ForageKeeps/@ForageAttempts*100))%] 
  /echo Destroys = $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%] 
  /echo [Idx] [Item] [Keep] [Qty] [%] 
  /echo ------------------------------------------- 
  /if n @NumItem>0 { 
    /for xy 1 to @NumItem 
      /echo [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%] 
    /next xy 
  } 
/return 


Sub CheckItem 
  /declare xy local 
  /if @NumItem==0 { 
    /varset NumItem 1 
    /call AddToArray 
    /varset Index 1 
  } else { 
    /for xy 1 to @NumItem 
      /if "@ItemArray(0,@xy)"=="$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","$cursor(name)") 
    /if "@ItemArray(1,@NumItem)"=="NOTFOUND" { 
      /varset ItemArray(1,@NumItem) 1 
      /ini "IniFile" "$zone" "$cursor(name)" 1 
    } 
    /varset ItemArray(2,@NumItem) 1 
/return 

Sub HandleItem 
  /if @ItemArray(1,@Index)==0 { 
    /varadd ForageDestroys 1 
    /click left destroy 
    /echo $cursor(name) should be destroyed.
  } else { 
    /varadd ForageKeeps 1 
    /autoinv 
  } 
/return

Teh_ish
UI Guru
Posts: 168
Joined: Wed Nov 05, 2003 12:18 am

Post by Teh_ish » Tue Nov 25, 2003 1:54 am

That does work, except there's a bug in that it's not loading the zone-based forages right.

Code: Select all

/varset IniList "$ini(IniFile,"$zone")"
/if "@IniList"!="NOTFOUND||" {
To fix it change any instances of

Code: Select all

!="NOTFOUND||"
to

Code: Select all

!~"NOTFOUND"
Also change

Code: Select all

/varset ItemArray(1,@NumItem) $ini(IniFile,$zone,"@ItemArray(0,@NumItem)")
to

Code: Select all

/varset ItemArray(1,@NumItem) $ini(IniFile,[b]"$zone"[/b],"@ItemArray(0,@NumItem)")
Well it's loading the stuff right if you're in the zone. It's just not reloading when you zone. I'll figure that out and post tomorrow. bedtime
OMGWTFBBQ

Zeit
a lesser mummy
a lesser mummy
Posts: 34
Joined: Sat Jan 24, 2004 5:54 am

Post by Zeit » Sun Feb 01, 2004 5:10 am

great macro took out the annoying /beep =x nows its just going to town i like the statistics $

daerck
a ghoul
a ghoul
Posts: 134
Joined: Mon Jan 12, 2004 8:44 pm

Post by daerck » Fri Feb 13, 2004 2:46 pm

Well it's loading the stuff right if you're in the zone. It's just not reloading when you zone. I'll figure that out and post tomorrow. bedtime

Change

Code: Select all

#Event ZoneChange "Loading please wait" 
to

Code: Select all

#Event ZoneChange "LOADING, PLEASE WAIT..." 

Eat_the_meek
orc pawn
orc pawn
Posts: 11
Joined: Sat Feb 07, 2004 9:03 pm

Post by Eat_the_meek » Fri Feb 13, 2004 9:14 pm

First make sure you DL MQ2, get it compiled (help for this is in the Help forum), and load MQ2, and EQ.

Copy this code and put it into a notepad file and save it into your Macro folder as whatever.mac . Create another blank file and save it as something.ini . Change (#define INIFile "e:\macros\forage.ini') line in your .mac file so it has the name of the .ini file you created. Go into EQ and type /macro "name of your .mac file" into your normal chat window.

eqg4m3r
decaying skeleton
decaying skeleton
Posts: 6
Joined: Mon Mar 01, 2004 12:34 pm

Post by eqg4m3r » Thu Mar 11, 2004 10:28 pm

Wouldn't it make more sense to exchange

Code: Select all

Sub HandleItem 
  /if @ItemArray(1,@Index)==0 { 
    /varadd ForageDestroys 1 
    /click left destroy 
    /echo $cursor(name) should be destroyed. 
  } else { 
    /varadd ForageKeeps 1 
    /autoinv 
  } 
/return 
with

Code: Select all

Sub HandleItem 
  /if @ItemArray(1,@Index)==0 { 
    /varadd ForageDestroys 1 
    /echo $cursor(name) should be destroyed. 
    /destroy
  } else { 
    /varadd ForageKeeps 1 
    /autoinv 
  } 
/return 
First off the /echo should happen BEFORE the item is destroyed, otherwise you'll just get a "NULL should be destroyed." Secondly, usage of the /destroy feature makes it unnecessary to keep the inventory open and FastItemDestroy enabled.

Also there seems to be an issue with the global area of the ini. Even if a "Pod of Water" is in the global area it still gets added to the zone specific areas ... Basically it just creates double entries for items already listed in the global area, rendering the global area useless.

Other than that very nice macro indeed.
Life is a game - play it... But play to win!

GD
a snow griffon
a snow griffon
Posts: 353
Joined: Sat Jun 29, 2002 11:57 pm

Code Updated

Post by GD » Sat Mar 13, 2004 10:05 am

Code: Select all

|----------------------------
| Forager v2.2
|
| Changes in 2.2:
|   Streamlined the code a little more
|   Changed it to an ability check rather than a timer
|   Massively reduced the status spam!
|   - Fewer lines, only updates after each forage attempt now

#define INIFile "Forage.ini"

| Set the above 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 (requires FastItemDestroy
| be turned on in the options window)


Sub Main
	/declare EnableShowStats global
	/declare EnableWriteLog global
	/declare EnableClear global

| ##### User set variables #####
	/varset EnableShowStats 1        | Set to 1 to show foraging statistics
	/varset EnableWriteLog 0         | Set to 1 to write statistics to MQLog
	/varset EnableClear 0            | 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

:Continue
	/delay 5
	/varset Index 0
	/if "$char(state)"=="SIT" {
		/stand
		/delay 5
	}

	/if n $char(ability,"Forage")>0 {
		/doability Forage
		/delay 5
		/varadd ForageAttempts 1
		/if "$cursor(name)"=="NULL" {
			/varadd ForageFailure 1
		} else {
			/varadd ForageSuccess 1
			/call CheckItem
			/call HandleItem
		}
		/if @EnableShowStats==1 /call ShowStats
		/if @EnableWriteLog==1 /call LogStats
	}

	/goto :Continue

/return

| ########## Subroutines ##########

Sub LogStats
	/declare xy local
	/if @EnableClear==1 /mqlog clear
	/mqlog #############################################
	/mqlog Attempts: $int(@ForageAttempts), Success: $int(@ForageSuccess) [$int($calc(@ForageSuccess/@ForageAttempts*100))%]  Failures: $int(@ForageFailure) [$int($calc(@ForageFailure/@ForageAttempts*100))%]
	/mqlog Keeps: $int(@ForageKeeps) [$int($calc(@ForageKeeps/@ForageAttempts*100))%]  Destroys: $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%]
	/mqlog [Idx] [Item] [Keep] [Qty] [%]
	/mqlog -------------------------------------------
	/if n @NumItem>0 {
		/for xy 1 to @NumItem
		/mqlog [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%]
		/next xy
	}
/return

Sub ShowStats
	/declare xy local
	/if @EnableClear==1 /clear
	/echo -------------------------------------------
	/echo Attempts: $int(@ForageAttempts), Success: $int(@ForageSuccess) [$int($calc(@ForageSuccess/@ForageAttempts*100))%]  Failures: $int(@ForageFailure) [$int($calc(@ForageFailure/@ForageAttempts*100))%]
	/echo Keeps: $int(@ForageKeeps) [$int($calc(@ForageKeeps/@ForageAttempts*100))%]  Destroys: $int(@ForageDestroys) [$int($calc(@ForageDestroys/@ForageAttempts*100))%]
	/echo [Idx] [Item] [Keep] [Qty] [%]
	/echo -------------------------------------------
	/if n @NumItem>0 {
		/for xy 1 to @NumItem
		/echo [$int(@xy)] [@ItemArray(0,@xy)] [$int(@ItemArray(1,@xy))] [$int(@ItemArray(2,@xy))] [$int($calc(@ItemArray(2,@xy)/@ForageAttempts*100))%]
		/next xy
	}
/return

Sub CheckItem
	/declare xy local
	/if @NumItem==0 {
		/varset NumItem 1
		/call AddToArray
		/varset Index 1
	} else {
		/for xy 1 to @NumItem
		/if "@ItemArray(0,@xy)"=="$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","$cursor(name)")
	/if "@ItemArray(1,@NumItem)"=="NOTFOUND" {
		/varset ItemArray(1,@NumItem) 1
		/ini "INIFile" "$zone" "$cursor(name)" 1
	}
	/varset ItemArray(2,@NumItem) 1
/return

Sub HandleItem
	/if @ItemArray(1,@Index)==0 {
		/varadd ForageDestroys 1
		/destroy
	} else {
		/varadd ForageKeeps 1
		/autoinv
	}
/return

Opinions are like assholes, everyone has one, but most of them stink.