ts.mac - All Purpose Tradeskill Macro

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

Moderator: MacroQuest Developers

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

ts.mac - All Purpose Tradeskill Macro

Post by kagonis » Sat Jun 21, 2003 10:39 pm

This kind of macro has been seen before, since most of the ideas comes from other macros. I only take credit for cleaning up a lot of it.

If you know an item -will- be returned, or have a high chance of being returned upon a combine (or failed combine), those items are recommended to be listed as the first items on the list of components. This saves the macro from cycling through the array more than necessary, thereby taking up less ressources and less time.

Edit:
Added the new Argument Parsing routines I have been working on, wich now makes it possible to change all settings from within EverQuest, or merely let it use its hardcoded defaults.
Type:
/macro ts help
in-game for more help (beware, it produces a lot of text).

I didn't want to make a new thread with this, calling it sisits (/tease fryfrog thanks for all your awesome additions), cause all scripts evolve, no reason to start new threads, just give them new version numbers ;) (mine is oddly enough still version unknown, I just add features as I find the time, and need).

As allways, use at your own risk, I take no responsibility for accidently destroyed items etc. (trust me I have been there during the making of some of my macros ;).
Please post any changes, bugs, or bugfixes on this thread, I will edit the original post (this one) with the changes, as well as proper credits ;)

Have fun tradeskilling without spraining your wrist :)

Code: Select all

| ts.mac (tradeskill.mac)
| ----------------------- 
| *** DESCRIPTION *** 
| ts.mac is a versatile Tradeskilling Macro, made for the purpose of lessening the strain
| on our wrists and fingers.
|
| A quick list of some of it's features.
|
| - Can combine up to 10 items in the selected combiner.
|
| - Can be set to destroy the end-combine (good for when skilling up) rather than keep it.
|   (Thanks to pita for fixing this)
|
| - Pause script by targeting self.
|   (Thanks to fryfrog)
|
| - Combine X number of successes, or unlimited.
|   (Thanks to fryfrog)
|
| - Turn on/off display of statistics.
|   (Thanks to fryfrog for implementing, thanks to pita for minor cosmetic fix)
|
| - Statistics about combines such as trivial combines, successes, failures, skillups, % of
|   successes and % of skillups.
|   (Thanks to fryfrog)
|
| - Trivial warning.
|   (Thanks to fryfrog)
|
| - Failed combine recovery, cleans pack and retries 2 times.
|   (Thanks to fryfrog for implementing, thanks to Kagonis for minor fix)
|
| - Can use wildcard matching on both combiner and components. Ie: "#ore" matches
|   "small brick of high quality ore", and "#sewing" matches "Collapsible Sewing Kit" etc.
|   (Thanks to Serberus for initial idea, Kagonis for cleanup)
|
| - Can change all settings from within EverQuest, thanks to the new arugment parsing
|   routines.
|   (Thanks to Kagonis)
|
| A few things to note before starting to use this..
| 1. Open ALL container windows and your Inventory window, as well as any enviromental
|    combiners needed such as forge, pottery wheel etc.
| 2. Place all so none of the windows are hidden beneath another window.
| 3. Make sure to close all container windows if you moved them since opening them, then
|    open them, this is to save their positions, so the Macro can find the right slots.
|
| In game, type the following for more help..
| /macro ts help
|
|
| *** SYNTAX ***
| /macro ts <"various options here"> <"combiner"> <"component"> ["component"]...
|
|
| *** EXAMPLE ***
| /macro ts "default" "Mortar and Pestle" "Celestial Solvent" "The Scent of Marr"
|
|
| *** CREDITS *** 
| These are the persons I know I borrowed code from, I'm sure I forgot some..
| In no particular order..
| -- 
| Gengis, Pigeon, Serberus, fryfrog, pita.
|
|
| *** TODO ***
| - Ini file support.
|   Save recipes in an ini file, and call them by their recipe name.
|   /macro ts "default" "ini" "Celestial Essence"
|
|   [Celestial Essence]
|   comb1=Mortar and Pestle
|   comb2=Collabisble Mortar and Pestle
|   comp1=Celestial Solvent
|   comp2=The Scent of Marr
|
|   It should be possible to give it multiple choices of comb(iners), the script should then
|   just select, and use the first comb(iner) found.
|

#turbo
#define CombStr v1
#define CombInt v2
#define TotalComp v3
#define dly v4
#define abt v5
#define cbe v6
#define SkillFailCounter v50
#define SkillSuccessCounter v51
#define SuccessRate v53
#define TotalAttempts v54
#define SkillUpCounter v55
#define SkillUpRate v56
#define ShowStats v57
#define CombineErrorCounter v58
#define SkillTrivialCounter v59
#define FinishedProduct v60
#define ErrorAtCombine v61
#define DesiredSuccesses v62
#define EndOnTrivial v63

#event SkillTrivial "You can no longer advance your skill from making this item"
#event SkillUp "You have become better at"
#event SkillFailure "You lacked the skills"
#event SkillSuccess "You have fashioned the items together to create something new"
#event FullInventory "There was no place to put that"
#event CombineError "You cannot combine these items in this container type!"
#chat tell

Sub Main
	/call SetDefaults
	/if "$p0"=="" /call ExecError
	/if "$p0"=="help" /call ShowHelp
	/call ParseArgs "$p0"

	/varset ErrorAtCombine 0
	/varset CombineErrorCounter 0
	/varset SkillTrivialCounter 0
	/varset SkillFailCounter 0
	/varset SkillSuccessCounter 0
	/varset SuccessRate 0
	/varset TotalAttempts 0
	/varset SkillUpRate 0
	/varset SkillUpCounter 0
	
	/call CombFind "$p1"
	/if $CombInt<=7 /varset CombStr "pack $CombInt"
	/if $CombInt==8 {
		/varset CombInt e
		/varset CombStr enviro
	}
	/if $CombInt>=98 /if $CombInt<=99 {
		/if n $CombInt==99 /echo Cannot find container << $p1 >>
		/if n $CombInt==98 /echo Too far away from << $p1 >>
		/endmacro
	}

	/varset TotalComp 0
	/call ClearCursor $FinishedProduct
	:CountComponents
		/varset a(1,$TotalComp) "$p$int($calc($TotalComp+2))"
		/varadd TotalComp 1
		/if n $int($TotalComp)>10 /call ExecError
		/echo Component $int($TotalComp): $p$int($calc($TotalComp+1))
		/if "$p$int($calc($TotalComp+2))"~~"$" {
			/goto :DestroyCheck
		} else /if "$p$int($calc($TotalComp+2))"=="" {
			/goto :DestroyCheck
		} else {
			/goto :CountComponents
		}

	:DestroyCheck		
	/if $FinishedProduct=="DESTROY" {
		/beep
		/press F1
		/echo This macro is currently set to destroy successful combines!!!!
	}

	:Begin
		/call ClearCursor $FinishedProduct
		/doevents

		/if "$target(name,clean)"=="$char(name)" {
			/echo Pausing!! To resume, type /target clear or target something 

else.
			:HoldingPattern
				/delay 2s
				/if "$target(name,clean)"=="$char(name)" /goto 

:HoldingPattern
		}
		/if n $DesiredSuccesses!=0 /if n $DesiredSuccesses<=$SkillSuccessCounter {
			/echo Created $int($DesiredSuccesses) items as requested!
			/call EndCombines
		}
		/for l0 0 to $int($calc($TotalComp-1))
			/call AddComp "$a(1,$l0)" $l0
		/next l0

	:Combine
		/doevents
		/call DoCombine

	:ClearCursor
		/doevents
		/call ClearCursor $FinishedProduct
	}	
	/goto :Begin
/return

Sub SetDefaults
	/varset ShowStats 1
	/varset EndOnTrivial 0
	/varset dly 2
	/varset abt 0
	/varset FinishedProduct "keep"
	/varset DesiredSuccesses 0
/return

Sub CheckOptions
	/if "$p1"=="" {
		/echo Syntax: /call CheckOptions "option" "value"
		/endmacro
	}
	/if "$p0"=="combines" /varset DesiredSuccesses $int($p1)
	/if "$p0"=="cursor-delay" /varset dly $int($p1)
	/if "$p0"=="end-on-trivial" /varset EndOnTrivial $int($p1)
	/if "$p0"=="abort-on-tell" /varset abt $int($p1)
	/if "$p0"=="destroy" /if n $p1==1 /varset FinishedProduct "destroy"
	/if "$p0"=="show-stats" /varset ShowStats $int($p1)
/return

Sub ParseArgs
	/if "$p0"=="" {
		/echo Syntax: /call ParseArgs "space seperated string of arguments"
		/endmacro
	}
	/if "$p0"~~"default" {
		/call SetDefaults
		/goto :EndOptions
	}
	/varset l0 "$p0"
	/call CountArgs "$l0"
	/varset l1 $int($return)
	/for l2 1 to $l1
		/if n $l1>1 /varset l0 "$arg($int($l2),"$p0")"
		/varset l3 $left($instr("=","$l0"),"$l0")
		/varset l4 $right($calc($strlen("$l0")-$instr("=","$l0")-1),"$l0")
		/call CheckOptions "$l3" "$l4"
	/next l2
	:EndOptions
/return

Sub CountArgs
	/if "$p0"=="" {
		/echo Syntax: /call CountArgs "space seperated string of arguments"
		/endmacro
	}
	/varset l0 1
	/varset l1 1
	:Loop
		/if "$mid($int($l1),1,"$p0")"==" " /varadd l0 1
		/varadd l1 1
	/if n $l1<$strLen("$p0") /goto :Loop
/return $int($l0)

Sub ExecError
	/echo Syntax error.
	/echo Type the following for more help:
	/echo /macro ts "help"
	/endmacro
/return

Sub ShowHelp
	/echo Syntax: /macro ts <options> <CombinerName> <Component> [Component]...
	/echo Example: /macro ts "show-stats=0 destroy=0 abort-on-tell=0 end-on-trivial=0" 

"Sewing Kit" "Spider Silk" "Spider Silk"
	/echo -
	/echo MAKE SURE THAT:
	/echo * Inventory is open.
	/echo * All your containers are open.
	/echo * Nothing crosses over each other, all windows (bags, inventory, buttons) must 

be free.
	/echo * Your windos positions are saved (by closing them and opening them again 

after they have been moved).
	/echo -
	/echo Options:
	/echo --------
	/echo * show-stats
	/echo -- Syntax: show-stats=1|0
	/echo -- Example: show-stats=0
	/echo -- Shows combine statistics.
	/echo -- Set to 1 for show showing stats, 0 to leave out the stats.
	/echo -- Default set to 1 (show stats).
	/echo -
	/echo * destroy
	/echo -- Syntax: destroy=1|0
	/echo -- Example: destroy=1
	/echo -- Tells the macro wether end-result is destroyed or kept.
	/echo -- Set to 1 for destroying end-result, 1 to keep end-result.
	/echo -- Default set to 0 (keep end-result).
	/echo -
	/echo * abort-on-tell
	/echo -- Syntax: abort-on-tell=1|0
	/echo -- Example: abort-on-tell=1
	/echo -- Tell the macro wether it should /endmacro when recieving a tell.
	/echo -- Set to 1 for ending macro on tells, 0 to ignore tells.
	/echo -- Default set to 0 (ignore tells).
	/echo -
	/echo * end-on-trivial
	/echo -- Syntax: end-on-trivial=1|0
	/echo -- Example: end-on-trivial=1
	/echo -- Tell the macro wether it should stop combines when recieving a trivial 

message.
	/echo -- Set to 1 for ending macro on trivial, 0 to ignore trivial.
	/echo -- Default set to 0 (ignore trivial).
	/echo -
	/echo * cursor-delay
	/echo -- Syntax: cursor-delay=#
	/echo -- Example: cursor-delay=4
	/echo -- The delay between mouse commands in the macro.
	/echo -- Increase this number to make the macro combine slower, but more safely. 

Decrease the number to combine faster, but more prone to errors.
	/echo -- Default set to 2 (this is as fast as it has been tested to be able to go)
	/echo -
	/echo * combines
	/echo -- Syntax: combine=#
	/echo -- Example: combine=100
	/echo -- The number of successfull combines you want made (or till no more 

components are available).
	/echo -- Set to 0 for unlimited combines (or till no more components are available), 

or to the wanted amount.
	/echo -- Default set to 0 (unlimited).
	/echo -
	/echo * default
	/echo -- Syntax: default
	/echo -- Tell the macro to use all default settings, any other options set will be 

ignored and defaults will be used.
	/endmacro
/return

Sub CleanPack
	/press ctrl
	/sendkey down shift
	/if "$CombStr"=="enviro" {
		/varset l0 10
	} else {
		/varcalc l0 $pack($CombInt,slots)-1
	}

	/for l1 0 to $l0
		/click left $CombStr $l1
		/delay $dly
		/click left auto
		/delay $dly
	/next l1
	/sendkey up shift
	/press shift
/return

sub ClearCursor
	:Loop
		/delay $dly
		/if $cursor()!=NULL {
			/if "$p0"=="DESTROY" {
				/varset l0 0
				:SubLoop
				  /if "$a(1,$l0)"~~"#" {
						/varset l1 

"$right($calc($strlen("$a(1,$l0)")-1),"$a(1,$l0)")"
						/varset l2 0
					} else {
						/varset l1 "$a(1,$l0)"
						/varset l2 1
					}
					/if n $l2==0 /if "$cursor(name)"~~"$l1" {
						/click left auto
						/delay $dly
					} else /if n $l2==1 /if "$cursor(name)"=="$l1" {
						/click left auto
						/delay $dly
					}
					/if "$cursor()"!="NULL" {
						/if n $l0< $calc($TotalComp-1) {
							/varadd l0 1
							/goto :SubLoop
						} else {
							/click left destroy
							/delay $dly
						}
					}
			} else {
				/click left auto
				/delay $dly
			}
		}
		/if $cursor()!=NULL /goto :Loop
/return

sub DoCombine
	:Loop
		/click left $CombStr combine
		/doevents
		/delay $dly
		/if $pack($CombInt,empty)==FALSE /goto :Loop
/return

sub AddComp
	/press shift
	/sendkey down ctrl
	/if "$p0"~~# {
		/finditem similar "$right($calc($strlen("$p0")-1),"$p0")"
	} else {
		/finditem "$p0"
	}
	/if $find()==FALSE /goto :NoComp
	/delay $dly
	/click left $CombStr $p1
	/goto :End
	:NoComp
		/echo Could not find << $p0 >>
		/call EndCombines
	:End
		/sendkey up ctrl
		/press ctrl
/return

Sub CombFind
	/varset CombInt 99
	/if "$p0"~~"#" {
		/varset l1 "$right($calc($strlen("$p0")-1),"$p0")"
		/varset l2 0
	} else {
		/varset l1 "$p0"
		/varset l2 1
	}
	/for l3 0 to 7
		/if n $l2==0 /if "$pack($l3,name)"~~"$l1" /varset CombInt $l3
		/if n $l2==1 /if "$pack($l3,name)"=="$l1" /varset CombInt $l3
	/next l3

	/if n $CombInt==99 {
		/if "$l1"=="enviro" /varset CombInt 8
		/if n $CombInt!=8 /itemtarget $p0	
		/if n $CombInt!=8 /if n $ground(id)==0 /varset CombInt 99
		/if n $CombInt!=8 /if n $distance(item)>20 /varset CombInt 98
		/if n $CombInt!=8 /if n $ground(id)>0 /if n $distance(item)<=20 /varset 

CombInt 8
	}
/return $CombInt

Sub DisplayStats
	/echo Combine Statistics - Successes: $int($SkillSuccessCounter), Failures: 

$int($SkillFailCounter), Trivial: $int($SkillTrivialCounter)
	/varcalc TotalAttempts $SkillFailCounter + $SkillSuccessCounter
	/if $TotalAttempts>0 {
	/varcalc SuccessRate $SkillSuccessCounter / $TotalAttempts * 100
	/varcalc SkillUpRate $SkillUpCounter / $TotalAttempts * 100
	/echo Successes Rate: $int($SuccessRate) % out of $int($TotalAttempts) attempts
	} else {
		/echo Unable to complete a combine.  No Stats to report
	}
	/if n $SkillUpCounter>0 /echo Skill Ups: $int($SkillUpCounter) , Skill Rate: 

$int($SkillUpRate) % out of $int($TotalAttempts) attempts
	/if n $SkillTrivialCounter>0 /echo THIS ITEM IS OR HAS GONE TRIVIAL!
/return

Sub EndCombines
	/call CleanPack
	/if n $ShowStats==1 /call DisplayStats
	/endmacro
/return

Sub Event_Chat
	/if "$abt"=="TRUE" {
		/echo Got a tell, pausing.
		/press F1
	}
/return

Sub Event_CombineError
	/varcalc ErrorAtCombine $SkillFailCounter + $SkillSuccessCounter
	/varadd CombineErrorCounter 1
	/if n $CombineErrorCounter<=1 {
		/echo Attempting to recover from failed combine!
		/call CleanPack
	} else {
		/echo Failed to recover from failed combine!
		/call EndCombines
	}
/return

Sub Event_FullInventory
	/echo Your inventory is full, ending macro.
	/call EndCombines
/return

Sub Event_SkillFailure
	/varadd SkillFailCounter 1
	/if n $CombineErrorCounter>=1 /varset CombineErrorCounter 0	
/return

Sub Event_SkillSuccess
	/varadd SkillSuccessCounter 1
	/if n $CombineErrorCounter>=1 /varset CombineErrorCounter 0
/return

Sub Event_SkillUp
	/varadd SkillUpCounter 1
	/echo $int($SkillUpCounter) skill ups in 

$int($calc($SkillFailCounter+$SkillSuccessCounter)) attempts!
/return

Sub Event_SkillTrivial
	/varadd SkillTrivialCounter 1
	/if n $ShowStats==1 /if n $SkillTrivialCounter==1 /echo THIS ITEM IS OR HAS GONE 

TRIVIAL!
	/if n $EndOnTrivial==1 /if n $SkillTrivialCounter==1 /call EndCombines
/return
Last edited by kagonis on Tue Sep 23, 2003 2:30 am, edited 1 time in total.

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

Post by kagonis » Tue Jul 01, 2003 6:17 pm

$cbe ins't used yet, it's in there for counting the number of times in a row there are CombineErrors.

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

Post by kagonis » Fri Jul 11, 2003 1:51 pm

Gonna build in ini support sometime soon when I get around to it.
The idea is to do a /macro ts "Justice Fruit Pie"

Then the ini file would look like this:
[Justice Fruit Pie]
combiner=Collapbisble Spit
endproduct=keep
c1=Muffin Tin
c2=Justice Fruit
c3=Clump of Dough
c4=Celestial Essence
c5=Celestial Essence
[Fish Rolls]
combiner=Collapsible Spit
endproduct=keep
c1=Bat Wing
c2=Fresh Fish

topgun
a lesser mummy
a lesser mummy
Posts: 43
Joined: Thu Jan 09, 2003 8:27 am

Post by topgun » Mon Jul 14, 2003 6:41 pm

I think this one sounds great. I have made the change you describe to MQ.h and recompiled.
But i get the following error everytime i try to use it
Ending macro: subrutine Clearcursor wasn't found
I cant find the error. I have tryes to rename the subrutine and all references to it, but i get the same error, only with my new name instead

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Tue Jul 15, 2003 7:11 am

the portion that is meant to comment out the line is doing it, use | instead of |** to comment out that section.

topgun
a lesser mummy
a lesser mummy
Posts: 43
Joined: Thu Jan 09, 2003 8:27 am

Post by topgun » Tue Jul 15, 2003 11:24 am

Tnx, it helped

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Tue Jul 15, 2003 6:05 pm

since /click left item was crashing me i had to comment out a couple of lines to use environmental containers and i also had to fix up the exit error code thing a little bit. I also added a success / failure counter. please feel free to rip the code and put it in yours if you want :)

I really love your macro, it works with multiple returned items like a champ and it is flexible like i couldn't believe :)

Oh yeah, i forgot: Since /click left item crashes me i disabled it, which means if you are using an env item, it needs to be OPEN when you start the script.

Update: Added some tracking of skill ups, failures and successes which output at the end of the script. Skill ups are announced when it happens.

Code: Select all

| ts.mac (tradeskill.mac) 
| ----------------------- 
| *** DESCRIPTION *** 
| Syntax: /macro ts <Keep|Destroy> <CombinerName> <Component> [Component] [Component] [Component] [Component] [Component] [Component] [Component] [Component] [Component] 
| Can add up to 10 components and combine them in the selected combiner. (Notice, MacroQuest NEED to be compiled to handle more than 10 paramaters, read subnote on what file to edit, and what line.) 
| Can specify wether to keep or destroy the finished product, returned components WILL NOT be destroyed, only the new item(s), that isn't part of the component list. 
| As a precaution, it must specifically say "destroy" (case doesn't matter, case insensitive), if it says anything else it will keep the end product. 
| 
| Please note that I have told the macro to use /click left done rather than /click left combine, this is due to the fact that my UI makes it click a bit off otherwise. 
| There still are some minor bugs, nothing big though. Those that are bothered by them can fix them and post their changes in this thread ;) 
| 
| To speed up the macro I put in #turbo and /delay's after just about each mouse movement. The delay is defined the ghe global variable $dly 
| Set wether to abort macro on tell or to ignore it with the global variable $abt 
| 
| 
| *** CREDITS *** 
| These are the persons I know I borrowed code from, I'm sure I forgot some.. 
| -- 
| General idea, and many of the sub routines from: 
| - Gengis (http://macroquest2.com/phpBB2/viewtopic.php?p=4759#4759) 
| - Pigeon (http://macroquest2.com/phpBB2/viewtopic.php?p=15523#15523) 
| 
| - #Wildcard sub routine idea from Serberus (http://macroquest2.com/phpBB2/viewtopic.php?p=9443#9443) 
| 
| 
| *** TODO *** 
| - Rumors say that when using "destroy", the macro is not working completely as intended. Investigating. 
| - Thinking about adding some statistic Sub Routines, as in Zeuz's macro (http://macroquest2.com/phpBB2/viewtopic.php?p=16800#16800) 
| - On CombineError, make the macro "/call CleanPack" 1 time, then retry combine. If CombineError 2 times in a row then "/call EndCombines". 
| 
| 
| *** SUB NOTE *** 
| Before compiling MacroQuest (note; the search strings are without the quotes): 
| - OPEN "EQLib\MQ.h" 
| - FIND "#define MAX_STACKVARS 10" 
| - REPLACE "#define MAX_STACKVARS 30" 

#turbo 
#define CombStr v1 
#define CombInt v2 
#define TotalComp v3 
#define dly v4 
#define abt v5 
#define cbe v6
#define SkillFailCounter v50
#define SkillSuccessCounter v51
#define SuccessRate v53
#define TotalAttempts v54
#define SkillUpCounter v55
#define SkillUpRate v56

#event SkillUp "You have become better at"
#event SkillFailure "You lacked the skills"
#event SkillSuccess "You have fashioned the items together to create something new"
#event FullInventory "There was no place to put that" 
#event CombineError "You cannot combine these items in this container type!" 
#chat tell 

Sub Main 
   |/cleanup
   /varset SkillFailCounter 0
   /varset SkillSuccessCounter 0
   /varset SuccessRate 0
   /varset TotalAttempts 0
   /varset SkillUpRate 0
   /varset SkillUpCounter 0
   | SET THE DELAY BETWEEN MOUSE CLICKS HERE 
   /varset dly 3
   | ABORT ON RECIEVING A TELL, SET TO "TRUE" or "FALSE"
   /varset abt "FALSE"
   /call ClearCursor $p0
   /if "$p2"=="" {
      /echo Syntax: /macro ts <Keep|Destroy> <CombinerName> <Component> [Component]... 
      /endmacro 
   } 
   /call CombFind "$p1" 
   /if $CombInt<=7 /call OpenInv 
   /if $CombInt==8 { 
      /call OpenEnv 
      /delay $dly 
   }
   /if $CombInt>=98 /if $CombInt<=99 { 
      /if n $CombInt==99 /echo Cannot find container << $p1 >> 
      /if n $CombInt==98 /echo Too far away from << $p1 >> 
      /endmacro
   }
   /call HandlePacks open
   /varset TotalComp 0
   /call ClearCursor $p0
   :CountComponents
      /varset a(1,$TotalComp) "$p$int($calc($TotalComp+2))"
      /varadd TotalComp 1
      /if n $int($TotalComp)>10 {
         /echo Syntax: /macro ts <Keep|Destroy> <CombinerName> <Component> [Component]...
         /echo You can only add up to a total of 10 components.
         /endmacro
      }
      /echo Component $int($TotalComp): $p$int($calc($TotalComp+1))
      /if "$p$int($calc($TotalComp+2))"~~"$" {
         /goto :Begin
      } else /if "$p$int($calc($TotalComp+2))"=="" {
         /goto :Begin
      } else {
         /goto :CountComponents
      }
   :Begin
   	  /doevents
      /for l0 0 to $int($calc($TotalComp-1)) 
         /call AddComp "$a(1,$l0)" $l0 
      /next l0 

   :Combine
   	  /doevents
      /call DoCombine

   :ClearCursor
      /doevents 
      /call ClearCursor $p0 
   /goto :Begin
/return 

Sub CleanPack 
   /press ctrl 
   /sendkey down shift 
   /if "$CombStr"=="enviro" { 
      /varset l0 10 
   } else { 
      /varcalc l0 $pack($CombInt,slots)-1 
   } 

   /for l1 0 to $l0 
      /click left $CombStr $l1 
      /delay $dly 
      /click left auto
      /click left auto
      /delay $dly 
   /next l1 
   /sendkey up shift 
   /press shift 
/return 

Sub HandlePacks 
   /varset l0 0 
   /if "$p0"=="open" /goto :Open 
   /if "$p0"=="close" /goto :Close 
   /if "$p0"=="" /goto :Syntax 
   :Open 
      /for l0 0 to 7 
         /if "$pack($int($l0))"=="TRUE" /if "$pack($int($l0),open)"=="FALSE" /click right inv $int($l0) 
         /delay $dly 
      /next l0 
      /goto :End 
   :Close 
      /for l0 0 to 7 
         /if "$pack($int($l0))"=="TRUE" /if "$pack($int($l0),open)"=="TRUE" /click right inv $int($l0) 
         /delay $dly 
      /next l0 
      /goto :End 
   :Syntax 
      /echo Syntax: /call HandlePacks <open|close> 
      /endmacro 
   :End 
/return 

Sub OpenInv 
   /varset CombStr "pack $CombInt" 
   /if "$pack($int($l0),open)"=="FALSE" /click right inv $int($l0) 
   /delay $dly 
   /if $pack($CombInt,empty)==FALSE /call CleanPack 
/return 

Sub OpenEnv 
   /varset CombInt e 
   /varset CombStr enviro 
   /face item 
   /delay $dly 
   |/click left item 
   |/delay $dly 
| Code currently not functioning. 
|   :WaitOpen 
|      /if $pack($CombInt,open)==FALSE /goto :WaitOpen 
|   /delay $dly 
|   /if $pack($CombInt,empty)==FALSE /call CleanPack 
/return 

sub ClearCursor 
   :Loop 
      /delay $dly 
      /if $cursor()!=NULL { 
         /if "$p0"=="DESTROY" { 
            /varset l0 0 
            :SubLoop 
               /if "$a(1,$l0)"~~"#" { 
                  /varset l1 "$right($calc($strlen("$a(1,$l0)")-1),"$a(1,$l0)")" 
                  /varset l2 0 
               } else { 
                  /varset l1 "$a(1,$l0)" 
                  /varset l2 1 
               } 

               /if n $l2==0 /if "$cursor(name)"~~"$l1" { 
                     /click left auto
                     /click left auto
                     /delay $dly 
               } else /if n $l2==1 /if "$cursor(name)"=="$l1" { 
                     /click left auto 
                     /click left auto
                     /delay $dly 
               } 
               /if "$cursor()"!="NULL" { 
                  /if n $l0<$TotalComp { 
                     /varadd l0 1 
                     /goto :SubLoop 
                  } else { 
                     /click left destroy 
                     /delay $dly 
                  } 
               } 
         } else { 
            /click left auto
            /click left auto
            /delay $dly 
         } 
      } 
      /if $cursor()!=NULL /goto :Loop 
/return 

sub DoCombine 
   :Loop
      | CLICK LEFT COMBINE MISSES THE COMBINE BUTTON WITH MY UI, TEMPORARY FIX BY SETTING IT TO DONE. 
      | /click left $CombStr done
      /click left $CombStr combine
      /doevents 
      /delay $dly 
      /if $pack($CombInt,empty)==FALSE /goto :Loop 
/return 

sub AddComp 
   /press shift 
   /sendkey down ctrl 
   /if "$p0"~~# { 
      /finditem similar "$right($calc($strlen("$p0")-1),"$p0")" 
   } else { 
      /finditem "$p0" 
   } 
   /if $find()==FALSE /goto :NoComp 
   /delay $dly 
   /click left $CombStr $p1 
   /goto :End 
   :NoComp 
      /echo Could not find << $p0 >> 
      /call EndCombines 
   :End 
      /sendkey up ctrl 
      /press ctrl 
/return 

Sub CombFind 
   /varset CombInt 99 
   /if "$p0"~~"#" { 
      /varset l1 "$right($calc($strlen("$p0")-1),"$p0")" 
      /varset l2 0 
   } else { 
      /varset l1 "$p0" 
      /varset l2 1 
   } 
   /for l3 0 to 7 
      /if n $l2==0 /if "$pack($l3,name)"~~"$l1" /varset CombInt $l3 
      /if n $l2==1 /if "$pack($l3,name)"=="$l1" /varset CombInt $l3 
   /next l3 
   /if n $CombInt==99 { 
      /itemtarget $p0 
      /if n $ground(id)==0 /varset CombInt 99 
      /if n $distance(item)>20 /varset CombInt 98 
      /if n $ground(id)>0 /if n $distance(item)<=20 /varset CombInt 8 
   } 
/return $CombInt 

Sub EndCombines 
   /call CleanPack 
   |/cleanup
   /echo Successes: $int($SkillSuccessCounter), Failures: $int($SkillFailCounter)
   /varcalc TotalAttempts $SkillFailCounter + $SkillSuccessCounter
   /varcalc SuccessRate $SkillSuccessCounter / $TotalAttempts * 100
   /varcalc SkillUpRate $SkillUpCounter / $TotalAttempts * 100
   /echo Successes Rate: $int($SuccessRate) % out of $int($TotalAttempts) attempts
   /if n $SkillUpCounter>0 /echo Skill Ups: $int($SkillUpCounter) , Skill Rate: $int($SkillUpRate) % out of $int($TotalAttempts) attempts
   /endmacro 
/return 

Sub Event_Chat 
   /if "$abt"=="TRUE" { 
      /echo Got a tell, stopping. 
      /call EndCombines 
   } 
/return 

Sub Event_CombineError 
   /echo You cannot combine these items in this container type! 
   /call EndCombines 
/return 

Sub Event_FullInventory 
   /echo Your inventory is full, ending macro. 
   /call EndCombines 
/return

Sub Event_SkillFailure
    /varadd SkillFailCounter 1
/return

Sub Event_SkillSuccess
    /varadd SkillSuccessCounter 1
/return

Sub Event_SkillUp
	/varadd SkillUpCounter 1
	/echo $int($SkillUpCounter) skill ups in $int($calc($SkillFailCounter+$SkillSuccessCounter)) Attempts!
/return
Last edited by fryfrog on Tue Jul 22, 2003 9:05 am, edited 2 times in total.

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Wed Jul 16, 2003 8:20 pm

What is this if comparison doing? I have never seen the # thing?

Code: Select all

/if "$p0"~~# { 
      /finditem similar "$right($calc($strlen("$p0")-1),"$p0")" 
}

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Wed Jul 16, 2003 8:52 pm

it's seeing if $p0 has a "#" in it (as the first char I'd assume, though this actually finds a # anywhere in it) and if it finds the # it cuts off the first char of $p0 and passes it to a /find similar...

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Wed Jul 16, 2003 10:47 pm

Okay, that makes sense. What I don't get is how to use it :)

I would assume that this is to make it easier to list ingrediants, but I don't quite see how one would use it.

Lets say I wanted to make Clumps of Dough. That would be "Some Egg" "Cup of Flour" "Bottle of Milk"

Now, this recepiet can be done with many different types of eggs. If you just use "Egg" it of course doesn't find anything. Is that if statement making is so you could use "#Egg" and it would use anything that was similar to "Egg"? I should just try it but I'm not in front of an eq computer :)

Random
decaying skeleton
decaying skeleton
Posts: 5
Joined: Sun Jul 20, 2003 3:31 pm

Post by Random » Mon Jul 21, 2003 1:18 pm

Great macro, just wish destroy worked =)

Keep up the good work

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Tue Jul 22, 2003 4:22 am

My girlfriend helped me confirm that # is like a wild card operator. If you are making Clumps of Dough, #Egg will match Drake Eggs or Basalisk Eggs. Spiffy.

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Tue Jul 22, 2003 7:35 am

I am having some trouble with it when using it to combine items with 8 or more components. This only started recently, as I have used it to do the same thing in the past. What was happening was when the macroquest script startup variables $p0 - $pXX went to double digits... What was happening was instead of seeing (for example) $p10 (using $p$int($calc($TotalComp+2)) as being "" (when there was nothing assigned) it was for some reason seeing it ss "$P10" (which echos as "@p10"). To fix it, i put an additional check for "$" as well as the "" (empty) and it seems to work okay.

Code: Select all

/if "$p$int($calc($TotalComp+2))"~~"$" {
   /goto :Begin
} else /if "$p$int($calc($TotalComp+2))"=="" {
   /goto :Begin
} else {
   /goto :CountComponents
}

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Tue Jul 22, 2003 8:25 am

could also fix it by setting your MAX_STACKVARS to a higher number and recompiling... mine are set at 30.

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Tue Jul 22, 2003 8:29 am

Actually, thats the first thing I did when I saw the error. "#define MAX_STACKVARS 30" right?

OMG...

I know what it was...

I did an nmake clean in EQLib, but forgot to do it in ../