Anyone out there, who can and will help ?
This is the only thing between me and the new improved MQ :)
This is a combined version of the sits.mac in the old macro section.
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]
#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 0
| 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
/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
/if n $l2==1 /if "$pack($l39,combine)"=="$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
/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!
/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
