sits.mac - slightly improved ts.mac

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

Moderator: MacroQuest Developers

pita
decaying skeleton
decaying skeleton
Posts: 6
Joined: Sat Sep 06, 2003 5:09 pm

Post by pita » Tue Sep 16, 2003 6:36 am

Here is the complete code I am currently using with destroy on the command line, and worked fine for me when I used it yesterday.
I typically have all bags open, and enviro container open also, before I start the macro.

Only reason, destroy interested me so much, was doing hundreds of pottery combines, that you are never going to fire, and which only sell for coppers, wasn't worth my time.

This macro does everything that I want of it now, so I doubt I will make anymore changes to it.

Code: Select all

| ts.mac (slightly improved tradeskill.mac) 
| ----------------------- 
| *** DESCRIPTION *** 
| IF YOU ARE USING AN ENVIRONMENTAL CONTAINER, HAVE IT OPEN WHEN YOU START THE MACRO 
| Syntax: /macro ts <0-X> <enviro|Combinername> <keep|destroy> <Component1>....[Component10] 
| 
| The first option is how many successes you want, 0 means unlimited and any other number is used for how many successful combines you want 
| Can add up to 10 components and combine them in the selected combiner.  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. 
| 
| 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 pause macro on tell or to ignore it with the global variable $abt 
| 
| Scroll down to "VARIABLES TO LOOK AT!" for some user setable variables 
| 
| *** FEATURES *** 
| - Pause script by targeting self 
| - Combine X number of successes (or unlimited) 
| - Keep or Destory result (set from cmd line) 
| - Turn on/off display of statistics 
| - Statistics about combines such as trivial combines, successes, failures, skillups, % of successes and % of skillups 
| - Trivial warning 
| - Failed combine DNC recovery, cleans pack and retries.  If no error in 2 more attempts will reset and not exit. 
| - Can use wildcard matching "#ShortName" instead of "Pieces of ShortName" (included in previous version, but not mentioned) 
| 
| *** 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. 
| - !DONE BY FRYFROG! Thinking about adding some statistic Sub Routines, as in Zeuz's macro (http://macroquest2.com/phpBB2/viewtopic.php?p=16800#16800) 
| - !DONE BY FRYFROG! On CombineError, make the macro "/call CleanPack" 1 time, then retry combine. If CombineError 2 times in a row then "/call EndCombines". 
| 
| 
#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
#define CombineKeep v64

#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 
   | ############################## VARIABLES TO LOOK AT! ##################################### 
   | SET SHOWSTATS TO 1 TO SHOW STATS AND WARNINGS, 0 FOR OFF 
   /varset ShowStats 1 
   | SET EndOnTrivial to 1 to stop the macro when it becomes trivial
   /varset EndOnTrivial 0
   | SET THE DELAY BETWEEN MOUSE CLICKS HERE 
   /varset dly 2
   | ABORT ON RECIEVING A TELL, SET TO "TRUE" or "FALSE" 
   /varset abt "TRUE" 

   | ############################## VARIABLES TO LOOK AT! ##################################### 


   
   | /cleanup 
   /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 
   /varset CombineKeep 0
    
   /call ClearCursor $FinishedProduct 
   
   /if "$p2"=="destroy" {
   	/varset FinishedProduct "DESTROY"
   	/varset CombineKeep 1
     } else /if "$p2"=="keep" {
     	/varset FinishedProduct "KEEP"
     	/varset CombineKeep 1
     } 
     
   /if n "$CombineKeep"==0 {
   	/echo Syntax: /macro ts <0-X> <enviro|Combinername> <keep|destroy> <Component> [Component]... 
	/endmacro 
   }
   /if "$p3"=="" { 
      /echo Syntax: /macro ts <0-X> <enviro|CombinerName> <keep|destroy> <Component> [Component]... 
      /endmacro 
   } 
    
   /if n $p0>0 /if n $p0<=5000 { 
      /echo Setting to $p0 successful attempts! 
      /varset DesiredSuccesses $p0 
   } else /if $p0==0 { 
      /echo Setting to unlimited attempts! 
      /varset DesiredSuccesses 0 
   } else { 
      /echo Invalid setting for # of attempts 
      /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 $FinishedProduct 
   :CountComponents 
      /varset a(1,$TotalComp) "$p$int($calc($TotalComp+3))" 
      /varadd TotalComp 1 
      /if n $int($TotalComp)>10 { 
         /echo Syntax: /macro ts <0-X> <CombinerName> <keep|destroy> <Component> [Component]... 
         /echo You can only add up to a total of 10 components. 
         /endmacro 
      } 
      /echo Component $int($TotalComp): $p$int($calc($TotalComp+2)) 
      /if "$p$int($calc($TotalComp+3))"~~"$" { 
         /goto :DestroyCheck 
      } else /if "$p$int($calc($TotalComp+3))"=="" { 
         /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 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 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 
                     /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 
   |/cleanup 
   /if n $ShowStats==1 /call DisplayStats 
   /endmacro 
/return 

Sub Event_Chat 
   /if "$abt"=="TRUE" { 
      /echo Got a tell, pausing.
      /press F1
|      /call EndCombines 
   } 
/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 

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

Post by kagonis » Tue Sep 16, 2003 11:04 pm

Added my argument parsing sub-routines, just type "/macro ts help" for info ;)
Cleaned up the code for unecessary stuff, the macro now requires all bags to be open, and not on top of each other, before starting it.

Code: Select all

| ts.mac (tradeskill.mac)
#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+3))"
		/varadd TotalComp 1
		/if n $int($TotalComp)>10 /call ExecError
		/echo Component $int($TotalComp): $p$int($calc($TotalComp+2))
		/if "$p$int($calc($TotalComp+3))"~~"$" {
			/goto :DestroyCheck
		} else /if "$p$int($calc($TotalComp+3))"=="" {
			/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

Garrik
orc pawn
orc pawn
Posts: 10
Joined: Thu Sep 18, 2003 4:04 pm

Post by Garrik » Thu Sep 18, 2003 5:01 pm

Ok, I can't seem to get this to work for me. It does everything fine except it can't seem to find the combine button on my mixing bowl. I've tried in EQw with mouse captured and released and in regular EQ. I've opened and closed and reopened all containers before starting macro. Any ideas? This is using irc-latest.zip version of MQ.

Edit: Also when using Kag's version it only finds 3 of the components in a 4 component recipe.

User avatar
Slice
a hill giant
a hill giant
Posts: 189
Joined: Wed Oct 30, 2002 2:52 pm

Post by Slice » Thu Sep 18, 2003 5:27 pm

Reload the default skin.

/loadskin default 1

Slice

Garrik
orc pawn
orc pawn
Posts: 10
Joined: Thu Sep 18, 2003 4:04 pm

Post by Garrik » Fri Sep 19, 2003 2:15 pm

Ok, that worked. Thanks. Kagonis' version still cuts off the last component in a recipe though for some reason.

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

Post by kagonis » Sat Sep 20, 2003 8:35 pm

I didn't test it after I modded it into the ts.mac, and haven't tested this either, but I think I know what is wrong..

First the changed code..

Code: Select all

	: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
		}
What I think was wrong, was that the number of arguments sent to the script was changed, so you didnt actually miss the last component, but the first.
I've merely decreased the number in my checks by 1, so that instead of +3 (and one place +2) its now +2 (and one place +1).

again, haven't tested it, so it might not be it, but I would think it is.

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

Post by fryfrog » Sun Sep 21, 2003 7:24 am

Maybe you should make your slightly improved slightly improved trade skill script into a new thread? The argument parsting ability is quite a leap forward and I am unsure if I can continue to maintain your better sits myself in this thread. If you don't mind, I think it would benefit the entire world if you made your own thread with your spiffy script in it :)

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

Post by kagonis » Sun Sep 21, 2003 7:53 am

/shrug.
I dont see a big reason for having multiple threads for what is basically the same script, thats why I dumped my original thread wich this one sprang from.

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

Post by fryfrog » Mon Sep 22, 2003 6:03 am

I think your modification to it is such a change and improvement that it should at least be on the front page of the thread... and I don't think I should be the one to have it as the first in mine. Maybe its time to let your ts.mac take back over as the better one, that would work :)

achitophel
decaying skeleton
decaying skeleton
Posts: 1
Joined: Sun Oct 05, 2003 12:31 pm

Working as intended ?

Post by achitophel » Sun Oct 05, 2003 12:44 pm

Is this macro working ? Im trying to do a pottery skillup, but all i get is "[MacroQuest] Cannot find container << Pottery Wheel >>"

I am using default interface
EQW with mouse released
none of the bags overlap, and positions have been memmed
Pottery wheel along with all containers with ingredients are open

What am i doing something wrong ?

User avatar
Slice
a hill giant
a hill giant
Posts: 189
Joined: Wed Oct 30, 2002 2:52 pm

Post by Slice » Sun Oct 05, 2003 2:11 pm

Use env or enviro (I forget which one the original mac has, I made sure mine uses env) for environmental containers like the pottery wheel.

ps. Fryfrog, you going to be converting this to the new format?
Slice

Malice
decaying skeleton
decaying skeleton
Posts: 4
Joined: Mon Oct 06, 2003 9:21 pm

Beginner difficulties

Post by Malice » Mon Oct 06, 2003 9:26 pm

Been reading all the threads and working with the material and suggestions in them but get this every time with this macro.

Ending macro bad variable in /var function.

ts.mac 76(main): /varset v57 1
Cleared the following: Timers Vars and arrays

I am trying to get this to creates celestial essences.

Any help is appreciated.

Malice

MacroFiend
a grimling bloodguard
a grimling bloodguard
Posts: 662
Joined: Mon Jul 28, 2003 2:47 am

Post by MacroFiend » Mon Oct 06, 2003 10:15 pm

Malice, if you are using a version of the MQ code newer than the end of September, you are using a major rewrite of how variables, timers and arrays are structured. This forum has macros for the pre-major revamp versions of MQ that have not been converted.

Malice
decaying skeleton
decaying skeleton
Posts: 4
Joined: Mon Oct 06, 2003 9:21 pm

Post by Malice » Mon Oct 06, 2003 10:41 pm

Thanks. Will hunt around for an older version or a newer version tradeskill macro.

Malice

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

Post by fryfrog » Wed Oct 08, 2003 7:24 am

What you need to do is compile a version of MQ from before the major change and use ts.mac (its the better one). I was hoping to help him convert ts.mac to the new format... but I gotta unlazy myself for that :)