Reposting the bazaar.mac that was posted by VI in http://www.mmobugs.com/forums/everquest-general-chat-requests-and-questions/21956-bazaar-mac.html. Fixed so it no longer undercuts itself. Haven't verified the buyer mode is working, however I plan on adding some additional functionality to this soon.
Code:
|************************************************************************
|* bazaar.mac version 1.0.5
|* 04/26/2006
|* Auto-Update Bazaar Prices
|*
|* by ebs2002
|*
|* Special thanks to:
|* - Sparr for the original updatebazaarprices.mac
|* - M.D. for updating it
|* - Updated with TraderSetup routine by TreeHuginDruid 10-26-2007
|************************************************************************
|* Summary:
|*
|* This macro is used to automatically update the prices of your
|* buyer or trader to remain competitive.
|*
|* It also contains INI support to allow you to set minimum and maximum
|* prices which your merchants will not pass
|************************************************************************
|* Usage:
|* /mac bazaar trader
|* updates your /trader
|*
|* /mac bazaar buyer
|* updates your buyer
|*
|* INI format:
|* bazaar.ini:
|* [Metallic Drake Scales]
|* SellPriceMin=20500
|* SellPriceMax=30000
|* BuyPriceMin=10000
|* BuyPriceMax=20000
|************************************************************************
|* Notes:
|* Unlike Sparr's bazaar update mac, this macro doesn't check for
|* underpriced goods yet. This is because I had to significantly
|* re-write Sparr's code for my purposes, and I didn't have a need for
|* it with the goods I sell. A future update may include this feature.
|*
|* This macro also will ALWAYS beat a price unless it falls outside your
|* SellPriceMin or BuyPriceMax. Rather than using Standard Deviation,
|* it will price your seller 1% lower than the lowest seller, or price
|* your buyer at either +5, +1%, or +0.1% depending on the price of the
|* item:
|*
|* 1-500 : +5
|* 501-5000 : +1%
|* 5000+ : +0.1%
|*
|* Additionally, if your selling price is significantly lower than the
|* next highest seller (or your buying price is higher than the next
|* lowest buyer), your prices will be adjusted accordingly
|*
|* Finally, if you want to execute any commands at the end of the macro
|* just edit the last Sub (EndMacro) to execute the final commands
|* (example, /ooc Trader Up! or /1 WTS Cultural Augments!
|*
|************************************************************************|
|-------------------------------------------------------------|
Sub Main
/declare looptimer int local
/declare slot int local
/declare dupecheck int local
/declare itemname string local
/declare result int local
/declare stddev int local
/declare itemsfound int local
/declare pricetotal int local
/declare avgprice int local
/declare minprice int local
/declare avgdev int local
/declare devhigh int local
/declare quartprice int local
/declare maxprice int local
/declare price int local
/declare fairprice int local
/declare targetprice int local
/declare newtargetprice int local
/declare PlatVal int local
/declare targetstr string local
/declare merchType int local 0
/declare merchString string local 0
/declare minSellPrice int local
/declare maxSellPrice int local
/declare dontReprice int local 0
|------------------------------------------
|INITPRICE SETUP
|------------------------------------------
/if (${Defined[Param1]}) {
/if (${Param1.Equal[initprice]}) {
/echo Initiating prices on new items.
/call TraderSetup
}
}
|------------------------------------------
:mainloop
/varset looptimer 60
/echo Starting Auto-update...
/if (${Defined[Param0]}) {
/if (${Param0.Equal[trader]}) {
/varset merchType 1
/varset merchString "
/echo Auto-Updating Trader Prices.
} else /if (${Param0.Equal[buyer]}) {
/varset merchType 2
/echo Auto-Updating Buyer Prices.
}
}
/if (${merchType}==0) {
/echo Invalid Usage: /mac bazaar trader | /mac bazaar buyer.
/endmac
}
/if (${merchType}==1) {
:OpenTraderAgain
/echo Opening Trade Window.
/trader
/delay 1s ${Window[BazaarWnd].Open}
/if (!${Window[BazaarWnd].Open}) /goto :OpenTraderAgain
:OpenBazaarAgain
/bazaar
/echo Opening Bazaar Window.
/delay 2s ${Window[BazaarSearchWnd].Open}
/if (!${Window[BazaarSearchWnd].Open}) /goto :OpenBazaarAgain
/notify BazaarSearchWnd BZR_UpdatePlayerButton leftmouseup
/echo Updating Current Traders...
/delay 2s
} else {
/call Barter_Main
}
/varset slot -1
|/varset slot 68
:nextslot
/delay 5
|/echo checking slot # (${slot}).
/varcalc slot ${slot}+1
/if (${slot}>79) /goto :donewithslots
/notify BazaarWnd BZR_BazaarSlot${slot} leftmouseup
/if (!${Window[BazaarWnd].Child[BZW_SetPrice_Button].Enabled}) /goto :nextslot
/if (!${Window[BazaarWnd].Child[BZW_Clear_Button].Enabled}) /goto :nextslot
/varset itemname ${Window[BazaarWnd].Child[BZR_BazaarSlot${slot}].Tooltip}
/delay 10
:SearchBazaarAgain
/echo Searching bazaar for item (${itemname}).
/bzsrch race any class any stat any slot any type any price 0 9999999 ${itemname}
/delay 5s ${Bazaar.Done}
/if (!${Bazaar.Done}) /goto :SearchBazaarAgain
/if (!${Bazaar.Count}) /goto :nextslot
/varset itemsfound 0
/varset pricetotal 0
/varset minprice 9999999999
/varset maxprice 0
/varset minSellPrice 0
/varset maxSellPrice 9999999999
/varset dontReprice 0
/for result 1 to ${Bazaar.Count}
/if (${Bazaar.Item[${result}].Name.Equal[${itemname}]}&&!${Me.Name.Equal[${Bazaar.Item[${result}].Trader}]}) {
/varcalc itemsfound ${itemsfound}+${Bazaar.Item[${result}].Quantity}
/varcalc pricetotal ${pricetotal}+${Bazaar.Item[${result}].Price}*${Bazaar.Item[${result}].Quantity}
/if (${Bazaar.Item[${result}].Price}<${minprice}) /varset minprice ${Bazaar.Item[${result}].Price}
/if (${Bazaar.Item[${result}].Price}>${maxprice}) /varset maxprice ${Bazaar.Item[${result}].Price}
}
/next result
/if (!${itemsfound}) {
/if (${Ini["bazaar.ini","${itemname}", SellPriceMax]}) {
/varset targetstr ${Ini["bazaar.ini","${itemname}", SellPriceMax]}
/goto :setPrice
} else {
/goto :nextslot
}
}
/varcalc minprice ${minprice}/1000
/if (${minprice}==1) /varset minprice 2
/if (${Ini["bazaar.ini","${itemname}",SellPriceMin]}) {
/varset minSellPrice ${Ini[bazaar.ini,"${itemname}",SellPriceMin]}
}
/if (${Ini[bazaar.ini,"${itemname}",SellPriceMax]}) {
/varset maxSellPrice ${Ini[bazaar.ini,"${itemname}",SellPriceMax]}
}
/if (${minprice}*0.99<${minSellPrice}) {
/varset targetstr ${minSellPrice}
/beep
/echo ${itemname} is being sold for ${minprice}, but your minimum is ${minSellPrice}.
/goto :setPrice
}
/if (${minprice}*0.99>${maxSellPrice}) {
/varset targetstr ${maxSellPrice}
/goto :setPrice
}
/if (${minprice}<500000 && ${minprice}>0) {
/if (${minprice}<100) {
/varset targetstr ${Math.Calc[${minprice}-1]}
| } else /if (${minprice}>5000) {
| /varcalc targetstr ${Int[${Math.Calc[ ${minprice}*0.999/25 ]}]}*25
} else {
/varcalc targetstr ${Int[${Math.Calc[ ${minprice}*0.99/25 ]}]}*25
}
/varset targetprice ${targetstr}
/varset targetstr ${Int[${targetstr}]}
:setPrice
/if (!${targetstr.Equal[${Window[BazaarWnd].Child[BZW_Money0].Text}]}) {
/echo --- Repricing ${itemname} from (${Window[BazaarWnd].Child[BZW_Money0].Text}) to (${targetstr}).
:openqtywndagain
/notify BazaarWnd BZW_Money0 leftmouseup
/delay 2s
/if (!${Window[QuantityWnd].Open}) /goto :openqtywndagain
/delay 1
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/delay 1
/for PlatVal 1 to 7
/squelch /keypress ${targetstr.Mid[${PlatVal},1]} chat
/next PlatVal
/notify QuantityWnd QTYW_Accept_Button leftmouseup
/delay 1
/notify BazaarWnd BZW_SetPrice_Button leftmouseup
/delay 1
}
}
/goto :nextslot
:donewithslots
/call TraderStatus
|-------------------------------------|
:cycleloop
/Echo *** Waiting (${looptimer})minute(s) before next price check/update. ***
/call CloseBazSrchWnd
/if (${looptimer}==0) /goto :mainloop
/varset looptimer ${Math.Calc[${looptimer}-1]}
/delay 1m
/goto :cycleloop
|-------------------------------------|
/call EndMacro
/return
|-------------------------------------------------------------|
|-------------------------------------------------------------|
Sub Barter_Main
/declare merchType int local 0
/declare merchString string local 0
/declare minBuyPrice int local
/declare maxBuyPrice int local
/declare dontReprice int local 0
/declare BuyItemSlot int local 0
/declare ItemName string local 0
:OpenBuyerAgain
/echo Opening Buy Window.
/buy
/delay 1s ${Window[BarterWnd].Open}
/if (!${Window[BarterWnd].Open}) /goto :OpenBuyerAgain
:OpenBarterAgain
/barter
/echo Opening Barter Window.
/delay 2s ${Window[BarterSearchWnd].Open}
/if (!${Window[BarterSearchWnd].Open}) /goto :OpenBarterAgain
:startLoop
/for BuyItemSlot 1 to 80
/if (${Window[BarterWnd].Child[BTR_BuyLineList].List[${BuyItemSlot}].Length}>0) {
/varset ItemName ${Window[BarterWnd].Child[BTR_BuyLineList].List[${BuyItemSlot},3]}
/varset minBuyPrice ${Ini["bazaar.ini",${ItemName}, BuyPriceMin]}
/varset maxBuyPrice ${Ini["bazaar.ini",${ItemName}, BuyPriceMax]}
/call UpdateBuyer "${ItemName}" ${minBuyPrice} ${maxBuyPrice}
}
/next BuyItemSlot
/call EndMacro
/return
|-------------------------------------------------------------|
|-------------------------------------------------------------|
Sub UpdateBuyer(String name, int min, int max)
/declare loopVar int local 0
/declare loopVarMax int local 0
/declare maxFoundPrice int local ${min}
/declare searchResult string local
/declare found int local 0
/declare seller string local
/declare inSlot int local 0
/notify BarterSearchWnd BTRSRCH_ItemSearchEdit leftmouseup
/delay 1s
/shiftkey /keypress end chat
/delay 1s
/varset loopVarMax ${Window[BarterSearchWnd].Child[BTRSRCH_ItemSearchEdit].Text.Length}
/for loopVar 1 to ${loopVarMax}
/keypress backspace chat
/next loopVar
/for loopVar 1 to ${name.Length}
/if (${name.Mid[${loopVar},1].Equal[" "]}) {
/keypress space chat
} else {
/keypress ${name.Mid[${loopVar},1]} chat
}
/next loopVar
/keypress enter chat
/delay 3s
| Find Max Buy Price
/for loopVar 1 to 200
/varset searchResult ${Window[BarterSearchWnd].Child[BTRSRCH_BuyLineList].List[${loopVar},2]}
/varset searchResult ${searchResult.Mid[1, ${Math.Calc[${searchResult.Find["("]}-1]}]}
/if (${searchResult.Length}==0) /goto :EndLoop
/varset seller ${Window[BarterSearchWnd].Child[BTRSRCH_BuyLineList].List[${loopVar},4]}
/if (${searchResult.Equal[${name}]} && !${seller.Equal[${Me.Name}]}) {
| Item match, get max plat value
/varset found ${Window[BarterSearchWnd].Child[BTRSRCH_BuyLineList].List[${loopVar},3]}
/if (${found}>${maxFoundPrice}) /varset maxFoundPrice ${found}
}
/next loopVar
:EndLoop
/if (${maxFoundPrice}!=${min}) {
/if (${maxFoundPrice}<100) {
/varcalc maxFoundPrice ${maxFoundPrice}+1
} else /if (${maxFoundPrice}<5000) {
/varcalc maxFoundPrice ${maxFoundPrice}+5
} else {
/varcalc maxFoundPrice ${maxFoundPrice}*1.001
/varcalc maxFoundPrice ${Int[${Math.Calc[${maxFoundPrice}/5]}]}*5
}
}
/if (${maxFoundPrice}>${max}) {
/beep
/echo Want to set ${name} to ${maxFoundPrice}, but your maximum is ${max}.
/varset maxFoundPrice ${max}
}
/varset inSlot ${Window[BarterWnd].Child[BTR_BuyLineList].List[=${name},3]}
/if (${maxFoundPrice} != ${Int[${Window[BarterWnd].Child[BTR_BuyLineList].List[${inSlot},5]}]} ) {
/call SetPrice ${maxFoundPrice} "${name}"
}
/return
|-------------------------------------------------------------|
|-------------------------------------------------------------|
Sub SetPrice(string price, string name)
/echo Setting price of ${name} to ${price}.
/declare listID int ${Window[BarterWnd].Child[BTR_BuyLineList].List[=${name},3]}
/declare PlatVal int 0
/notify BarterWnd BTR_BuyLineList listselect ${listID}
/delay 5
/notify BarterWnd BTR_BuyLineList leftmouse ${listID}
/delay 5
/notify BarterWnd BTR_CompensationPlat leftmouseup
/delay 1
:delete
/keypress backspace chat
/if (${Window[QuantityWnd].Child[QTYW_SliderInput].Text.Length}) /goto :delete
/delay 1
/for PlatVal 1 to 7
/squelch /keypress ${price.Mid[${PlatVal},1]} chat
/next PlatVal
/notify QuantityWnd QTYW_Accept_Button leftmouseup
/delay 1
/notify BarterWnd BTR_BuyLineModifyButton leftmouseup
/return
|-------------------------------------------------------------|
|-------------------------------------------------------------|
Sub TraderStatus
/if (!${Me.Trader}) {
/delay 1s
:OpenBazaarWnd
/if (!${Window[BazaarWnd].Open}) /trader
/delay 1s (${Window[BazaarWnd].Open})
/if (!${Window[BazaarWnd].Open}) /goto :OpenBazaarWnd
/delay 1s
/notify BazaarWnd BZW_Start_Button LeftMouseUp
/delay 1s
/echo Tradermode ON.
}
/delay 1s
/return
|-------------------------------------------------------------|
|-------------------------------------------------------------|
Sub TraderSetup
/declare slot int local
/declare itemname string local
/declare PlatVal int local
/declare targetstr string local 1000
/declare curprice string local
/echo Setting unpriced items to default price of (${targetstr}) pp.
:OpenTraderAgain
/echo Opening Trade Window.
/trader
/delay 1s ${Window[BazaarWnd].Open}
/if (!${Window[BazaarWnd].Open}) /goto :OpenTraderAgain
/varset slot -1
:nextslot
/varcalc slot ${slot}+1
/if (${slot}>79) /goto :donewithslots
/notify BazaarWnd BZR_BazaarSlot${slot} leftmouseup
/varset curprice ${Window[BazaarWnd].Child[BZW_Money0].Text}
|/echo --- ${curprice} ---
/if (!${Window[BazaarWnd].Child[BZW_SetPrice_Button].Enabled}) /goto :nextslot
|/if (!${Window[BazaarWnd].Child[BZW_Clear_Button].Enabled}) /goto :nextslot
/varset itemname ${Window[BazaarWnd].Child[BZR_BazaarSlot${slot}].Tooltip}
|/echo itemname = ${itemname}
/delay 1s
/if (${curprice}==0) {
/echo Price not set for item (${itemname}).
:setPrice
/echo --- Repricing ${itemname} from ${Window[BazaarWnd].Child[BZW_Money0].Text} to ${targetstr}.
:openqtywndagain
/notify BazaarWnd BZW_Money0 leftmouseup
/delay 2s
/if (!${Window[QuantityWnd].Open}) /goto :openqtywndagain
/delay 1
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/keypress backspace chat
/delay 1
/for PlatVal 1 to 7
/squelch /keypress ${targetstr.Mid[${PlatVal},1]} chat
/next PlatVal
/notify QuantityWnd QTYW_Accept_Button leftmouseup
/delay 1
/notify BazaarWnd BZW_SetPrice_Button leftmouseup
/delay 1
} else {
/echo Price set to: (${curprice} pp), skipping price init.
}
/goto :nextslot
:donewithslots
/call CloseBazSrchWnd
/return
|-------------------------------------------------------------|
|-------------------------------------------------------------|
Sub CloseBazSrchWnd
:CloseBazaarSearchWnd
/if (${Window[BazaarSearchWnd].Open}) /keypress TOGGLE_BAZAARSEARCHWIN
/delay 2s (!${Window[BazaarSearchWnd].Open})
/if (${Window[BazaarSearchWnd].Open}) /goto :CloseBazaarSearchWnd
/return
|-------------------------------------------------------------|
|-------------------------------------------------------------|
Sub EndMacro
/call CloseBazSrchWnd
/endmac
/return
|-------------------------------------------------------------|
Last edited: