forage.mac Simple Forrage Script

Macro depository for macros written before the user variable changes that broke all of them.

Moderator: MacroQuest Developers

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Fri May 23, 2003 6:49 pm

Uncoment the debug line and post the output if you could.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Fri May 23, 2003 6:58 pm

Just me being stupid and trying to save "howling" substance when it's "wailing" substance. It works, and thanks.
MQ2: Think of it as Evolution in action.

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Post by kagonis » Sat May 24, 2003 9:29 pm

I did some extra work on the script GrimJack and I worked on, here is what I got:

Code: Select all

| Name:
| -----
| Forage.mac
|
| Authors:
| --------
| GrimJack, Kagonis
|
| Description:
| ------------
| This forage macro is optimized for druids (or rangers) that
| have the AA called Innate Camouflage.
|
| The following variables can be changed to suit your needs:
| /varset DestroyX <int>	= The X position of your destroy
| button, since this is not working correct at the moment.
| /varset DestroyY <int>	= The Y position of your destroy
| button, since this is not working correct at the moment.
| /varset UseCamo <TRUE|FALSE>	= Use Innate Camouflage AA
| between forages? Good for foraging places where there are
| roamers.
| /varset DefKeep <TRUE|FALSE>	= Keep or Destroy the items
| listed in the array, per default, ie:
| - /varset DefKeep TRUE	: If you wish to keep the items
|   listed in the array, and destroy the rest (risky: read warning).
| - /varset DefKeep FALSE	: If you wish to destroy the items
|   listed in the array, and keep the rest (safest: read warning).
|
| To add new items that you wish to keep or destroy, to your array
| you simply add a new line like these:
| /varset a(1,0) "Roots"
| /varset a(1,1) "Tuft of Dire Wolf Fur"
| /varset a(1,2) "Dragon Egg"
|
| Remember to update the ArraySize accordingly to the number of
| items in your array:
| /varset ArraySize 3
|
| ** WARNING WARNING **
| If you decide to use the KEEP list, then you will have to make
| sure that you don't put something on your cursor that you would
| not risk to loose.
| ** WARNING WARNING **
 
#define LoopCount v40
#define ArraySize v41
#define MouseX v42
#define MouseY v43
#define DestroyX v44
#define DestroyY v45
#define DefKeep v46
#define UseCamo v47

sub Main
	/varset a(1,0) "Roots"
	/varset a(1,1) "Tuft of Dire Wolf Fur"
	/varset a(1,2) "Dragon Egg"
	/varset a(1,3) "Drake Egg"
	/varset a(1,4) "Wurm Egg"
	/varset a(1,5) "Morning Dew"
	/varset a)1,6) "Branch of Planar Oak"
	/varset ArraySize 7
	/varset LoopCount 0
	/varset DestroyX 1018
	/varset DestroyY 805
	/varset UseCamo "FALSE"
	/varset DefKeep "TRUE"
	/cleanup
	:Loop
		/varset MouseX $mouse(X)
		/varset MouseY $mouse(Y)
		/delay 5
		/if n $char(ability,"Forage")>0 {
			/if "$cursor()"!="NULL" /call ItemSort
			/delay 5
			/doability forage
			/if "$UseCamo"=="TRUE" /alt activate 80
			/delay 5
			/if "$cursor()"!="NULL" /call ItemSort
		}
		/goto :Loop
/return

sub ItemSort
	:itemchecker
		/if "$cursor(name)"~~"$a(1,$LoopCount)" {
			/if "$DefKeep"=="TRUE" {
				/echo Keeping: << $cursor(name) >>
				/click left auto
			} else {
				/echo Destroying: << $cursor(name) >>
				/mouseto $DestroyX $DestroyY
				/click left
			}
			/delay 5
		}
		/varadd LoopCount 1
		/if "$cursor()"!="NULL" {
			/if n $LoopCount<$ArraySize /goto :itemchecker
		}

		/if "$cursor()"!="NULL" {
			/if "$DefKeep"=="TRUE" {
				/echo Destroying: << $cursor(name) >>
				/mouseto $DestroyX $DestroyY
				/click left
			} else {
				/echo Keeping: << $cursor(name) >>
				/click left auto
			}
			/delay 5
		}
		/mouseto $MouseX $MouseY
		/varset LoopCount 0
/return
I also worked a bit further on the idea and tried to implement some fishing into it, but I can't really figure it out completely, it keeps fishing even though I have no bait.

By the way, the fishing routine is expecting certain things like having the summon fishing pole thing, as well as the positions of some slots etc.

Code: Select all

#event NoPole "You need to put your fishing pole in your primary hand." 
#event NoBait "You can't fish without fishing bait, go buy some." 
#event BrokePole "Your fishing pole broke!" 

#define LoopCount v40
#define ArraySize v41
#define MouseX v42
#define MouseY v43
#define DestroyX v44
#define DestroyY v45
#define PrimaryX v46
#define PrimaryY v47
#define InvSlot8X v48
#define InvSlot8Y v49
#define UseCamo v50
#define NoBait v51

sub Main
	/varset a(1,0) "Roots"
	/varset a(1,1) "Tuft of Dire Wolf Fur"
	/varset a(1,2) "Dragon Egg"
	/varset a(1,3) "Drake Egg"
	/varset a(1,4) "Wurm Egg"
	/varset a(1,5) "Fresh Fish"
	/varset a(1,6) "Cobalt Cod"
	/varset a(1,7) "Dragon Bay Snapper"
	/varset a(1,8) "Morning Dew"
	/varset a(1,9) "Branch of Planar Oak"
	/varset ArraySize 10
	/varset LoopCount 0
	/varset NoBait "FALSE"
	/varset UseCamo "FALSE"
	/varset DestroyX 1018
	/varset DestroyY 805
	/varset PrimaryX 836
	/varset PrimaryY 725
	/varset InvSlot8X 1091
	/varset InvSlot8Y 730
	/cleanup
	/doevents flush

	:Loop
		/varset MouseX $mouse(X)
		/varset MouseY $mouse(Y)
		/delay 5
		/if n $char(ability,"Forage")>0 {
			/if "$cursor()"!="NULL" /call ItemSort
			/delay 5
			/doability forage
			/if "$UseCamo"=="TRUE" /alt activate 80
			/delay 5
			/if "$cursor()"!="NULL" /call ItemSort
		}
		/doevents NoBait
		/if n $char(ability,fishing)>0 /if "$NoBait"!="TRUE" {
			/if "$equip(primary,name)"!="Brell's Fishin' Pole" /call SummonPole
			/if "$cursor()"!="NULL" /call ItemSort
			/delay 5
			/doability fishing
			/delay 5
			/if "$cursor()"!="NULL" /call ItemSort
		}

		/goto :Loop
/return

sub ItemSort
	:itemchecker
		/if "$cursor(name)"~~"$a(1,$LoopCount)" {
			/echo Keeping: << $cursor(name) >>
			/click left auto
			/delay 5
		}
		/varadd LoopCount 1
		/if "$cursor()"!="NULL" {
			/if n $LoopCount<$ArraySize /goto :itemchecker
		}

		/if "$cursor()"!="NULL" {
			/echo Destroying: << $cursor(name) >>
			/mouseto $DestroyX $DestroyY
			/click left
			/delay 5
		}
		/mouseto $MouseX $MouseY
		/varset LoopCount 0
/return

sub SummonPole
	/mouseto $InvSlot8X $InvSlot8Y
	/click right
	/delay 11s
	/if "$cursor()"!="NULL" /if "$cursor(name)"~~"Brell's Fishin' Pole" {
		/mouseto $PrimaryX $PrimaryY
		/delay 5
		/click left
		/delay 5
		/if "$cursor()"!="NULL" /click left auto
	} else {
		/varset NoBait "TRUE"
	}
/return

Sub Event_NoPole 
	/call SummonPole
/return 

Sub Event_BrokePole 
	/call SummonPole
/return

Sub Event_NoBait
	/varset NoBait "TRUE"
/return

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Forrage script

Post by grimjack » Sun May 25, 2003 4:42 am

Looking good Kagonis. I like the fact that you made it reversable. I don't have any characters that forrage but I may have to make one now hehe. I prefer default keep with a list of items to destroy (for when you forget it's running and pickup that epic) and I think it was a great idea that you put that in. If you need any more help with any ideas you have don't hesitate to ask or send me a PM.

Thanks
GrimJack
Last edited by grimjack on Thu Jun 12, 2003 4:13 am, edited 1 time in total.

AlphaBeta
a ghoul
a ghoul
Posts: 126
Joined: Sat Nov 09, 2002 12:35 am

Problems destroying

Post by AlphaBeta » Tue May 27, 2003 1:54 pm

Just was wondering if anyone was having problems with this script when trying to destroy a forage? Problem for me is that it is clicking about 1/16 of an inch above the button. I can fix this by grabing the window and draging it up a little while the macro is running (no easy task I might add). Is the problem in the XML reading the right location? note: using the default UI.

Zelker
a lesser mummy
a lesser mummy
Posts: 38
Joined: Fri Jan 03, 2003 3:01 pm

Post by Zelker » Tue May 27, 2003 3:03 pm

This link has some info on it.
http://macroquest2.com/phpBB2/viewtopic ... t=titlebar
Basically the titlebar was never acounted for, which results in the selector missing the Destroy button by 5 pixels or something like that.

I copied the default skins for Inventory and Loot, to a separate directory. In each of them toward the bottom of the code I changed <Style_Titlebar>true</Style_Titlebar> to <Style_Titlebar>false</Style_Titlebar>.

If you need help with skins, try http://www.eqskins.com

Good luck,
Z

Ayla
orc pawn
orc pawn
Posts: 12
Joined: Mon May 26, 2003 11:05 pm

Post by Ayla » Fri May 30, 2003 4:00 am

Whenever I run this macro it tells me "Destroying: xxx" then the mouse warps around the screen a couple of times, then it quickly says "Keeping: xxx" and puts it in my bag, even though I set it up so it's supposed to destroy instead of saving it. Any thoughts?

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Fri May 30, 2003 4:53 am

Ayla wrote:Whenever I run this macro it tells me "Destroying: xxx" then the mouse warps around the screen a couple of times, then it quickly says "Keeping: xxx" and puts it in my bag, even though I set it up so it's supposed to destroy instead of saving it. Any thoughts?
I would say your question is most likely answered in the post directly above yours. On UI's with titlebars it will miss the destroy button. If it misses the destroy button it will run through the rest of the array (it keeps checking against the next item in the array untill there is nothing on the cursor or nothing left in the array) then decide you want to keep it. To be sure though I would need better information. More accurate information on what the mouse is doing would be helpful. "warps around the screen" doesn't give me much to work with. Where does it warp to the first movement, second movement, ect? Is it the same places every time?

Also do /click left destroy and where does that move your mouse.

Thanks
GrimJack

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Fri May 30, 2003 8:34 am

It can also be a problem with delays.

The location parsing routine sorts through a bunch of files to determine the XY locations of buttons/etc. This takes time, and while to a human it's not a significant amount of time to your computer it's ages. MQ then has to move the mouse (basically instantaneous), EQ has to recognize the new location, the click has to be executed, and EQ has to react to it.

Frequently what I will see is the macro executing so fast that by the time EQ has acknowledged what you are doing your macro has already moved on to the next line, or is 5 commands further on. So, I do

if condition /click left destroy
else /click left auto

By the time EQ has reacted to me moving the mouse and calling a click I've already told it to click again, and the mouse shifts before EQ can register the actual button press.

That's probably confusing to most of you, don't think I explained it well...let's just say that MQ can be faster than EQ, which means you need to insert /delay after your /click statement. The amount of delay depends on your hardware/network configuration. So:

Code: Select all

|if we catch a rusty dagger destroy it
/if "$cursor(name)"~~"rusty" /click left destroy
|pause briefly to make sure it's destroyed
/delay 1s
|keep everything else
/if $cursor()==TRUE /click left auto
I usually start with a delay of 1 second, then work backwards to figure out how fast I can run it and still have the commands execute properly.
MQ2: Think of it as Evolution in action.

meep
orc pawn
orc pawn
Posts: 10
Joined: Sun Jan 19, 2003 11:18 am

Post by meep » Fri May 30, 2003 11:19 am

Code: Select all

/mouseto $DestroyX $DestroyY 
/click left 
Correct me if I'm wrong, but wouldnt it be easier to use

Code: Select all

/click left destroy
now it's all implemented and working?

I've edited my copy of the script to do that and it causes significantly fewer mouseloc problems, it would also remove the titlebar issues.

Removes a few variables and keeps the script cleaner too.
Last edited by meep on Fri May 30, 2003 1:44 pm, edited 2 times in total.

Ayla
orc pawn
orc pawn
Posts: 12
Joined: Mon May 26, 2003 11:05 pm

Post by Ayla » Fri May 30, 2003 12:29 pm

I read the post above mine, and got rid of the title bar on my inventory window. This didn't help at all, when it says destroying item... if I remember correctly is warps to the far bottom right corner of the screen.. then to a few other places (hard to see it goes pretty fast), but at any rate it's not anywhere near my destroy button.

I've got it working with the /left click destroy stuff now though.

meep
orc pawn
orc pawn
Posts: 10
Joined: Sun Jan 19, 2003 11:18 am

Post by meep » Fri May 30, 2003 1:50 pm

The code which I find a bit more reliable and custom UI friendly. I also increased the delay to be a little more lag friendly, it's not like forage refreshes that quickly anyway:

Code: Select all

| Name: 
| ----- 
| Forage.mac 
| 
| Authors: 
| -------- 
| GrimJack, Kagonis 
| 
| Description: 
| ------------ 
| This forage macro is optimized for druids (or rangers) that 
| have the AA called Innate Camouflage. 
| 
| The following variables can be changed to suit your needs: 
|
| /varset UseCamo <TRUE|FALSE>   = Use Innate Camouflage AA 
| between forages? Good for foraging places where there are 
| roamers. 
| /varset DefKeep <TRUE|FALSE>   = Keep or Destroy the items 
| listed in the array, per default, ie: 
| - /varset DefKeep TRUE   : If you wish to keep the items 
|   listed in the array, and destroy the rest (risky: read warning). 
| - /varset DefKeep FALSE   : If you wish to destroy the items 
|   listed in the array, and keep the rest (safest: read warning). 
| 
| To add new items that you wish to keep or destroy, to your array 
| you simply add a new line like these: 
| /varset a(1,0) "Roots" 
| /varset a(1,1) "Tuft of Dire Wolf Fur" 
| /varset a(1,2) "Dragon Egg" 
| 
| Remember to update the ArraySize accordingly to the number of 
| items in your array: 
| /varset ArraySize 3 
| 
| ** WARNING WARNING ** 
| If you decide to use the KEEP list, then you will have to make 
| sure that you don't put something on your cursor that you would 
| not risk to loose. 
| ** WARNING WARNING ** 

#define LoopCount v40 
#define ArraySize v41 
#define MouseX v42 
#define MouseY v43 
#define DefKeep v46 
#define UseCamo v47 

sub Main 
   /varset a(1,0) "Plant Shoot" 
   /varset a(1,1) "Tuft of Dire Wolf Fur" 
   /varset a(1,2) "Dragon Egg" 
   /varset a(1,3) "Drake Egg" 
   /varset a(1,4) "Wurm Egg" 
   /varset a(1,5) "Morning Dew" 
   /varset a(1,6) "Branch of Planar Oak" 
   /varset ArraySize 7 
   /varset LoopCount 0 
   /varset UseCamo "FALSE" 
   /varset DefKeep "TRUE" 
   /cleanup 

   :Loop 
      /varset MouseX $mouse(X) 
      /varset MouseY $mouse(Y) 
      /delay 5 
      /if n $char(ability,"Forage")>0 { 
         /if "$cursor()"!="NULL" /call ItemSort 
         /delay 15 
         /doability forage 
         /if "$UseCamo"=="TRUE" /alt activate 80 
         /delay 15 
         /if "$cursor()"!="NULL" /call ItemSort 
      } 
      /goto :Loop 
/return 

sub ItemSort 
   :itemchecker 
      /if "$cursor(name)"~~"$a(1,$LoopCount)" { 
         /if "$DefKeep"=="TRUE" { 
 
            /click left auto 

         } else { 

            /click left destroy 

         } 
         /delay 15 
      } 
      /varadd LoopCount 1 
      /if "$cursor()"!="NULL" { 
         /if n $LoopCount<$ArraySize /goto :itemchecker 
      } 

      /if "$cursor()"!="NULL" { 
         /if "$DefKeep"=="TRUE" { 

            /click left destroy

         } else { 

            /click left auto 
         } 
         /delay 15 
      } 
      /mouseto $MouseX $MouseY 
      /varset LoopCount 0 
/return
Hope I'm not stepping on anyones toes.

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Post by kagonis » Fri May 30, 2003 7:09 pm

Reason for the /mouseto x y /click left, rather tha /click left destroy, was that I had the title bar on while writing the script, so as you have been told, the destroy button is a bit off then.

My home version I updated a bit with an extra feature, but my computer is not working at the moment so I cant even deliver my update.

Basically I took an idea from the original combine.mac (the stickied one) where all items that is put into the array would be EXACT matches, unless prefixed with a #.
That would make "Meat" ONLY match items named meat, but "#Meat" would match Wolf Meat, Griffon Meat, Meaty Thing etc.

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Updated Version

Post by kagonis » Sat May 31, 2003 12:04 pm

Here is my updated version, 2 things are changed from my previous one:
1) Modified the macro to use /click left destroy instead of /mouseto X Y /click left. I have removed the titlebar in my inventory window, makes it work.
2) Added the "beExact" feature, thanks to serberus for the idea :), where everything added in the keep/destroy array must be exact match, unless prefixed by a #.

Code: Select all

| Name:
| -----
| Forage.mac
|
| Authors:
| --------
| GrimJack, Kagonis
|
| Description:
| ------------
| This forage macro is optimized for druids (or rangers) that
| have the AA called Innate Camouflage.
|
| The following variables can be changed to suit your needs:
| /varset DestroyX <int>	= The X position of your destroy
| button, since this is not working correct at the moment.
| /varset DestroyY <int>	= The Y position of your destroy
| button, since this is not working correct at the moment.
| /varset UseCamo <TRUE|FALSE>	= Use Innate Camouflage AA
| between forages? Good for foraging places where there are
| roamers.
| /varset DefKeep <TRUE|FALSE>	= Keep or Destroy the items
| listed in the array, per default, ie:
| - /varset DefKeep TRUE	: If you wish to keep the items
|   listed in the array, and destroy the rest (risky: read warning).
| - /varset DefKeep FALSE	: If you wish to destroy the items
|   listed in the array, and keep the rest (safest: read warning).
|
| To add new items that you wish to keep or destroy, to your array
| you simply add a new line like these:
| /varset a(1,0) "Roots"
| /varset a(1,1) "Tuft of Dire Wolf Fur"
| /varset a(1,2) "#Egg"
| All items will be EXACT matches, except if it is prepended by a #
| Ie: "Roots" will ONLY match "Roots", and not "Lichen Roots",
| "#Roots" on the other hand will match any item containing "Roots",
| Ie: "#Roots" matches both "Roots" and "Lichen Roots".
|
| Remember to update the ArraySize accordingly to the number of
| items in your array:
| /varset ArraySize 3
|
| ** WARNING WARNING **
| If you decide to use the KEEP list, then you will have to make
| sure that you don't put something on your cursor that you would
| not risk to loose.
| ** WARNING WARNING **

|Enabling #turbo makes the client lag for some reason.
|#turbo
#define LoopCount v1
#define ArraySize v2
#define MousePos v3
#define DefKeep v4
#define UseCamo v5
#define thisItem v6
#define beExact v7

sub Main
	/varset a(1,0) "#Egg"
	/varset a(1,1) "Tuft of Dire Wolf Fur"
	/varset a(1,2) "Roots"
	/varset a(1,3) "Morning Dew"
	/varset a(1,4) "Branch of Planar Oak"
	/varset a(1,5) "Plant Shoot"
	/varset ArraySize 6
	/varset UseCamo "FALSE"
	/varset DefKeep "TRUE"
	/cleanup
	:Loop
		/call doForage
|		/if "$cursor()"!="NULL" /call itemSort
		/goto :Loop
/return

sub doForage
	/if n $char(ability,"Forage")>0 {
		/if "$cursor()"!="NULL" /call ItemSort
		/delay 5
		/doability forage
		/if "$UseCamo"=="TRUE" /alt activate 80
		/delay 5
		/if "$cursor()"!="NULL" /call ItemSort
	}
/return

sub itemSort
	/varset MousePos "$mouse(X) $mouse(Y)"
	/delay 5
	/varset LoopCount 0
	:itemchecker
		/if "$a(1,$LoopCount)"~~"#" {
			/varset thisItem "$right($calc($strlen("$a(1,$LoopCount)")-1),"$a(1,$LoopCount)")"
			/varset beExact 0
		} else {
			/varset thisItem "$a(1,$LoopCount)"
			/varset beExact 1
		}

		/if n $beExact==0 /if "$cursor(name)"~~"$thisItem" {
			/if "$DefKeep"=="TRUE" {
				/echo Keeping: << $cursor(name) >>
				/click left auto
			} else {
				/echo Destroying: << $cursor(name) >>
				/click left destroy
			}
			/delay 5
		} else /if n $beExact==1 /if "$cursor(name)"=="$thisItem" {
			/if "$DefKeep"=="TRUE" {
				/echo Keeping: << $cursor(name) >>
				/click left auto
			} else {
				/echo Destroying: << $cursor(name) >>
				/click left destroy
			}
			/delay 5
		}
		/varadd LoopCount 1
		/if "$cursor()"!="NULL" {
			/if n $LoopCount<$ArraySize /goto :itemchecker
		}

		/if "$cursor()"!="NULL" {
			/if "$DefKeep"=="TRUE" {
				/echo Destroying: << $cursor(name) >>
				/click left destroy
			} else {
				/echo Keeping: << $cursor(name) >>
				/click left auto
			}
			/delay 5
		}
		/mouseto $MousePos
/return

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Sat May 31, 2003 4:30 pm

This script is quite nice. I was wondering if there were a way of adding a feature so that if a variable is set, and you are ATTACKED while foraging, you'd automatically cast a spell gem (ie, gate).

That bitch horse in LFay has killed me too many times while foraging...even at 65. I've got a nice script for Xylobot that forages and successfully gets me the hell out of dodge when attacked, but it would be nice to use MQ for everything.

This script as it is right now works great for me though :)