new sits.mac

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

new sits.mac

Post by dont_know_at_all » Wed Oct 08, 2003 4:37 am

Not fully tested but I went from 40 to 60 in baking...

Enjoy.

Code: Select all

| ts.mac (tradeskill.mac)
#turbo

#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
/declare ShowStats global
/declare EndOnTrivial global
/declare dly global
/declare abt global
/declare FinishedProduct global
/declare DesiredSuccesses global
/declare ErrorAtCombine global
/declare CombineErrorCounter global
/declare SkillTrivialCounter global
/declare SkillFailCounter global
/declare SkillSuccessCounter global
/declare SuccessRate global
/declare TotalAttempts global
/declare SkillUpRate global
/declare SkillUpCounter global
/declare CombInt global
/declare CombStr global
/declare TotalComp global
/declare l0 local
/declare a array

   /call SetDefaults
   /if $defined(Param0)==false /call ExecError
   /if "@Param0"=="help" /call ShowHelp
   /call ParseArgs "@Param0"

   /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
   

   |/echo CombFind @Param1
   /call CombFind "@Param1"
   /if n @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 << @Param1 >>
      /if n @CombInt==98 /echo Too far away from << @Param1 >>
      /endmacro
   }

   /varset TotalComp 0
   /call ClearCursor @FinishedProduct
   :CountComponents
      /varset a(@TotalComp) "@Param$int($calc(@TotalComp+2))"
      /varadd TotalComp 1
      /if n $int(@TotalComp)>10 /call ExecError
      /echo Component $int(@TotalComp): @Param$int($calc(@TotalComp+1))
      /if "@Param$int($calc(@TotalComp+2))"~~"@" {
         /goto :DestroyCheck
      } else /if "@Param$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))
         |/echo calling AddComp "@a(@l0)" @l0
         /call AddComp "@a(@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 "@Param1"=="" {
      /echo Syntax: /call CheckOptions "option" "value"
      /endmacro
   }
   /if "@Param0"=="combines" {
    /varset DesiredSuccesses $int(@Param1)
    /return
   }
   /if "@Param0"=="cursor-delay" {
    /varset dly $int(@Param1)
    /return
   }
   /if "@Param0"=="end-on-trivial" {
    /varset EndOnTrivial $int(@Param1)
    /return
   }
   /if "@Param0"=="abort-on-tell" {
    /varset abt $int(@Param1)
    /return
   }
   /if "@Param0"=="destroy" {
    /if n @Param1==1 /varset FinishedProduct "destroy"
    /return
   }
   /if "@Param0"=="show-stats" {
    /varset ShowStats $int(@Param1)
    /return
   }
   /echo unknown option @Param0

/return

Sub ParseArgs
/declare l0 local
/declare l1 local
/declare l2 local
/declare l3 local
/declare l4 local

   /if $defined(Param0)==false {
      /echo Syntax: /call ParseArgs "space seperated string of arguments"
      /endmacro
   }
   /if "@Param0"~~"default" {
      /call SetDefaults
      /goto :EndOptions
   }
   /varset l0 "@Param0"
   /call CountArgs "@l0"
   /varset l1 $int($return)
   /for l2 1 to @l1
      /if n @l1>1 /varset l0 "$arg($int(@l2),"@Param0")"
      /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
/declare l0 local
/declare l1 local
   /if $defined(Param0)==false {
      /echo Syntax: /call CountArgs "space seperated string of arguments"
      /endmacro
   }
   /varset l0 1
   /varset l1 1
   :Loop
      /if "$mid($int(@l1),1,"@Param0")"==" " /varadd l0 1
      /varadd l1 1
   /if n @l1<$strLen("@Param0") /goto :Loop
/return $int(@l0)

Sub ExecError
   /echo Syntax error.
   /echo Type the following for more help:
   /echo /macro sits "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
/declare l0 local
/declare l1 local
   /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
/declare l0 local
/declare l1 local
/declare l2 local
   :Loop
      /delay @dly
      /if $cursor()!=NULL {
         /echo cursor is $cursor()
         /if "@Param0"=="DESTROY" {
            /varset l0 0
            :SubLoop
              /if "@a(@l0)"~~"#" {
                  /varset l1 "$right($calc($strlen("@a(@l0)")-1),"@a(@l0)")"
                  /varset l2 0
               } else {
                  /varset l1 "@a(@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
      /delay @dly
      /delay @dly
      | careful here, this seems to take a long time
      /if $pack(@CombInt,empty)==FALSE /goto :Loop
/return

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

Sub CombFind
/declare l0 local
/declare l1 local
/declare l2 local
/declare l3 local

   /varset CombInt 99
   /if "@Param0"~~"#" {
      /varset l1 "$right($calc($strlen("@Param0")-1),"@Param0")"
      /varset l2 0
   } else {
      /varset l1 "@Param0"
      /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 @Param0   
      /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 n @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
   /echo 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
   /call ClearCursor @FinishedProduct
   /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 
Edited by DKAA: fixed a couple conversion errors -- thanks SimpleMynd_01
Last edited by dont_know_at_all on Tue Oct 14, 2003 5:21 pm, edited 1 time in total.

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

Post by topgun » Wed Oct 08, 2003 5:15 am

Hi have a question (have read the thread in the old macro section)

Will this work

/macro ts "combines=10" "Sewing Kit" "Spider Silk" "Spider Silk"

Or must the options be "default" OR ALL the options ???

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Wed Oct 08, 2003 2:47 pm

That should work.

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

Post by fryfrog » Wed Oct 08, 2003 10:43 pm

Thats great, thanks for translating it :)

Now that I have something I have dealt with and know to compare maybe I can do my own translations :)

Guest

Post by Guest » Thu Oct 09, 2003 1:34 am

Worked great the first time, did silk swatches to verify.

Now it does 1 run through then perma cycles through clicking the combine button.

I put the forge over the spot where the large sewing kit was, opened all containter and made sure the auto drop inventory spot was accessasble. Closed everything and reopened and was getting the 1 run through then perma cycle on the combine button.

Malice

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

Post by Malice » Thu Oct 09, 2003 1:36 am

Didnt log in. last message was mine.

Edit. Figured out my error.

Even though i was using a forge and had it placed over the possition where the sewing kit was, the sewing kit was full and so it kept trying to combine. Emptied the kit and it works as smooth for me as it does everyone else.

Thanks for this great macro.

Regards.

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

Post by topgun » Thu Oct 09, 2003 4:13 am

No need to select "large sewing kit" and place the forge over it. Just open the forge, and make the container "enviro".. Enviro (enviroment container) works instead of forge, brew barrel ect.

seph_yaro
a lesser mummy
a lesser mummy
Posts: 72
Joined: Sat Jul 26, 2003 1:12 pm

Post by seph_yaro » Thu Oct 09, 2003 8:36 am

Oh I love you love you love you!

Finally, can do some pottery! I haven't the hand power for tradeskilling manually (I cramp up badly after 30 or so combines :( )

Did not get the chance to try it on pottery, but posion making worked fine.

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

Post by kagonis » Thu Oct 09, 2003 9:29 am

I was so dreading to convert the TS.mac, cause I tend to forget half of what I have made when first its working.
Thanks a ton DKAA :)

And to topgun:
Yes, you can chose to only define 1 option, the rest will just be set to default.

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

Post by Malice » Thu Oct 09, 2003 11:24 pm

Couldnt Find a 'Celestial Solvent'

This is the result i get now after the patch.

Worked smoothly prior.
..

As a side note is there a good book on programming that you all use as a reference? Looking to contribute in the distant future.

bakkal
decaying skeleton
decaying skeleton
Posts: 4
Joined: Thu Sep 11, 2003 4:28 am

Post by bakkal » Fri Oct 10, 2003 3:34 am

I always used ts.mac, worked very well for me, after the 10/9 patch i get the error:

ts.mac@82 (Main): /varset v57 1

in the code line 82 is:
/varset showstats 0
(first of the /varset's)

it gets the same error both on and off

i tried sits.mac and it flat crashes to desktop.

any help?

-ty

MSMage
a lesser mummy
a lesser mummy
Posts: 37
Joined: Sun Aug 03, 2003 3:14 am

Post by MSMage » Sat Oct 11, 2003 1:47 am

For some reason it hangs after the first component is placed in the container for me.
Latest zip, fresh compile, VS6, Windows XP

EDIT: Tried using 2 different components instead of just 2 of the same, and it stopped after placing the first component.
MSMage

MSMage
a lesser mummy
a lesser mummy
Posts: 37
Joined: Sun Aug 03, 2003 3:14 am

Post by MSMage » Sun Oct 12, 2003 12:16 am

Nevermind me, i tried to run the macro under the default UI and it worked just fine there, so i guess its an issue with my UI and the names of locations or lack thereof. *shrug*
MSMage

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

Post by Amadeus » Sun Oct 12, 2003 3:02 am

Yes...is it possible to get some information on how one might use this with a custom UI?

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Sun Oct 12, 2003 3:58 am

IN THEORY, it should work with a custom UI so long as you have a combine button on your combiner.

Locations.txt tells mq which xml tag to use for the location of the slots and buttons. However, it has been my experience that the parsing logic or moving logic makes assumptions based on the default UI.

So, switch UIs for tradeskills...