Smithing Freebie Macro

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

ScubaSki
a lesser mummy
a lesser mummy
Posts: 55
Joined: Mon Jun 21, 2004 8:27 pm

Smithing Freebie Macro

Post by ScubaSki » Wed Sep 08, 2004 5:22 pm

I need some help on this Smithing Freebie Macro. Basically all this does is the simple combines for the Smithing freebie quests in Abysmal Sea. Alot of the code has been shamelessly stolen. =)

I'm stuck on the Add Components Subroutine, and the Combine. Everything else works(for me)

I am pretty new at this and this is my first real "macro"

I used the move.inc from http://www.macroquest2.com/phpBB2/viewtopic.php?t=7207

If anyone can look at this and give me some pointers on how to smooth out my errors I would appreciate it.

Code: Select all

| Smithing Freebie
| Freesmith.mac
| Works on Abysmal Free Smithing Quest
| Version 1.0
| Date: 09-07-04
| By:  ScubaSki
|
| You WILL need to in front of Snokin Breaksteel in Abysmal Sea for it to work
|
| Disclaimer:
| Code was used from other programers also from the MQ Forums.
|
|  Snokin loc = 96.50,260.36,113.94
|  Forge Loc = 175.08,253.02,113.94
|  Next to Forge = 165.53,257.12,113.94

#include move.inc

#event CombineError "#*#There was no place to put that#*#" 
#event CombineError "#*#You cannot combine these items in this container type!#*#" 
#event CombineError "#*#did not accept these items#*#" 
#event ContUsed "#*#Someone else is using that. Try again later.#*#"

Sub Main

  /declare Comp[3] string outer 
  /declare ItemTurnIn String outer

:Start

  /call GMCheck
  /call GetItems
  |  Move to Forge
  /call MovetoLoc 165.53,257.12,113.94
  /echo At Forge
  /call Docombine
  |Move to Snokin
  /call MovetoLoc 96.50,260.36,113.94
  /echo At Snokin
  /call GiveItems

/return

Sub GetItems

  /declare i int outer

:Loop
  /target Snokin
  /face nolook Snokin
  /nomodkey /say Silly Work
  /delay 1s 
  /if (!${Window[InventoryWindow].Open}) /nomodkey /keypress inventory
  /delay 2
  |  Inventory Components
  /for i 1 to 3 
  /varset Comp[${i}] ${Cursor.Name} 
  /echo Item ${i} is ${Comp[${i}]}
  /autoinv
  /delay 2s
  /next i

/return


Sub GiveItems
  /target Snokin
  /face nolook
  /delay 1s
  /cleanup 
|       Open Bag 
  /itemnotify ${Math.Calc[${FindItem[=${ItemTurnIn}].InvSlot.Pack}-21]} rightmouseup 
:ItemLoop
|       Click Item 
  /itemnotify ${FindItem[=${ItemTurnIn].InvSlot} leftmouseup 
|       Close Bag 
  /itemnotify ${Math.Calc[${FindItem[=${ItemTurnIn}].InvSlot.Pack}-21]} rightmouseup 
|       Open GiveWnd, and automatically place item in first give slot. 
  /click left target 
| Checks that the window has been opened. (GiveWnd). This accounts for lag. 
  :givewindowcheck 
  /if (${Window}==FALSE) { 
    /goto :givewindowcheck 
    } 
  /nomodkey /notify GiveWnd GVW_Give_Button leftmouseup 
|	Delay for safety
  /delay 1s 
|Check for more items
  /if (!${FindItem[=${ItemTurnIn}].ID}) {
     /goto ItemLoop
     }  
  /call ClosePacks
/return


Sub GMCheck 
:gmcheck 
   /if (${Spawn[gm].ID}>0) { 
      /echo "Waiting on GM to leave zone." 
      /delay 10 
      /goto :gmcheck 
   } 
/return 

Sub Event_CombineError 
  /beep
/return 

Sub Event_ContUsed
    /echo Container in use. Waiting 30 seconds and trying again.
    /delay 30s
    /itemtarget "Forge"
    /delay 1s
    /nomodkey /click left item
    /delay 2s
    /doevents
/return 

|--------------------------------------------------- 
| SUB: Do the Comines 
|--------------------------------------------------- 
Sub DoCombine

   /declare iSlot int local 
   /declare Counter int local 

   /doevents 

   |------------------------------------------------ 
   | Open Forge. 
   |------------------------------------------------ 
   /itemtarget Forge 
   /face item 
   /click left item 
   /delay 2s 
   /notify TradeSkillWnd ExperimentButton leftmouseup 
   |------------------------------------------------ 
   | Clear Out Brew Barrel. 
   |------------------------------------------------ 
   /echo Cleaning Out Forge... 
   /for iSlot 1 to 10 
      /shiftkey /itemnotify enviro${iSlot} leftmouseup 
      /if (${Cursor.ID}) { 
         /destroy 
      } 
   /next iSlot 

   |------------------------------------------------ 
   | Open Inventory Window. 
   |------------------------------------------------ 
   /if (${Window[Inventory].Open}==FALSE) { 
      /windowstate inventory open 
   } 

   |------------------------------------------------ 
   | Open All 8 Packs. 
   |------------------------------------------------ 
   /for iSlot 1 to 8 
      /if (${Window[Pack${iSlot}].Open}==FALSE) { 
         /itemnotify pack${iSlot} rightmouseup 
      } 
   /next iSlot 

   |------------------------------------------------ 
   | Make Recipe. 
   |------------------------------------------------ 
   /echo Making Recipe... 

   :MakeRecipe 

   /doevents 
   /call GMCheck 
   /for Counter 1 to 3
   /if (${FindItem[${Comp[${Counter}]}].InvSlot}==NULL) /goto :Done 
   /ctrl /itemnotify ${FindItem[=${Comp[${Counter}]}].InvSlot} leftmouseup 
   /delay 2
   /echo ${Comp[${Counter}]}
   /itemnotify enviro${Counter} leftmouseup 
   /delay 2
   /next Counter
   /delay 2 
   /combine enviro 

   |------------------------------------------------ 
   | Waiting for Combine to Finish. 
   |------------------------------------------------ 
   :WaitCombine 
   /if (!${Cursor.ID}) { 
      /goto :WaitCombine 
   } 
   /combine enviro 

   |------------------------------------------------ 
   | Clearing the Cursor. 
   |------------------------------------------------ 
   :ClearCursor 
   /autoinventory 
   } 
   /delay 2 

   /if (!${Cursor.ID}) { 
      /goto :MakeRecipe 
   } else { 
      /goto :ClearCursor 
   } 

   |------------------------------------------------ 
   | Done with Making Recipe. 
   |------------------------------------------------ 
   :Done 
   /cleanup

/return 


Last edited by ScubaSki on Thu Sep 09, 2004 5:27 pm, edited 1 time in total.

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Post by JP5 » Thu Sep 09, 2004 2:53 pm

Code: Select all

  /for h 1 to 20 
      /for i 1 to 3 
        /call AddComp "${Comp[${i}]}" ${i} 
        /echo Added Item ${i} ${Comp[${i}]} ${i} 
        /delay 2s 
      /next i 
    /call DoCombine 
    /delay 5 
  /next h 

Code: Select all

sub AddComp(CompName, PackSlot) 

   :Loop 
      /nomodkey /ctrl /itemnotify ${FindItem[=${CompName}].InvSlot} leftmouseup 

      /if (!${Cursor.ID}) { 
         /delay 1 
         /goto :Loop 
      } 

   /if (${PackCode.Equal[Enviro]}) { 
      /nomodkey /itemnotify ${InvSlot[enviro${PackSlot}]} leftmouseup 
   } else { 
      /nomodkey /itemnotify in ${PackCode} ${PackSlot} leftmouseup 
   }    
   /return 
Couple questions, still trying to get ahold of your code.
Why do you have a /for h 1 to 20?
What does the 1-20 do?
What i can guess is that it does 20 combines, because you probably receive 20 items from the guy. Ok figured that out.

Code: Select all

      /nomodkey /ctrl /itemnotify ${FindItem[=${CompName}].InvSlot} leftmouseup 
You will have problems with this, unless you open all the packs at the start.
Check out my handin.mac in the macro help section to see how to open a pack that contains the certain item you need.

Code: Select all

      /if (!${Cursor.ID}) { 
         /delay 1 
         /goto :Loop 
What does this do?

Code: Select all

   /if (${PackCode.Equal[Enviro]}) { 
This code makes me nervous. I know it's from Override's macros, and I've never liked how he checks for which type of tradeskill container you have.

If I were you, I'd be using the new tradeskill interface to be doing the combines (if you aren't already.. but I think you're using the old type, because you shouldn't have to give a shit whether the container is Enviro or not).

Could you post any errors you receive if there are any?

I'll try to help you out more. I have 30 minutes lunch every day, where I do nothing except screw around, so..

good luck, post reply

ScubaSki
a lesser mummy
a lesser mummy
Posts: 55
Joined: Mon Jun 21, 2004 8:27 pm

Post by ScubaSki » Thu Sep 09, 2004 5:16 pm

Ok, I am incredibly new at this. The last time I took a programing class was in college and to warn you... The coding still involved line numbers.

I looked at your handin macro and I took some of the code from there for my Give Routine. Thanks. I can't test this as I can't get the macro to get this far. I think it will work though.

Code: Select all

Sub GiveItems
  /target Snokin
  /face
  /delay 1s
  /cleanup 
|       Open Bag 
  /itemnotify ${Math.Calc[${FindItem[=${ItemTurnIn}].InvSlot.Pack}-21]} rightmouseup 
:ItemLoop
|       Click Item 
  /itemnotify ${FindItem[=${ItemTurnIn].InvSlot} leftmouseup 
|       Close Bag 
  /itemnotify ${Math.Calc[${FindItem[=${ItemTurnIn}].InvSlot.Pack}-21]} rightmouseup 
|       Open GiveWnd, and automatically place item in first give slot. 
  /click left target 
| Checks that the window has been opened. (GiveWnd). This accounts for lag. 
  :givewindowcheck 
  /if (${Window}==FALSE) { 
    /goto :givewindowcheck 
    } 
  /nomodkey /notify GiveWnd GVW_Give_Button leftmouseup 

|Check for more items
  /if (!${FindItem[=${ItemTurnIn}].ID}) {
     /goto ItemLoop
     }  
  /call ClosePacks
/return

I also went in and found another tradeskill macro and used some code from there to redesign the handin/combine portion.

Code: Select all

|--------------------------------------------------- 
| SUB: Do the Comines 
|--------------------------------------------------- 
Sub DoCombine

   /declare iSlot int local 
   /declare Counter int local 

   /doevents 

   |------------------------------------------------ 
   | Open Forge. 
   |------------------------------------------------ 
   /itemtarget Forge 
   /face item 
   /click left item 
   /delay 2s 
   /notify TradeSkillWnd ExperimentButton leftmouseup 
   |------------------------------------------------ 
   | Clear Out Forge. 
   |------------------------------------------------ 
   /echo Cleaning Out Forge... 
   /for iSlot 1 to 10 
      /shiftkey /itemnotify enviro${iSlot} leftmouseup 
      /if (${Cursor.ID}) { 
         /destroy 
      } 
   /next iSlot 

   |------------------------------------------------ 
   | Open Inventory Window. 
   |------------------------------------------------ 
   /if (${Window[Inventory].Open}==FALSE) { 
      /windowstate inventory open 
   } 

   |------------------------------------------------ 
   | Open All 8 Packs. 
   |------------------------------------------------ 
   /for iSlot 1 to 8 
      /if (${Window[Pack${iSlot}].Open}==FALSE) { 
         /itemnotify pack${iSlot} rightmouseup 
      } 
   /next iSlot 

   |------------------------------------------------ 
   | Make Recipe. 
   |------------------------------------------------ 
   /echo Making Recipe... 

   :MakeRecipe 

   /doevents 
   /call GMCheck 
   /for Counter 1 to 3
   /if (${FindItem[${Comp[${Counter}]}].InvSlot}==NULL) /goto :Done 
   /ctrl /itemnotify ${FindItem[=${Comp[${Counter}]}].InvSlot} leftmouseup 
   /delay 2
   /echo ${Comp[${Counter}]}
   /itemnotify enviro${Counter} leftmouseup 
   /delay 2
   /next Counter
   /delay 2 
   /combine enviro 

   |------------------------------------------------ 
   | Waiting for Combine to Finish. 
   |------------------------------------------------ 
   :WaitCombine 
   /if (!${Cursor.ID}) { 
      /goto :WaitCombine 
   } 
   /combine enviro 

   |------------------------------------------------ 
   | Clearing the Cursor. 
   |------------------------------------------------ 
   :ClearCursor 
   /autoinventory 
   } 
   /delay 2 

   /if (!${Cursor.ID}) { 
      /goto :MakeRecipe 
   } else { 
      /goto :ClearCursor 
   } 

   |------------------------------------------------ 
   | Done with Making Recipe. 
   |------------------------------------------------ 
   :Done 
   /cleanup

/return 
I'm having some problems with it still. Bugs I need to work out.

It now: Correctly gets the items from the NPC, It will move to the Forge and Combine the recipes, It continues to Combine the recipes until it gets a failure and then it just stops. Sometimes it looks like it's running too fast(lag) and it just stops as well.

I'm going to do some fine tuning on it over the weekend and see if I can't get a good version out myself. Thanks for your suggestions they really helped point me in the right direction.

dman
a hill giant
a hill giant
Posts: 181
Joined: Fri Dec 05, 2003 12:54 pm

Post by dman » Thu Sep 09, 2004 6:48 pm

Code: Select all

   /combine enviro 

   |------------------------------------------------ 
   | Waiting for Combine to Finish. 
   |------------------------------------------------ 
   :WaitCombine 
   /if (!${Cursor.ID}) { 
      /goto :WaitCombine 
   } 
   /combine enviro 
It now: Correctly gets the items from the NPC, It will move to the Forge and Combine the recipes, It continues to Combine the recipes until it gets a failure and then it just stops. Sometimes it looks like it's running too fast(lag) and it just stops as well.
Your code is hanging up here. The reason for it is that if you fail the combine you will never have anything in your cursor for most of these combines and so your macro will be stuck in an endless loop waiting. The same goes for a messed up combine due to lag, with the wrong components you won't get a result and as such you will stick into an endless loop here again. I would suggest using a few events here to handle the different cases as reading events is the easiest way to figure out if you succeeded/failed/botched the combine.

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Post by JP5 » Thu Sep 09, 2004 8:25 pm

I see you're still using the drag + drop + combine method. I think this might be better, because people using the macro won't necessarily have the recipe "learned".

I also noticed the !${Cursor.ID} .. good catch dman.

Code: Select all

|Check for more items
  /if (!${FindItem[=${ItemTurnIn}].ID}) {
     /goto ItemLoop
     }  
/goto :ItemLoop