Hope you don't mind me adding stuff to your macro. It's a great macro and I just thought of some features that would make it even better. Trying to make it the perfect script to use to fill up the spellbooks of my alts :). I've been rather bored today so I figured I might aswell add them myself instead of bugging you to do it.
Anyway, what I've done is that after it's searched it doesn't end, it waits for commands to be sent to it through /echo.
It will allow you to specify a maxlevel above your current level so you can see what spells you want to buy before you ding.
It will look for the scrolls in your bank and bags if the spell isn't in your spellbook and report that accordingly.
The commands availiable are:
Log
-writes the missing spells to a log file (/mqlog)
BuySpells
-if you have an open merchant window it will buy the spells you are missing that are in the merchant's inventory
Bazaar
-if you are in the bazaar it searches vendors for the spells you are missing and reports the lowest price
SearchVendor
-searches for spell merchants in inifiles made by Chill's macro
SearchVendorDump
-same as SearchVendor but it writes to logfile instead
SpellsToScribe
-lists the spells you have in your bags or bank that you are high enough to scribe but haven't yet
Might very well be a bug or two in there as I haven't tested it that much. Here's the code:
EDIT: Made it ask for confirmation before buying spells. Press shift+Y or shift+N to buy or pass.
EDIT: Added functionality to search for vendors in inifiles made by Chill's macro
EDIT: Made it work with bard songs too
EDIT: SpellsToScribe command added
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
#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}]}]} && !${FindItemBankCount[=${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}]}]} && !${FindItemBankCount[${SpellNames[${Counter}]}]}) {
/for ItemCounter 1 to ${Merchant.Items}
/if (${Merchant.Item[${ItemCounter}].Name.Equal[${SpellNames[${Counter}]}]}) /varset ItemSlotNumber ${ItemCounter}
/next ItemCounter
/if (${ItemSlotNumber}) {
/echo Buy ${Merchant.Item[${ItemSlotNumber}].Name} 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)
:WaitForSpellBuyResponse
/if (${STB_BuySpellStatus}==2) {
/delay 1
/goto :WaitForSpellBuyResponse
}
/if (${STB_BuySpellStatus}==1) {
/itemnotify merchant${ItemSlotNumber} leftmouseup
/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}]}]} && !${FindItemBankCount[=${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}]}]} && !${FindItemBankCount[=${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 ${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