Page 3 of 3

Posted: Sun Jun 14, 2009 4:51 am
by Lord Beavis
is there anyone that can fix the buy part of this macro?
it works great except i think the way it selects the items and the window names.

or maybe a push in the right direction and i can tinker with it till i can get it to work

Posted: Sun Jun 14, 2009 10:26 am
by toomanynames
I don't think this macro buys anything, it just dumps a list of the spells you do NOT have in your book but "should"

Re: SpellsToBuy.mac [tells you what spells you need to buy]

Posted: Sun Feb 13, 2011 12:55 pm
by Milten
This macro now crashes me.

I'll try to figure out the offending command...

Edit:
/declare InBank bool local ${FindItemBankCount[=${SpellText} ${Spell[${SpellNum}].Name}]}

This one.

Workaround:
/declare InBank bool local 0

Re: SpellsToBuy.mac [tells you what spells you need to buy]

Posted: Tue Mar 15, 2011 2:48 am
by Sym
Anyone have full ini lists that they can send me? Links are dead. I've gotten this updated (mostly) so it will buy again but could use the ini's so i don't have to reinvent the wheel.

Re: SpellsToBuy.mac [tells you what spells you need to buy]

Posted: Fri May 13, 2011 2:00 am
by Roran
Sym wrote:Anyone have full ini lists that they can send me? Links are dead. I've gotten this updated (mostly) so it will buy again but could use the ini's so i don't have to reinvent the wheel.
Can you please share how you fixed it with the rest of us? :-)

Re: SpellsToBuy.mac [tells you what spells you need to buy]

Posted: Thu May 26, 2011 7:02 pm
by Valthonis
Messing around with this, hate to bump an old macro heh. But I have about 4 characters I have to find spells for. macro runs and finds all the spells but I am getting the TLO error when I try to search vendors. Any ideas which line it is.

Re: SpellsToBuy.mac [tells you what spells you need to buy]

Posted: Fri May 27, 2011 2:37 am
by dont_know_at_all
What is "the TLO error"?
Why are you posting in this thread about vendors?

Re: SpellsToBuy.mac [tells you what spells you need to buy]

Posted: Fri May 27, 2011 4:56 pm
by Valthonis
due to missuse of the string top-level object it has been removed.

And its this macro when you do a SearchVendor or SearchVendordump command

Re: SpellsToBuy.mac [tells you what spells you need to buy]

Posted: Fri May 27, 2011 5:21 pm
by Sym
I have this working but need updated vendor lists. Does anyone have them?

Re: SpellsToBuy.mac [tells you what spells you need to buy]

Posted: Fri May 27, 2011 10:11 pm
by Valthonis
I don't have the vendor just the one thats posted on here in the vendor macro, what did you do to get it working?

Re: SpellsToBuy.mac [tells you what spells you need to buy]

Posted: Sat May 28, 2011 12:11 pm
by Sym
I had to remove the bank portions and rewrite the merchant ui selection. I've used it on several diff chars (shd, bst, mag, clr, shm, brd, enc) and it worked pretty well. The ini was off for some things and some newer spells are missing, but the basic functionality is there.

Code: Select all

|Usage:
| /macro spellstobuy
|  lists every spell to be bought
| /macro spellstobuy <level>
|  lists every level <level> spell to be bought
| /macro spellstobuy <minlevel> <maxlevel>
|  lists every level <minlevel> to level <maxlevel> spell to be bought
|
| Updated 05.01.2011 by Sym

#event Bazaar "[MQ2] Bazaar"
#event Merchant "[MQ2] BuySpells"
#event Log "[MQ2] Log"
#event SearchVendors "[MQ2] SearchVendors"
#event SearchVendorLog "[MQ2] SearchVendorDump"
#event SpellsToScribe "[MQ2] SpellsToScribe"

Sub Main(int LevelMin, int LevelMax)
/declare x int local
/declare MaxLevel int local
/declare SpellsMissing int outer 0
/declare SpellNames[256] string outer
/declare SpellIDs[256] int outer
/declare SpellLevels[256] int outer

/if (!${Defined[STB_BuySpellStatus]}) /declare STB_BuySpellStatus int global

/if (!${LevelMin}) {
   /varset MaxLevel ${Me.Level}
} else {
   /varset MaxLevel ${LevelMax}
}

/for x 1 to 5499
  /if (!${Me.Book[${Spell[${x}]}]}) {
   /if (${MaxLevel}) {
    /if (${Spell[${x}].Level}<=${MaxLevel}&&${Spell[${x}].Level}>=${LevelMin}) {
     /call SpellInfo ${x}
    }
   } else /if (${LevelMin}) {
    /if (${Spell[${x}].Level}==${LevelMin}) {
     /call SpellInfo ${x}
    }
   } else {
    /call SpellInfo ${x}
   }
  }
/next x

/echo Search done, waiting for commands. Availiable commands are: Bazaar, BuySpells, SearchVendors, SearchVendorDump, SpellsToScribe and Log.

:endlessloop
   /doevents
   /delay 1s
/goto :endlessloop

/return

Sub Event_SpellsToScribe
   /declare Counter int local

   /for Counter 1 to ${SpellsMissing}
      /if (!${Me.Book[${Spell[${SpellIDs[${Counter}]}].Name}]} && ${Spell[${SpellIDs[${Counter}]}].Level}<=${Me.Level}) {
         /if (${FindItemCount[=${SpellNames[${Counter}]}]}) {
            /echo ${SpellNames[${Counter}]} is in inventory.
         }
         |/if (${FindItemBankCount[=${SpellNames[${Counter}]}]}) {
         |   /echo ${SpellNames[${Counter}]} is in bank.
         |}
      }
   /next Counter
      
   /echo Done looking for spells to scribe.
/return

Sub Event_SearchVendors
   /call SearchVendors 0
/return

Sub Event_SearchVendorLog
   /call SearchVendors 1
/return

Sub SearchVendors(bool Logging)
   /declare Counter int local
   /declare KeyList string local
   /declare KeyTemp string local
   /declare KeyCount int local
   /declare ZoneTemp string local
   /declare FoundSpells bool local 0
   
   /if (${Logging}) /mqlog ---------------------- Merchants with missing spells for ${Me.Name} --------------------------   
   /for Counter 1 to ${SpellsMissing}
      /if (!${FindItemCount[=${SpellNames[${Counter}]}]}) {
         /varset KeyList ${Ini[SpellVendors.ini,${SpellIDs[${Counter}]}]}
         /if (${String[${KeyList}].NotEqual[NULL]}) {
            /varset KeyCount 1
            :MoreKeys
            /varset KeyTemp ${KeyList.Arg[${KeyCount},|]}
            /if (${String[${KeyTemp}].Equal[Null]}) /goto :NoMoreKeys
            /varset ZoneTemp ${Ini[SpellVendors.ini,${SpellIDs[${Counter}]},${KeyTemp},]}
            /varset FoundSpells 1
            /if (${Logging}) {
               /mqlog ${SpellNames[${Counter}]} available from ${KeyTemp} in ${ZoneTemp} at loc ${Ini[SpellVendorList.ini,${ZoneTemp},${KeyTemp}]}
            } else {
               /echo ${SpellNames[${Counter}]} available from ${KeyTemp} in ${ZoneTemp} at loc ${Ini[SpellVendorList.ini,${ZoneTemp},${KeyTemp}]}
            }
            /varcalc KeyCount ${KeyCount}+1
            /goto :MoreKeys
            :NoMoreKeys
         }
      }
   /next Counter
   /if (${Logging}) /mqlog ---------------------- End of merchants for ${Me.Name} ---------------------------------------
   /if (${Logging}) /echo Logging of merchants to ${Macro.Name}.log done.
   /echo Vendor search done. ${If[${FoundSpells},,No matches found.]}
/return

Sub Event_Merchant
   /if (!${Merchant.Open}) {
      /echo You need to open a merchant window.
      /return
   }
   /call BuySpells
/return

Sub BuySpells
   /if (!${Merchant.Open}) /return
   /squelch /custombind add BUYSPELLYES
   /squelch /custombind set BUYSPELLYES-up /varset STB_BuySpellStatus 1
   /squelch /bind BUYSPELLYES shift+y

   /squelch /custombind add BUYSPELLNO
   /squelch /custombind set BUYSPELLNO-up /varset STB_BuySpellStatus 0
   /squelch /bind BUYSPELLNO shift+n

   /if (!${Defined[STB_BuySpellStatus]}) /declare STB_BuySpellStatus int global

   /declare Counter int local
   /declare ItemCounter int local
   /declare ItemSlotNumber int local
   
   /for Counter 1 to ${SpellsMissing}
      /varset ItemSlotNumber 0
      /varset STB_BuySpellStatus 2
      /if (${Merchant.Item[=${SpellNames[${Counter}]}].ID} && !${FindItemCount[${SpellNames[${Counter}]}]} ) {
         |/for ItemCounter 1 to ${Merchant.Items}
         /for ItemCounter 1 to ${Window[MerchantWnd].Child[MW_ItemList].Items}
            |/e ${ItemCounter} ${Merchant.Item[${ItemCounter}].Name}
            |/e ${ItemCounter} ${Window[MerchantWnd].Child[MW_ItemList].List[${ItemCounter},2]}
            /if (${Window[MerchantWnd].Child[MW_ItemList].List[${ItemCounter},2].Equal[${SpellNames[${Counter}]}]}) /varset ItemSlotNumber ${ItemCounter}
         /next ItemCounter
         /if (${ItemSlotNumber}) {
            |/echo Buy ${Window[MerchantWnd].Child[MW_ItemList].List[${ItemCounter},2]} for ${Math.Calc[${Merchant.Item[${ItemSlotNumber}].BuyPrice}\1000].Int}p ${Math.Calc[(${Merchant.Item[${ItemSlotNumber}].BuyPrice}\100)%10].Int}g ${Math.Calc[(${Merchant.Item[${ItemSlotNumber}].BuyPrice}\10)%10].Int}s ${Math.Calc[${Merchant.Item[${ItemSlotNumber}].BuyPrice}%10].Int}c? (Shift-Y / Shift-N)
            /echo Buy ${Window[MerchantWnd].Child[MW_ItemList].List[${ItemSlotNumber},2]}? (Shift-Y / Shift-N)
            /notify MerchantWnd MW_ItemList listselect ${ItemSlotNumber}
            |/e /notify MerchantWnd MW_ItemList listselect ${ItemSlotNumber}
            :WaitForSpellBuyResponse
            /if (${STB_BuySpellStatus}==2) {
               /delay 1
               /goto :WaitForSpellBuyResponse
            }
            /if (${STB_BuySpellStatus}==1) {
               |/itemnotify merchant${ItemSlotNumber} leftmouseup
               |/notify MerchantWnd MW_ItemList listselect ${ItemSlotNumber}
               /buyitem 1
               /delay 2s
            }
         }
      }
   /next Counter
   /echo Finished buying spells.
   /squelch /custombind delete BUYSPELLYES
   /squelch /custombind delete BUYSPELLNO
   /squelch /bind shift+y clear
   /squelch /bind shift+n clear
   /squelch /deletevar STB_BuySpellStatus
/return

Sub Event_Log
   /declare Counter int local
   /mqlog ------------------------ Missing Spells for ${Me.Name} ------------------------
   /for Counter 1 to ${SpellsMissing}
      /if (!${FindItemCount[=${SpellNames[${Counter}]}]}) /mqlog ${Me.Name} is missing level ${SpellLevels[${Counter}]} ${SpellNames[${Counter}]}
   /next Counter
   /mqlog ------------------------ End of Spells for ${Me.Name} -------------------------
   /echo Logging to ${Macro.Name}.log done.
/return

Sub Event_Bazaar
   /if (${Zone.Name.NotEqual[The Bazaar]}) {
      /echo You need to be in The Bazaar to search.
      /return
   }
   /if (${String[${Plugin[MQ2Bzsrch]}].Equal[NULL]}) {
      /echo You need to load the mq2bzsrch plugin to search.
      /return
   }
   /call BazaarSearch
/return

Sub BazaarSearch
/declare Counter int local
/declare ItemCounter int local
/declare CheapestPrice int local
/declare CheapestVendor string local
/declare FoundSpells bool local 0
/echo Searching the bazaar for missing spells.

/for Counter 1 to ${SpellsMissing}
   /if (!${FindItemCount[=${SpellNames[${Counter}]}]}) {
      /varset CheapestPrice 0
     :KeepSearching
     /bzsrch race any class any stat any slot any type scroll price 0 9999999 "${SpellNames[${Counter}]}"
     /delay 3s ${Bazaar.Done}
     /if (!${Bazaar.Done}) /goto :KeepSearching
      /if (${Bazaar.Count}) {
         /for ItemCounter 1 to ${Bazaar.Count}
            /varset FoundSpells 1
            /if (!${CheapestPrice} || ${CheapestPrice}>${Bazaar.Item[${ItemCounter}].Price} && ${Bazaar.Item[${ItemCounter}].Name.Equal[${SpellNames[${Counter}]}]}) {
               /varset CheapestPrice ${Bazaar.Item[${ItemCounter}].Price}
               /varset CheapestVendor ${Bazaar.Item[${ItemCounter}].Trader.Name}
            }
         /next ItemCounter
         /echo ${SpellNames[${Counter}]} is sold by ${CheapestVendor} for ${Math.Calc[${CheapestPrice}\1000].Int}p ${Math.Calc[(${CheapestPrice}\100)%10].Int}g ${Math.Calc[(${CheapestPrice}\10)%10].Int}s ${Math.Calc[${CheapestPrice}%10].Int}c.
      }
   }
/next Counter
/echo Bazaar search done. ${If[${FoundSpells},,No matches found.]}
/return


Sub SpellInfo(int SpellNum)
/declare SpellText string local
/if (${Me.Class.Name.Equal[Bard]}) {
   /varset SpellText Song:
} else {
   /varset SpellText Spell:
}
/declare InBank bool local 0
|${FindItemBankCount[=${SpellText} ${Spell[${SpellNum}].Name}]}
/declare InBag bool local ${FindItemCount[=${SpellText} ${Spell[${SpellNum}].Name}]}

| /if (!${InBank} && !${InBag}) {
    /varcalc SpellsMissing ${SpellsMissing}+1
    /varset SpellNames[${SpellsMissing}] ${SpellText} ${Spell[${SpellNum}].Name}
    /varset SpellLevels[${SpellsMissing}] ${Spell[${SpellNum}].Level}
    /varset SpellIDs[${SpellsMissing}] ${Spell[${SpellNum}].ID}
| }
/echo ${Spell[${SpellNum}]} ${If[${Spell[${SpellNum}].Level}>${Me.Level},(Above level) ,]}${If[${InBag},(In Bag) ,]}${If[${InBank},(In Bank) ,]}Level:${Spell[${SpellNum}].Level}  Type:${Spell[${SpellNum}].SpellType}  Target:${Spell[${SpellNum}].TargetType}

/return