Tradeskill macro using new TS UI

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

Moderator: MacroQuest Developers

BrainDeath
a ghoul
a ghoul
Posts: 86
Joined: Sun Mar 07, 2004 5:00 pm

Tradeskill macro using new TS UI

Post by BrainDeath » Thu Mar 11, 2004 2:28 pm

I'm posting this at the request of someone who sent me a PM. I haven't tested it since the 3-10-2004 patch. Also it uses both /press and /click left X Y, so who knows if it will work in the future as it looks like these functions may be removed. If someone knows how to enter text into the search box on the new tradeskill UI without using /press, and how to select a recipe from the list returned without using /click, please let me know.

This macro lets you tradeskill something like grobb liquidised meat start to finish without touching the keyboard as long as you've loaded up with the proper ingredients.

Usage examples:
/macro newts glm
Makes grobb liquidised meat. You must have a mixing bowl and all the ingredients in your inventory and be standing near a brew barrel.
/macro newts glm soda
Makes grobb liquidised meat starting from the soda water subrecipe.

I only wrote this macro because I was paranoid that an easy way to catch macroers would be to see who was doing high volumes of combines using the old interface. After using it though, I found that it was much faster than my old tradeskill macro.

Oh, and parts of the code are freely borrowed from the many fine macros out there. :)

*EDIT* Now fixed, tested and working with 3-11-04 release. EQ now has a really long delay (around 4 seconds) after you open the TS UI before you can click the Search button.

Macro

Code: Select all

| NewTS.mac by BrainDeath updated 03-12-2004
| Uses INI files to create a complete recipe including subcombines
| using the new tradeskill interface.
| The name of the major recipe as defined in the INI file is required
| as the first parameter.  A second optional parameter is a subrecipe
| of the major recipe.  This is helpful for example if you halted the
| macro for some reason and don't want it to retry all the subcombines
| but just continue with the one it was on when halted.
|
|~~~~~~~~~~~~ IMPORTANT NOTE ~~~~~~~~~~~~
| This macro uses /click and actual screen locations to navigate the
| new tradeskill interface.  See the Sub TSClick and modify the local
| variables accordingly.  It also requires that the recipe the macro
| enters into the search box appear first in the list of results.
| I coded this soon after MQ2 was fixed after the patch that included
| the new tradeskill UI and I haven't taken a look at any of the new 
| functions such as /notify that might make it more generic.  Also
| I had no idea how to have the macro type a recipe into the search
| box other than using /press (see Sub Type) so that's how i did it.


#turbo 

#event Full "There was no place to put that" 
#event Error "You cannot combine these items" 
#event Failure "You lacked the skills" 
#event Success "You have fashioned the items together to create something new" 
#event Alternate "You have fashioned the items together to create an alternate product" 
#event Trivial "You can no longer advance your skill from making this item" 
#event SkillUp "You have become better at" 
#event NoIngredients "Sorry, but you don't have everything you need for this recipe"

#chat tell 

Sub Main
| Declare variables
   /call DeclareGlobals
   /declare inifile local
   /declare MajorRecipe local
   /declare ContInUse local
   /declare RecipeCtr local

| Define macro INI filename. 
   /varset inifile "newts.ini"
   
| Check for parameter of Major Recipe.
   /if $defined(Param0)==FALSE /call EndMacro "You must specify a recipe." 
   /varset MajorRecipe "@Param0" 

| Check for recipe list in macro INI file. 
   /if "$ini(@inifile,@MajorRecipe)"~~NOTFOUND /call EndMacro "Recipe not defined in @inifile INI file." 

| Check that ContainerInUse is defined in macro INI file.
   /varset ContInUse "$ini(@inifile,Settings,ContainerInUse)"
   /if "@ContInUse"~~NOTFOUND /call EndMacro "ContainerInUse setting not defined in @inifile INI file." 

| Check to see if starting in middle of major recipe
   /if $defined(Param1)==TRUE {
      /call FindSubRecipe "@inifile" "@MajorRecipe" "@Param1"
      /varset RecipeCtr $return
   } else {
      /varset RecipeCtr 1
   }
   /if "@RecipeCtr"~~NOTFOUND /call EndMacro "Subrecipe specified not defined in @inifile INI file." 

| Make the recipes    
   /call DoRecipes "@inifile" "@MajorRecipe" "@ContInUse" "@RecipeCtr"
   /cleanup
   /beep
/return 


| Declare global variables.
Sub DeclareGlobals
   /declare EventType global
   /declare SkillTrivialCounter global
   /declare SkillFailCounter global 
   /declare SkillSuccessCounter global 
   /declare SuccessRate global 
   /declare TotalAttempts global 
   /declare SkillUpRate global 
   /declare SkillUpCounter global 
/return


| Check for the existence of a subrecipe for the major recipe in your INI file.
Sub FindSubRecipe(INIfile,MajorRecipe,SubRecipe)
   /declare SubINI local
   /declare SubCtr local
   /varset SubCtr 1
   :Loop 
      /varset SubINI "$ini(@INIfile,@MajorRecipe,Recipe$int(@SubCtr))"
      /if "@SubINI"~~"@SubRecipe" /return @SubCtr
      /if "@SubINI"~~NOTFOUND /return NOTFOUND
      /varadd SubCtr 1 
   /goto :Loop 
/return


| Grab the subrecipe from INI file and execute it.
Sub DoRecipes(INIfile,MajorRecipe,ContInUse,RecipeCtr)
   /declare SubRecipe local
   :Loop 
      /varset SubRecipe "$ini(@INIfile,@MajorRecipe,Recipe$int(@RecipeCtr))"
      /if "@SubRecipe"~~NOTFOUND /return
      /call ResetCounters
      /echo Executing recipe @SubRecipe... 
      /call TradeSkills "@INIfile" "@MajorRecipe" "@RecipeCtr" "ContInUse"
      /call DisplayStats
      /varadd RecipeCtr 1 
   /goto :Loop 
/return 


| Reset the counters for the statistics display.
Sub ResetCounters
   /varset SkillTrivialCounter 0 
   /varset SkillFailCounter 0 
   /varset SkillSuccessCounter 0 
   /varset SuccessRate 0 
   /varset TotalAttempts 0 
   /varset SkillUpRate 0 
   /varset SkillUpCounter 0 
/return


|  Checks the INI file for the subrecipe parameters, opens the appropriate
|  container and performs the combines.
Sub TradeSkills(INIfile,MajorRecipe,SubRecipeNum,ContInUse) 
   /declare ContType local
   /declare ContName local
   /declare PackNum local
   /declare SubRecipe local

   /varset ContType "$ini(@INIfile,@MajorRecipe,ContType$int(@SubRecipeNum))"
   /if "@ContType"~~NOTFOUND /Call EndMacro "Could not find Container Type for Recipe @MajorRecipe, subrecipe number @SubRecipeNum in file @INIfile." 

   /varset ContName "$ini(@INIfile,@MajorRecipe,ContName$int(@SubRecipeNum))"
   /if "@ContName"~~NOTFOUND /Call EndMacro "Could not find Container Name for Recipe @MajorRecipe, subrecipe number @SubRecipeNum in file @INIfile." 

| Find and open combiner
   /if "@ContType"=="enviro" {
      /call OpenEnviro "@ContName" "@ContInUse"
      /if $return!=OPEN /call EndMacro "Could not open environmental container @ContName. Return Code: $return"
      /varset PackNum e
   } else /if "@ContType"=="pack" {
      /call OpenPack "@ContName"
      /if $return!=OPEN /call EndMacro "Could not open pack @ContName. Return Code: $return"
      /varset PackNum $return
   } else {
      /call EndMacro "Invalid Container Type defined for Recipe @MajorRecipe, subrecipe number @SubRecipeNum in file @INIfile." 
   }
   
| Main Combine Routine
   /call ClearCursor
   /varset SubRecipe "$ini(@INIfile,@MajorRecipe,Recipe$int(@SubRecipeNum))"
   /if "@SubRecipe"~~NOTFOUND /Call EndMacro "Could not find Recipe @MajorRecipe, subrecipe number @SubRecipeNum in file @INIfile." 
   /call ChooseRecipe "@SubRecipe"
   :Begin
      /call DoCombine
      /if @EventType!=Event_NoIngredients /goto :Begin
   /call ClearCursor
   /call TSClick CloseButton
/return 


| Type input string "Recipe" into search box in new tradeskill interface,
| click search and select the first recipe returned in the search results.
Sub ChooseRecipe(Recipe)
   /call TSClick SearchBox
   /delay 5
   /call Type "@Recipe"
   /delay 40
   /call TSClick SearchButton
   /delay 10
   /call TSClick RecipeSelect
   /delay 10
/return


| Click combine until you get an event.
Sub DoCombine
   /varset EventType NULL
   :Loop
      /call TSClick CombineButton
      /doevents
      /if @EventType==NULL /goto :Loop
/return


| Open an enviromental container given name (item).  Action tells whether or
| not to wait for the container to become available.
Sub OpenEnviro(item,action) 
   /declare count1 local
   /varset count1 0 
   :Loop 
      /if "$envopen"~~"@item" /return OPEN
      /itemtarget @item
      /if "$target(name)"=="NULL" /return NOTFOUND
      /if n $distance(item)>20 /return NOTINREACH
      /face fast nolook 
      /click left item 
   :Check 
      /varadd count1 1 
      /delay 10 
      /if "$envopen"~~"@item" /return OPEN
      /if n @count1==5 { 
         /if @action==WAIT /varset count1 0 
         /goto :Loop 
         } 
      /if n @count1==10 /goto :Loop 
      /if n @count1>=15 { 
         /return INUSE 
         } 
      /goto :Check 
/return OPEN


| Opens a pack given its name. 
Sub OpenPack(PackName)
   /declare PackNum local
   
   /call ContFind "@PackName"
   /if $return~~NOTFOUND /return NOTFOUND
   /varset PackNum $return
   
   /if $pack(@PackNum,open)==FALSE { 
      /if $invpanel==FALSE /windowstate inventory open 
      /click right inv @PackNum 
      /delay 5
   } 
   /if $pack(@PackNum,open)==FALSE /return NOTOPEN
/return OPEN


| Determine the pack number of a container
| Input: name of container, if name starts with # will use "contains" for comparison
|        to find the container
| Output: pack number of container or NOTFOUND if container is not in inventory
Sub ContFind(InName)
   /declare ContName local 
   /declare NameFlag local 
   /declare loopctr local 
   /declare PackNum local

   /varset PackNum NOTFOUND
   /if "@InName"~~"#" { 
      /varset ContName "$right($calc($strlen("@InName")-1),"@InName")" 
      /varset NameFlag 0 
   } else { 
      /varset ContName "@InName" 
      /varset NameFlag 1 
   } 
   /for loopctr 0 to 7 
      /if n @NameFlag==0 /if "$pack(@loopctr,name)"~~"@ContName" /varset PackNum @loopctr 
      /if n @NameFlag==1 /if "$pack(@loopctr,name)"=="@ContName" /varset PackNum @loopctr 
   /next loopctr 
/return @PackNum


| Provides the ability to click the buttons, search box and search results
| on the new tradeskill interface.  Uses the actual X,Y coordinates of the
| tradeskill UI.  Must be modified depending on screen resolution and the
| screen location of your tradeskill UI.
Sub TSClick(Button)
   /declare SearchBox_X local
   /declare SearchBox_Y local
   /declare SearchButton_X local
   /declare SearchButton_Y local
   /declare RecipeSelect_X local
   /declare RecipeSelect_Y local
   /declare CombineButton_X local
   /declare CombineButton_Y local
   /declare AutoInvButton_X local
   /declare AutoInvButton_Y local
   /declare ExperimentButton_X local
   /declare ExperimentButton_Y local
   /declare CloseButton_X local
   /declare CloseButton_Y local

   /varset SearchBox_X 240
   /varset SearchBox_Y 160
   /varset SearchButton_X 210
   /varset SearchButton_Y 185
   /varset RecipeSelect_X 170
   /varset RecipeSelect_Y 265
   /varset CombineButton_X 420
   /varset CombineButton_Y 445
   /varset AutoInvButton_X 420
   /varset AutoInvButton_Y 470
   /varset ExperimentButton_X 415
   /varset ExperimentButton_Y 200
   /varset CloseButton_X 410
   /varset CloseButton_Y 580

   /if @Button==SearchBox {
      /click left @SearchBox_X @SearchBox_Y
   } else /if @Button==SearchButton {
      /click left @SearchButton_X @SearchButton_Y
   } else /if @Button==RecipeSelect {
      /click left @RecipeSelect_X @RecipeSelect_Y
   } else /if @Button==CombineButton {
      /click left @CombineButton_X @CombineButton_Y
   } else /if @Button==AutoInvButton {
      /click left @AutoInvButton_X @AutoInvButton_Y
   } else /if @Button==ExperimentButton {
      /click left @ExperimentButton_X @ExperimentButton_Y
   } else /if @Button==CloseButton {
      /click left @CloseButton_X @CloseButton_Y
   } else {
      /return ERROR
   }
/return SUCCESS


| Type out the input string.  Only non-alphabetic character
| currently handled is space.
Sub Type(InStr)
   /declare char local
   /declare loopctr local
   /for loopctr 0 to $int($calc($strlen("@InStr")-1))
      /varset char $mid(@loopctr,1,"@InStr")
      /if "@char"=="" {
         /press space
      } else {
         /press @char
      }
   /next loopctr
/return


| Wait for cursor to contain something.
Sub WaitForPickup 
   :waiting 
   /if $cursor()!=TRUE /goto :waiting 
/return 


|Wait for cursor to become empty.
Sub WaitForDrop 
   :waiting 
   /if $cursor()==TRUE /goto :waiting 
/return 


| Pause while self is targeted.
Sub Pause 
   /if "$target(name,clean)"!="$char(name)" /return 
   /echo Pausing!! To resume, type /target clear or target something else. 
   :HoldingPattern 
      /delay 20 
      /if "$target(name,clean)"=="$char(name)" /goto :HoldingPattern 
/return 


| Send everything on cursor to inventory.
sub ClearCursor 
:Loop 
   /if $cursor()!=NULL { 
      /autoinv
      /delay 5
   } 
   /if $cursor()!=NULL /goto :Loop 
/return 


| Error reporting. 
Sub EndMacro(error) 
   /echo @error 
   /echo An error has occured.. ending macro. 
   /beep
   /endmacro 
/return 


| Display combine statistics.
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 Success 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 


| Event handling.
Sub Event_Chat 
   /varset EventType Event_Chat
   /call ClearCursor
   /press F1 
   /call Pause
/return 

Sub Event_Full 
   /varset EventType Event_Full
   /delay 5
   /call ClearCursor
   /cleanup
   /call EndMacro "Your inventory is full." 
/return 

Sub Event_Error 
   /varset EventType Event_Error
   /delay 5
   /call ClearCursor
/return 

Sub Event_Success 
   /varset EventType Event_Success
   /varadd SkillSuccessCounter 1 
   /call WaitForPickup
   /call ClearCursor
/return 

Sub Event_Failure 
   /varset EventType Event_Failure
   /varadd SkillFailCounter 1 
/return 

Sub Event_Alternate
   /varset EventType Event_Alternate
   /call WaitForPickup
   /call ClearCursor
/return 

Sub Event_NoIngredients
   /varset EventType Event_NoIngredients
/return

Sub Event_Trivial
   /varadd SkillTrivialCounter 1 
/return

Sub Event_Skillup
   /varadd SkillUpCounter 1 
   /echo $int(@SkillUpCounter) skill ups in $int($calc(@SkillFailCounter+@SkillSuccessCounter+1)) attempts! 
/return
INI File

Code: Select all

; NewTS INI (newts.ini)

[Settings] 
; Wait for enviro container to become available?
;ContainerInUse=WAIT 
ContainerInUse=ABORT

| List of recipes to execute. 
| Recipe entry should be such that the recipe you want will be first in the returned list.
| If container name starts with # exact name is not required.
| Valid container types are "enviro" for environmental containers
| or "pack" for containers held in inventory.

[glm] 
;Grobb Liquidised Meat
Recipe1=liquidised gator
ContType1=pack
ContName1=#Mixing Bowl
Recipe2=liquidised snake
ContType2=pack
ContName2=#Mixing Bowl
Recipe3=liquidised rat
ContType3=pack
ContName3=#Mixing Bowl
Recipe4=soda water
ContType4=enviro
ContName4=Brew Barrel
Recipe5=grobb liquidised meat
ContType5=enviro
ContName5=Brew Barrel


[kc]
;Kaladim Constitutional
; CE currently commented out because it doesn't use
; the new tradeskill interface.
;Recipe1=celestial essence
;ContType1=pack
;ContName1=#Mortar
Recipe1=fermented yarrow
ContType1=enviro
ContName1=Brew Barrel
Recipe2=soda water
ContType2=enviro
ContName2=Brew Barrel
Recipe3=kaladim constitutional
ContType3=enviro
ContName3=Brew Barrel


;Misty Thicket Picnic subs start =======================
[sb]
;Steel Boning
Recipe1=Steel Boning
ContType1=enviro
ContName1=Forge

[pb]
:Picnic Basket
Recipe1=woven mandrake
ContType1=pack
ContName1=#Sewing Kit
Recipe2=picnic basket
ContType2=pack
ContName2=#Sewing Kit

[jsb]
;Jumjum Spiced Beer
Recipe1=jumjum spiced beer
ContType1=enviro
ContName1=Brew Barrel

[mtp]
;Misty Thicket Picnic
Recipe1=jumjum salad
ContType1=pack
ContName1=#Mixing Bowl
Recipe2=royal mints
ContType2=pack
ContName2=#Mixing Bowl
Recipe3=mature cheese
ContType3=pack
ContName3=#Mixing Bowl
Recipe4=winter chocolate
ContType4=pack
ContName4=#Mixing Bowl
Recipe5=apricot marmalade
ContType5=enviro
ContName5=oven
Recipe6=marmalade sandwich
ContType6=pack
ContName6=#Mixing Bowl
Recipe7=jumjum cake
ContType7=enviro
ContName7=oven
Recipe8=slice of jumjum cake
ContType8=enviro
ContName8=oven
Recipe9=misty thicket picnic
ContType9=enviro
ContName9=oven
;Misty Thicket Picnic subs end ===================