• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

BuyAA.mac (1 Viewer)

EvenLessSpam

Active member
Joined
Oct 31, 2005
RedCents
91¢
Name:
BuyAA.inc
by EvenLessSpam


Credits:
nijhal
JoeK
jimjohnson
digitalpixel


Description:
The purpose of this include is to easily add AA buying capabilities to XP macros.

It can be used in two ways; either to just buy a single AA from a specific AA tab using the BuyAA subroutine, or to buy from an INI based list using the BuyAAFromINI subroutine.


Syntax/Example:
Syntax: /call BuyAA "AA Tab" "Alternate Ability"
Example: /call BuyAA "PoP Advance" "Planar Power"

In the example Planar Power will be bought, from the PoP Advance tab.

Both the "AA Tab" and the "Alternate Ability" parameters are required. The "AA Tab" is the tab in the AA Window which the wanted Alternate Ability is found on. See the currently available tabs below. The "Alternate Ability" is the name of the Alternate Ability that should be bought from the selected AA tab.


Syntax: /call BuyAAFromINI "INI File" "INI Section"
Example: /call BuyAAFromINI
Example: /call BuyAAFromINI "MyAA.ini"
Example: /call BuyAAFromINI "RogueAA.ini" "DPS"

In example 1 it will just use default values, that is buy the AA's defined in the section "server_Character", from the file "BuyAA.ini".
In example 2 it will buy the AA's defined in the section "server_Character" from the file "MyAA.ini".
In example 3 it will buy the AA's defined in the section "DPS" from the file "RogueAA.ini".

Both the "INI File" and the "INI Section" parameters are optional, although the "INI File" is required if the "INI Section" should be set. If "INI File" isn't specified it will default to "BuyAA.ini", and if the "INI Section" isn't specified it will default to "server_Character", where ofcourse server is the server of the character you wish to buy for, and (duh) Character is the character you wish to buy for.


Changes:
2006-08-05
  • Changed the /keypress to open AA Window from "V" to "TOGGLE_ALTADVWIN".
    Should make it more compatible between clients with different key setups.
  • Removed the /keypress that closed the AA window after each purchase.
    If buying 20 AAs the Window would open and close 20 times. No need for that ;)

2006-08-06
  • Modified the BuyAA.inc to return TRUE if it successfully bought an AA and FALSE if not.
    Thanks JoeK for the idea :)
  • Updated the Example macro with JoeK's ideas.
  • Made a dirty hack using MQ2MMouseTo to open tabs.
  • Added version comment.

2006-08-10
  • Updated the Example macro and INI.
    Macro no longer tries to check whether or not the AA actually can be bought (enough points, rank etc.)
    Macro now uses the actual AA name as the key, so no more naming them "AA1", "AA2" etc.
    INI updated with comments and to work with the new syntax.

2007-01-09
  • Removed (commented out) the events but left in the buying loop. The check is done by comparing the amount of saved AA before the buy, and then doing a loop that checks if the amount goes down (10 second timeout). If it goes down it's assumed that the purchace was successful.
  • Removed the SetupSomeVars sub. Using the existing Timeout variable and the AA amount check to see if it's bought. Still using Timeout loop by JoeK.
  • Removed the use of MQ2MMouseTo in favor of the newly built-in tabselect function by "yetanotheruser" on MacroQuest2 forums. Pointed out to me by jimjohnson and digitalpixel on MMOBugs.
  • Updated for The Serpents Spine.

2007-01-10
  • Added the sub BuyAAFromINI, which is basically what was previously the example macro.


Known issues:
None


BuyAA.inc
Rich (BB code):
|**
 * BuyAA.inc - Automated AA buying.
 *  by EvenLessSpam (see Credits)
 *
 * Version: 1.1.0
 *
 *
 * Description:
 * -----------------------------------------------------------------------------
 *  The purpose of this include is to easily add AA buying capabilities to XP
 *  macros.
 *
 *  It can be used in two ways; either to just buy a single AA from a specific
 *  AA tab using the BuyAA subroutine, or to buy from an INI based list using
 *  the BuyAAFromINI subroutine.
 *
 *
 *  Syntax/Example:
 *  -----------------------
 *  Syntax: /call BuyAA "AA Tab" "Alternate Ability"
 *  Example: /call BuyAA "PoP Advance" "Planar Power"
 *
 *  In the example Planar Power will be bought, from the PoP Advance tab.
 *
 *  Both the "AA Tab" and the "Alternate Ability" parameters are required. The
 *  "AA Tab" is the tab in the AA Window which the wanted Alternate Ability is
 *  found on. See the currently available tabs below. The "Alternate Ability" is
 *  the name of the Alternate Ability that should be bought from the selected
 *  AA tab.
 *
 *
 *  Syntax: /call BuyAAFromINI "INI File" "INI Section"
 *  Example: /call BuyAAFromINI
 *  Example: /call BuyAAFromINI "MyAA.ini"
 *  Example: /call BuyAAFromINI "RogueAA.ini" "DPS"
 *
 *  In example 1 it will just use default values, that is buy the AA's defined
 *  in the section "server_Character", from the file "BuyAA.ini".
 *  In example 2 it will buy the AA's defined in the section "server_Character"
 *  from the file "MyAA.ini".
 *  In example 3 it will buy the AA's defined in the section "DPS" from the file
 *  "RogueAA.ini".
 *
 *  Both the "INI File" and the "INI Section" parameters are optional, although
 *  the "INI File" is required if the "INI Section" should be set.
 *  If "INI File" isn't specified it will default to "BuyAA.ini", and if the
 *  "INI Section" isn't specified it will default to "server_Character", where
 *  ofcourse server is the server of the character you wish to buy for, and
 *  (duh) Character is the character you wish to buy for.
 *
 *
 *  Available AA Tabs are:
 *  -----------------------
 *      General
 *      Archetype
 *      Class
 *      PoP Advance
 *      PoP Ability
 *      Gates
 *      Omens
 *      Veteran
 *      Monster Innates
 *      Monster Abilities
 *      Darkhollow
 *      Serpent
 *
 *
 * Credits:
 * -----------------------------------------------------------------------------
 *  JoeK
 *  - Lot of tweaks, additions and suggestions.
 *
 *  nijhal
 *  - For pointing out that listselect required a leftmouse and leftmouseup
 *      after the listselect to actually select the AA for purchase.
 *
 *  jimjohnson
 *  - For pointing out that tabselect is now part of the MQ2 base.
 *
 *  digitalpixel
 *  - For pointing out the tabselect command.
 *
 *
 * Changes:
 * -----------------------------------------------------------------------------
 *  1.0.0
 *  - Initial release.
 *
 *  1.0.1
 *  - Changed /keypress from "V" to "TOGGLE_ALTADVWIN"
 *  - Removed /keypress that would normally close AAWindow
 *
 *  1.0.2
 *  - BuyAA will now return TRUE on success, FALSE on failure (thanks JoeK)
 *  - Added the "leftmouse" notification before the "leftmouseup" when selecting
 *      the AA in the AA list. (thanks JoeK)
 *
 *  1.0.3
 *  - Now uses MQ2MMouseTo to handle the AA Tabs. Don't place other windows on
 *      top of the AAWindow.
 *
 *  1.0.3J - by JoeK
 *  - added Events to detect successful purchases and a SetupSomeVars sub to be
 *      called by the macro that uses this include file.
 *
 *  1.0.4
 *  - Removed (commented out) the events but left in the buying loop. The check
 *      is done by comparing the amount of saved AA before the buy, and then
 *      doing a loop that checks if the amount goes down (10 second timeout). If
 *      it goes down it's assumed that the purchace was successful.
 *  - Removed the SetupSomeVars sub. Using the existing Timeout variable and the
 *      AA amount check to see if it's bought. Still using Timeout loop by JoeK.
 *  - Removed the use of MQ2MMouseTo in favor of the newly built-in tabselect
 *      function by "yetanotheruser" on MacroQuest2 forums. Pointed out to me by
 *      jimjohnson and digitalpixel on MMOBugs.
 *  - Updated for The Serpents Spine.
 *
 *  1.1.0
 *  - Added the sub BuyAAFromINI, which is basically what was previously the
 *      example macro.
**|

|#Event AAGained    "You have gained the ability #1# at a cost of #2# ability points."
|#Event AAImproved  "You have improved #1# at a cost of #2# ability points."

Sub BuyAAFromINI(string INIFile, string Section)
    /if (!${Defined[INIFile]}) {
        /declare INIFile    string  local   BuyAA.ini
    }
    /if (!${Defined[Section]}) {
        /declare Section    string  local   ${MacroQuest.Server}_${Me.Name}
    }
    /declare Keys           string  local
    /declare i              int     local
    /declare AA             string  local
    /declare Tab            string  local
    /if (${Ini[${INIFile}, ${Section}].Equal[NULL]}) /return
    /varset Keys ${Ini[${INIFile}, ${Section}]}
    :TrimKeys
        /if (${Keys.Right[1].Equal[|]}) /varset Keys ${Keys.Left[${Math.Calc[${Keys.Length}-1]}]}
    /if (${Keys.Right[1].Equal[|]}) /goto :TrimKeys
    /for i 1 to ${Math.Calc[${Keys.Count[|]}+1]}
        /varset AA ${Keys.Arg[${i},|]}
        /varset Tab ${Ini[${INIFile},${Section},${AA}]}
        :Buy
        /if (${AltAbility[${AA}].AARankRequired} < ${AltAbility[${AA}].MaxRank} && ${AltAbility[${AA}].Cost} <= ${Me.AAPoints}) {
            /echo [${Time.Time24}] BuyAA:: Attempting to buy "${AA}" from ${Tab}...
            /call BuyAA "${Tab}" "${AA}"
            /if (${Macro.Return}) /goto :Buy
            /echo [${Time.Time24}] BuyAA:: Failed to buy "${AA}" from ${Tab}...
        }
    /next i
/return

Sub BuyAA(string Tab, string AA)
    /if (!${Defined[Tab]} || !${Defined[AA]}) /return FALSE
    /declare i              int     local
    /declare AAPts          int     local   ${Me.AAPoints}
    /declare Timeout        timer   local   10s
    /declare TabIndex       int     local


    |--------------------------------------------------------------------------|
    |------------------------ Create the AA Tabs array ------------------------|
    |--------------------------------------------------------------------------|
    /declare Tabs[12,4] string  local
    /varset Tabs[1,1] General
    /varset Tabs[1,2] AAW_GeneralPage
    /varset Tabs[1,3] AAW_GeneralList

    /varset Tabs[2,1] Archetype
    /varset Tabs[2,2] AAW_ArchetypePage
    /varset Tabs[2,3] AAW_ArchList

    /varset Tabs[3,1] Class
    /varset Tabs[3,2] AAW_ClassPage
    /varset Tabs[3,3] AAW_ClassList

    /varset Tabs[4,1] PoP Advance
    /varset Tabs[4,2] AAW_Page4
    /varset Tabs[4,3] AAW_List4

    /varset Tabs[5,1] PoP Ability
    /varset Tabs[5,2] AAW_Page5
    /varset Tabs[5,3] AAW_List5

    /varset Tabs[6,1] Gates
    /varset Tabs[6,2] AAW_Page6
    /varset Tabs[6,3] AAW_List6

    /varset Tabs[7,1] Omens
    /varset Tabs[7,2] AAW_Page7
    /varset Tabs[7,3] AAW_List7

    /varset Tabs[8,1] Veteran
    /varset Tabs[8,2] AAW_Page8
    /varset Tabs[8,3] AAW_List8

    /varset Tabs[9,1] Monster Innates
    /varset Tabs[9,2] AAW_Page9
    /varset Tabs[9,3] AAW_List9

    /varset Tabs[10,1] Monster Abilities
    /varset Tabs[10,2] AAW_Page10
    /varset Tabs[10,3] AAW_List10

    /varset Tabs[11,1] Darkhollow
    /varset Tabs[11,2] AAW_Page11
    /varset Tabs[11,3] AAW_List11

    /varset Tabs[12,1] Serpent
    /varset Tabs[12,2] AAW_Page12
    /varset Tabs[12,3] AAW_List12


    |--------------------------------------------------------------------------|
    |-- Walk through the AA Tabs array till we find the Tab we're looking for -|
    |--------------------------------------------------------------------------|
    /for i 1 to ${Tabs.Size}
        /if (${Tabs[${i},1].Equal[${Tab}]}) /goto :GotTab
    /next i

    |--------------------------------------------------------------------------|
    |---------------------- No Tabs matched the one given ---------------------|
    |--------------------------------------------------------------------------|
    /echo The tab "${Tab}" isn't valid. These are the tabs available:
    /for i 1 to ${Tabs.Size}
        /echo ${Tabs[${i},1]}
    /next i
    /return FALSE

    |--------------------------------------------------------------------------|
    |-------------- Found the right AA Tab, time to buy some AA's -------------|
    |--------------------------------------------------------------------------|
    :GotTab
        /varset TabIndex ${i}
        /if (!${Window[AAWindow].Open}) /keypress TOGGLE_ALTADVWIN
        /delay 5 (${Window[AAWindow].Open})
    /if (!${Window[AAWindow].Open}) /goto :GotTab

    |--------------------------------------------------------------------------|
    |---------------------- Trying to select the right tab --------------------|
    |--------------------------------------------------------------------------|
    /for i 1 to ${Tabs.Size}
        /notify AAWindow AAW_Subwindows tabselect ${i}
        /delay 1s (${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${TabIndex},2]}].Open})
        /if (${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${TabIndex},2]}].Open}) /goto :TabOpen
    /next i

    |--------------------------------------------------------------------------|
    |-------- It seems that this character doesn't have the wanted tab --------|
    |--------------------------------------------------------------------------|
    /echo The tab "${TabIndex},1]}" wasn't found!
    /echo Maybe you're lacking the expansion for that AA tab? Maybe you're in shroud form, or trying to access a monster tab?
    /return FALSE

    :TabOpen
    /notify AAWindow ${Tabs[${TabIndex},3]} listselect ${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${TabIndex},2]}].Child[${Tabs[${TabIndex},3]}].List[${AA},1]}
    /delay 5
    /notify AAWindow ${Tabs[${TabIndex},3]} leftmouse ${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${TabIndex},2]}].Child[${Tabs[${TabIndex},3]}].List[${AA},1]}
    /delay 5
    /notify AAWindow ${Tabs[${TabIndex},3]} leftmouseup ${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${TabIndex},2]}].Child[${Tabs[${TabIndex},3]}].List[${AA},1]}

    /delay 1s (${Window[AAWindow].Child[AAW_TrainButton].Enabled})
    /if (${Window[AAWindow].Child[AAW_TrainButton].Enabled}) {
        /notify AAWindow AAW_TrainButton leftmouseup
        /varset Timeout ${Timeout.OriginalValue}
        :Buying
            /delay 5
        /if ((${Me.AAPoints} >= ${AAPts}) && (${Timeout})) /goto :Buying
    }
    /if (${Me.AAPoints} >= ${AAPts}) /return FALSE
/return TRUE


|#Event AAGained "You have gained the ability #1# at a cost of #2# ability points."
Sub Event_AAGained(string Line, string AA, int AACost)
    /echo ${AA.Replace[",]} Bought (Cost ${AACost})
/return

|#Event AAImproved "You have improved #1# at a cost of #2# ability points."
Sub Event_AAImproved(string Line, string AA, int AACost)
    /echo ${AA} Improved (Cost ${AACost})
/return


Example macro
Rich (BB code):
#include BuyAA.inc

Sub Main
    | This would start buying AA's defined in the default INI file if you have
    | saved up 30 AA's
    /if (${Me.AAPoints} > 29) /call BuyAAFromINI
/return


Example AA.ini
Rich (BB code):
; Syntax:
; [server_Character]
; Wanted AA=The AA Tab
;
; Available AA Tabs (depends on the expansions owned etc):
; General
; Archetype
; Class
; PoP Advance
; PoP Ability
; Gates
; Omens
; Veteran
; Monster Innates
; Monster Abilities
; Darkhollow
; Serpent
;
; Example:
[server_Character]
Innate See Invis=Darkhollow
 
Last edited:
Cool, no more checking my macros to see if i need to buy some aa's.

/cheer
 
You need a leftmouse before the leftmouseup line.

With that addition, this works as long as you have the Tab pre-selected for the AA's you want to buy (i.e. General, Archetype, etc). It doesn't work when you ask it to switch between Tabs.

We need a Tab select in there somewhere.
 
I had it buy 2 AA's without the leftmouse before the leftmouseup, although true, it was in the general Tab (didn't have any AA except 2 on the test toon).

Having it select the tab first is something I couldn't really figure out how to make it do on first try, but I'll give it another look. Thanks for pointing them out JoeK :)
 
This is going into my bard macros once you've got the kinks worked out.
Excellent work E.L.S.

*tosses a red cent into your can*
 
Still trying to figure out how to change tabs, I'm pretty stuck there right now..

AAWindow is the Window which should be worked with.
The TabBox child is called AAW_Subwindows, and is a direct child of AAWindow.
The various pages, such as AAW_GeneralPage, AAW_ArchetypePage are then children of the AAW_Subwindows object. I'm assuming that these are the actual tabs, but I can't for the world get them activated.
Anyway, the childen of the pages are, f.ex. AAW_ArchList but those are the actual list of AA's and not the tabs.

I would think that a notify like this:
/notify AAWindow AAW_ArchetypePage leftmouse
or
/notify AAWindow AAW_ArchetypePage leftmouseup
should activate the Archetype tab, but that is not so.

I've also tried with various other combination, some which seemed logical, others which were just trying to see if it would work :(

Any and all suggestions are very welcome.
 
I found that if you had an AA.INI like this

Rich (BB code):
[server_Toon]
 AA1=Healing Adept|Archetype
 AA2=Healing Gift|Archetype
 AA3=Spell Casting Mastery|Archetype

with 5 AA to spend, it would loop non-stop on Healing Adept. You would expect it to Succeed on HA1, fail on HA2, Succeed on HG1, then fail on the rest.

To make it work the way it ought to I put a check in for the Train button being enabled, and a positive verification that you succeeded in your Buy attempt. If you don't succeed, move on to the next AA in the .ini, don't keep trying the one you had trouble with...

BuyAA.inc
Rich (BB code):
Sub BuyAA(string Tab, string AA, int bought)
	/if (!${Defined[Tab]} || !${Defined[AA]}) /return
	/declare i		  int	 local   0
	/varset bought 0

	|--------------------------------------------------------------------------|
	|------------------------ Create the AA Tabs array ------------------------|
	|--------------------------------------------------------------------------|
	/declare Tabs[11,3] string  local
	/varset Tabs[1,1] General
	/varset Tabs[1,2] AAW_GeneralPage
	/varset Tabs[1,3] AAW_GeneralList
	/varset Tabs[2,1] Archetype
	/varset Tabs[2,2] AAW_ArchetypePage
	/varset Tabs[2,3] AAW_ArchList
	/varset Tabs[3,1] Class
	/varset Tabs[3,2] AAW_ClassPage
	/varset Tabs[3,3] AAW_ClassList
	/varset Tabs[4,1] PoPAdvance
	/varset Tabs[4,2] AAW_Page4
	/varset Tabs[4,3] AAW_List4
	/varset Tabs[5,1] PoPAbilities
	/varset Tabs[5,2] AAW_Page5
	/varset Tabs[5,3] AAW_List5
	/varset Tabs[6,1] Gates
	/varset Tabs[6,2] AAW_Page6
	/varset Tabs[6,3] AAW_List6
	/varset Tabs[7,1] Omens
	/varset Tabs[7,2] AAW_Page7
	/varset Tabs[7,3] AAW_List7
	/varset Tabs[8,1] Veteran
	/varset Tabs[8,2] AAW_Page8
	/varset Tabs[8,3] AAW_List8
	/varset Tabs[9,1] MonsterInnates
	/varset Tabs[9,2] AAW_Page9
	/varset Tabs[9,3] AAW_List9
	/varset Tabs[10,1] MonsterAbilities
	/varset Tabs[10,2] AAW_Page10
	/varset Tabs[10,3] AAW_List10
	/varset Tabs[11,1] Darkhollow
	/varset Tabs[11,2] AAW_Page11
	/varset Tabs[11,3] AAW_List11

	|--------------------------------------------------------------------------|
	|-- Walk through the AA Tabs array till we find the Tab we're looking for -|
	|--------------------------------------------------------------------------|
	/for i 1 to ${Tabs.Size}
		/if (${Tabs[${i},1].Equal[${Tab}]}) /goto :GotTab
	/next i

	|--------------------------------------------------------------------------|
	|---------------------- No Tabs matched the one given ---------------------|
	|--------------------------------------------------------------------------|
	/echo The Tab "${Tab}" isn't valid. These are the tabs available:
	/for i 1 to ${Tabs.Size}
		/echo ${Tabs[${i},1]}
	/next i
	/return

	|--------------------------------------------------------------------------|
	|-------------- Found the right AA Tab, time to buy some AA's -------------|
	|--------------------------------------------------------------------------|
	:GotTab
	/if (!${Window[AAWindow].Open}) /keypress TOGGLE_ALTADVWIN
	/delay 5 
	/if (!${Window[AAWindow].Open}) /goto :GotTab
	/notify AAWindow ${Tabs[${i},3]} listselect ${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${i},2]}].Child[${Tabs[${i},3]}].List[${AA},1]}
	/delay 5
	/notify AAWindow ${Tabs[${i},3]} leftmouse ${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${i},2]}].Child[${Tabs[${i},3]}].List[${AA},1]}
	/delay 5
	/notify AAWindow ${Tabs[${i},3]} leftmouseup ${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${i},2]}].Child[${Tabs[${i},3]}].List[${AA},1]}
	/delay 1s 
        /if (${Window[AAWindow].Child[AAW_TrainButton].Enabled}) {
		/notify AAWindow AAW_TrainButton leftmouseup
		/delay 5
		/varset bought 1
		/delay 5 (!${Window[AAWindow].Open})
	}
/return

TestBuyAA.mac
Rich (BB code):
#include BuyAA.inc
 
 #define INIFile AA.ini
 #define Section ${MacroQuest.Server}_${Me.Name}
 Sub Main
     /declare Keys       string  local
     /declare i          int     local   0
     /declare Key        string  local
     /declare Val        string  local
     /declare AA         string  local
     /declare Tab        string  local
     /declare Rank       int     local
     /declare bought     int     local   0
     /if (${Ini[INIFile, Section].Equal[NULL]}) /return
     /varset Keys ${Ini[INIFile, Section]}
     :TrimKeys
         /if (${Keys.Right[1].Equal[|]}) /varset Keys ${Keys.Left[${Math.Calc[${Keys.Length}-1]}]}
     /if (${Keys.Right[1].Equal[|]}) /goto :TrimKeys
     /for i 1 to ${Math.Calc[${Keys.Count[|]}+1]}
         /varset Key ${Keys.Arg[${i},|]}
         /varset Val ${Ini[INIFile,Section,${Keys.Arg[${i},|]}]}
         /varset AA ${Val.Arg[1,|]}
         /varset Tab ${Val.Arg[2,|]}
         :Buy
         /if (${AltAbility[${AA}].AARankRequired} < ${AltAbility[${AA}].MaxRank} && ${AltAbility[${AA}].Cost} <= ${Me.AAPoints}) {
             /echo Buying "${AA}" from ${Tab} tab...
             /call BuyAA "${Tab}" "${AA}" "${bought}"
             /if (${bought}) /goto :Buy
         }
     /next i
 /return
 
Thanks JoeK. I don't see any workaround for having it change tab on its own, so the Archetype examples you're giving, are they where you've manually changed to the correct tab, or?

I've included your idea on returning success or failure, changed to use the Macro.Return though, less variables to worry about ;)

I haven't doublechecked the buy-check you made in the example, but it seems good so also added that to the example in the first post.
 
Made the dirty hack I raved about *sigh*
Anyway, v1.0.3 untested at the moment so if you are up to wasting som AA testing it, you're more than welcome to do this and post your comments here :) Unfortunately the only toon on which I have any AA at the moment, are maxed and have none to buy :p
 
Tested the inc once or twice and it seems to work, however the example macro doesn't work as intended (see known issues in first post). Ideas and suggestions are welcome :)
 
battlerodent said:
how is this doing?
What do you mean?
It's doing just fine I'd say, maybe I should update it to include the TSS tab, but other than that th tests I've made has been well.
 
I tweaked the include to include some Events for successful purchase detection (the server can be slow sometimes getting back to you with the fact that the AA was bought and the available AA points needs to be reduced by the purchase price). Also added a SetupSomeVars sub to be called by the macro which uses this version of BuyAA.inc.

Here's an example macro that will buy the Innate resist AA's while in shroud.

BuyAATest.mac
Rich (BB code):
| Open the AA window and select the Monster Innates Tab.
#include BuyAA.inc
Sub Main()
| declare and initialize some variable located in BuyAA.inc
/call SetupSomeVars

/declare numAA int outer 
/declare numAAleft int outer 

/call BuyMonsterInnates

/return

Sub BuyMonsterInnates()

| How many individual AA's are we trying to buy
/varset numAA 5
/varset numAAleft ${numAA}

/declare i int local

| table is made up of AA_Tab (General, Archetype, etc), then AA Name, then a TryBuy flag.
/declare tableAA[${numAA},3] local

/varset tableAA[1,2] Innate Fire Protection
/varset tableAA[2,2] Innate Cold Protection
/varset tableAA[3,2] Innate Magic Protection
/varset tableAA[4,2] Innate Poison Protection
/varset tableAA[5,2] Innate Disease Protection

/for i 1 to ${numAA}
	/varset tableAA[${i},1] MonsterInnates 
	/varset tableAA[${i},3] 1
/next i

/for i 1 to ${numAA}

:BuyLoop

 /if (!${Me.AAPoints}) /goto :Exit  
 
 /call buyAA "${tableAA[${i},1]}" "${tableAA[${i},2]}"
 /if (!${Macro.Return}) {
  /echo Couldn't buy ${tableAA[${i},2]}.  Skipping. 
  /varset tableAA[${i},3] 0
  /varcalc numAAleft ${numAAleft}-1 
  /if ((!${numAAleft}) | (!${Me.AAPoints}) )  /goto :Exit
  /goto :Continue
 }
/goto :BuyLoop

:Continue

/next i

:Exit

/echo All done.

/return
|end of BuyMonsterInnates

BuyAA.inc (ver 1.03J (1.03 with tweaks by JoeK)

Rich (BB code):
|**
 * BuyAA.inc - by EvenLessSpam, tweaked by JoeK
 *
 * Version: 1.0.3J 
 *
 * Changes:
 *  1.0.0
 *  - Initial release.
 *
 *  1.0.1
 *  - Changed /keypress from "V" to "TOGGLE_ALTADVWIN"
 *  - Removed /keypress that would normally close AAWindow
 *
 *  1.0.2
 *  - BuyAA will now return TRUE on success, FALSE on failure (thanks JoeK)
 *  - Added the "leftmouse" notification before the "leftmouseup" when selecting
 *      the AA in the AA list. (thanks JoeK)
 *
 *  1.0.3
 *  - Now uses MQ2MMouseTo to handle the AA Tabs. Don't place otherwindows on
 *      top of the AAWindow.
 *
 *  1.0.3J
 *  - added Events to detect successful purchases and a SetupSomeVars sub to be 
 *      called by the macro that uses this include file.
**|

#Event AAGained "You have gained the ability#*#"
#Event AAImproved "You have improved #1# at a cost of #2# ability #*#"

Sub SetupSomeVars
    /declare AABought int outer 0
    /declare waitboughtcount outer 0
/return

Sub BuyAA(string Tab, string AA)
    /if (!${Defined[Tab]} || !${Defined[AA]}) /return FALSE
    /declare i              int     local   0
    /declare AAPts          int     local   ${Me.AAPoints}
    /declare Timeout        timer   local   10s
    /declare TabCoord[2]    float   local   0
    /varcalc TabCoord[2] ${Window[AAWindow].Y}+30

    |--------------------------------------------------------------------------|
    |------------------------ Create the AA Tabs array ------------------------|
    |--------------------------------------------------------------------------|
    /declare Tabs[11,4] string  local
    /varset Tabs[1,1] General
    /varset Tabs[1,2] AAW_GeneralPage
    /varset Tabs[1,3] AAW_GeneralList
    /varset Tabs[1,4] 40
    /varset Tabs[2,1] Archetype
    /varset Tabs[2,2] AAW_ArchetypePage
    /varset Tabs[2,3] AAW_ArchList
    /varset Tabs[2,4] 94
    /varset Tabs[3,1] Class
    /varset Tabs[3,2] AAW_ClassPage
    /varset Tabs[3,3] AAW_ClassList
    /varset Tabs[3,4] 145
    /varset Tabs[4,1] PoPAdvance
    /varset Tabs[4,2] AAW_Page4
    /varset Tabs[4,3] AAW_List4
    /varset Tabs[4,4] 196
    /varset Tabs[5,1] PoPAbilities
    /varset Tabs[5,2] AAW_Page5
    /varset Tabs[5,3] AAW_List5
    /varset Tabs[5,4] 247
    /varset Tabs[6,1] Gates
    /varset Tabs[6,2] AAW_Page6
    /varset Tabs[6,3] AAW_List6
    /varset Tabs[6,4] 298
    /varset Tabs[7,1] Omens
    /varset Tabs[7,2] AAW_Page7
    /varset Tabs[7,3] AAW_List7
    /varset Tabs[7,4] 349
    /varset Tabs[8,1] Veteran
    /varset Tabs[8,2] AAW_Page8
    /varset Tabs[8,3] AAW_List8
    /varset Tabs[8,4] 400
    /varset Tabs[9,1] MonsterInnates
    /varset Tabs[9,2] AAW_Page9
    /varset Tabs[9,3] AAW_List9
    /varset Tabs[9,4] 40
    /varset Tabs[10,1] MonsterAbilities
    /varset Tabs[10,2] AAW_Page10
    /varset Tabs[10,3] AAW_List10
    /varset Tabs[10,4] 94
    /varset Tabs[11,1] Darkhollow
    /varset Tabs[11,2] AAW_Page11
    /varset Tabs[11,3] AAW_List11
    /varset Tabs[11,4] 451

    |--------------------------------------------------------------------------|
    |-- Walk through the AA Tabs array till we find the Tab we're looking for -|
    |--------------------------------------------------------------------------|
    /for i 1 to ${Tabs.Size}
        /if (${Tabs[${i},1].Equal[${Tab}]}) /goto :GotTab
    /next i

    |--------------------------------------------------------------------------|
    |---------------------- No Tabs matched the one given ---------------------|
    |--------------------------------------------------------------------------|
    /echo The Tab "${Tab}" isn't valid. These are the tabs available:
    /for i 1 to ${Tabs.Size}
        /echo ${Tabs[${i},1]}
    /next i
    /return FALSE

    |--------------------------------------------------------------------------|
    |-------------- Found the right AA Tab, time to buy some AA's -------------|
    |--------------------------------------------------------------------------|
    :GotTab
    /varcalc TabCoord[1] ${Window[AAWindow].X}+${Tabs[${i},4]}
    /if (!${Window[AAWindow].Open}) /keypress TOGGLE_ALTADVWIN
    /delay 5 (${Window[AAWindow].Open})
    /if (!${Window[AAWindow].Open}) /goto :GotTab

    /varset Timeout ${Timeout.OriginalValue}
    :SwitchToTab
    /if (!${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${i},2]}].Open}) {
        /if (!${Plugin[MQ2MMouseTo].Name.Equal[MQ2MMouseTo]}) /return FALSE
        /mmouseto ${TabCoord[1]} ${TabCoord[2]}
        /delay 1
        /click left
        /delay 1s (${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${i},2]}].Open})
        /if (${Timeout}) /goto :SwitchToTab
    }
    /notify AAWindow ${Tabs[${i},3]} listselect 

${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${i},2]}].Child[${Tabs[${i},3]}].List[${AA},1

]}
    /delay 5
    /notify AAWindow ${Tabs[${i},3]} leftmouse 

${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${i},2]}].Child[${Tabs[${i},3]}].List[${AA},1

]}
    /delay 5
    /notify AAWindow ${Tabs[${i},3]} leftmouseup 

${Window[AAWindow].Child[AAW_Subwindows].Child[${Tabs[${i},2]}].Child[${Tabs[${i},3]}].List[${AA},1

]}

    /delay 1s (${Window[AAWindow].Child[AAW_TrainButton].Enabled})
    /if (${Window[AAWindow].Child[AAW_TrainButton].Enabled}) {
        /notify AAWindow AAW_TrainButton leftmouseup
    | confirmation/AA count update is slow sometimes.  
    | Set up an event but will only wait so long for it to pop.
	/varset AABought 0
	/varset waitboughtcount 0
       :waitboughtloop
	/delay 5
	/doevents
        /delay 5
	/if ((!${AABought}) & (${waitboughtcount} < 5)) {
	  /varcalc waitboughtcount ${waitboughtcount}+1
	  |/echo waitloop # ${waitboughtcount}
          /goto :waitboughtloop
	}
    }
    /if (${Me.AAPoints} >= ${AAPts}) /return FALSE
/return TRUE

|#Event AAGained "You have gained the ability#*#"
sub Event_AAGained 
  /echo AA Bought
  /varset AABought 1
/return

|#Event AAImproved "You have improved #1# at a cost of #2# ability #*#"
sub Event_AAImproved 
  /echo AA Improved
  /varset AABought 1
/return
 
Is there anyway that this macro could be adapted so it will look at the first tab, and just buy the first unpurchased AA it can find? THen, when that tab is done, it will switch to the next tab and do the same thing? I just want to turn the macro on and have it buy what ever AAs it can find while I run my afk macro... Any help with that would be appreciated.

Thanks!
 
this works sortof.. it wont switch between tabs, im gonna try and figure out how to fix it. but if someone else wants to go right ahead!
 
i think somethign on the mq side is borked :P

ive tried all sorts of notifies, and i cant get it to change tabs
 
zazoot said:
i think somethign on the mq side is borked :P

ive tried all sorts of notifies, and i cant get it to change tabs
Maybe the tabselect is b0rked in MQ2. Currently re-installing my system so unable to do any debugging at the moment, but will when I get home.

On another note, I can recommend MQ2AASpend, I myself switched to that instead of this :)
 
EvenLessSpam said:
Maybe the tabselect is b0rked in MQ2. Currently re-installing my system so unable to do any debugging at the moment, but will when I get home.

On another note, I can recommend MQ2AASpend, I myself switched to that instead of this :)

it needs a new offset hehe
 
BuyAA.mac

Users who are viewing this thread

Back
Top
Cart