I am leaving the following, but there is no reason to use it or maybe even read it.
The comments should pretty much say it all. I took the ts.mac and made it work with the currently broken /click left item and added a few features found in the todo list as well as a few new features of my own desire. Of major note is the replacement of the "keep" / "destory" portion of the command line macro launch. It can STILL be found IN the macro, and is set to "keep" by default. Instead you can specify a number, 0 for unlimited and anything else for the number of successful combines you would like. That is just more useful to me, besides i think /click left destroy is broken?
Be sure to open your inventory and arrange all your bags so they do not overlap. Then close each bag and your inventory before you start the script. If you are using an environmental container, be sure IT'S position does not overlap AND that it is open when you start the script (since /click left item crashes me).
There are a few small code optimizations, but nothing entirely mind blowing. My favorite part is actually the statistics. I have noticed about a 97% success rate on quite a few trivial items with about a 3-4% skill up rate.
NEW!
Removed some double /clicks... but they were all to /click left auto anyway.
Another thanks to Kagonis for his fix of the "env" containers. If you are using and environmental combiner, use "env" instead of its name.
Big thanks to "kagonis" for improving (and posting!) the script. He included a change that lets you increase the delay quite a bit w/o having to worry about bad clicking of items, added a "stop on trivial" feature AND fixed my "attempt to recover from failed attempt" code (quite simply and intelligently i might add!).
Thanks a bunch :)
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> <CombinerName> <Component> [Component] [Component] [Component] [Component] [Component] [Component] [Component] [Component] [Component]
|
| 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. (Notice, MacroQuest NEEDS 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 INSIDE THE SCRIPT, 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 abort 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 inside script, not 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 5 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".
|
|
| *** 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
#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
| ############################## 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 ITEM BECOMES TRIVIAL
/varset EndOnTrivial 1
| SET THE DELAY BETWEEN MOUSE CLICKS HERE
/varset dly 2
| ABORT ON RECIEVING A TELL, SET TO "TRUE" or "FALSE"
/varset abt "FALSE"
| IF YOU WOULD LIKE TO KEEP YOUR FINAL PRODUCT, SET TO "KEEP" OTHERWISE SET TO "DESTORY"
/varset FinishedProduct "keep"
| ############################## 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
/call ClearCursor $FinishedProduct
/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
}
/if "$p2"=="" {
/echo Syntax: /macro ts <0-X> <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 $FinishedProduct
:CountComponents
/varset a(1,$TotalComp) "$p$int($calc($TotalComp+2))"
/varadd TotalComp 1
/if n $int($TotalComp)>10 {
/echo Syntax: /macro ts <0-X> <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
/call ClearCursor $FinishedProduct
/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 $FinishedProduct
/if "$target(name,clean)"=="$char(name)" {
/echo You have targeted yourself, pausing. To resume, type /target clear or just 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
}
/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 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
/if n $l2==1 /if "$pack($l39,combine)"=="$l1" /varset CombInt $l3
/next l3
/if n $CombInt==99 {
/if "$l1"=="env" /varset CombInt 8
/if $CombInt!=8 {
/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 DisplayStats
/echo Combine Statistics - Successes: $int($SkillSuccessCounter), Failures: $int($SkillFailCounter), Trivial: $int($SkillTrivialCounter)
/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
/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, stopping.
/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!
/beep
/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





