Fix and re-enable bid support on buyer bot

This commit is contained in:
NathanHandley
2025-09-09 17:37:10 -05:00
parent d6af4edaf4
commit 7c57a6f11e
4 changed files with 70 additions and 34 deletions

View File

@@ -33,7 +33,7 @@ Notes:
1. **Determining Items to Buy:** Every minute the buyer bot will select (BuyCanditatesPerBuyoutCycle) items currently up for auction which are listed by players as potential purchase items.
2. **Price Willing to Pay:** The buyer bot will use the same item price calculation the seller bot uses, including the random +/- 25%, and that calculated price is then multiplied by (AcceptablePriceModifier) which then becomes the price the buyer will be willing to spend.
3. **Buying it:** If the price calculated is higher than the buy out price, then the bot will buy it out.
3. **Buying it:** If the price calculated is higher than the buy out price, then the bot will buy it out. If not, it will test to see if it has been bidded on by a bot and if not, if the bid price is below the price it is willing to pay. If so, it will bid (outbid, so just over current bid).
The above behavior is replicated on each enabled auction house. If left to default settings, 1 item in each auction house will attempt to be bought from, if the price calculation seems favorable. Note that any item buy attempt, even items above buying price, consumes a buy candidate. That means that too many overpriced items can drown out potential sales.

View File

@@ -48,14 +48,16 @@ AuctionHouseBot.AuctionHouseManagerCyclesBetweenBuyOrSell = 1
# BUYER PROPERTIES
# Behavior:
# 1) Determining Items to Buy: Every minute the buyer bot will select
# (BuyCanditatesPerBuyoutCycle) items currently up for auction which are
# (BuyCanditatesPerBuyCycle) items currently up for auction which are
# listed by players as potential purchase items.
# 2) Price Willing to Pay: The buyer bot will use the same item price
# calculation the seller bot uses, including the random +/- 25%, and
# that calculated price is then multiplied by (AcceptablePriceModifier)
# which then becomes the price the buyer will be willing to spend.
# 3) Buying it: If the price calculated is higher than the buy out price,
# then the bot will buy it out.
# then the bot will buy it out. If not, it will see if it's an item
# not yet bidded on by a bot and the price is affordable, then it will
# place a bid (outbid, so just over current bid)
# - The above behavior is replicated on each enabled auction house.
# - If left to default settings, 1 item in each auction house will attempt
# to be bought from, if the price calculation seems favorable.
@@ -67,7 +69,7 @@ AuctionHouseBot.AuctionHouseManagerCyclesBetweenBuyOrSell = 1
# Enable/Disable the buying bot.
# Default 0 (disabled)
#
# AuctionHouseBot.Buyer.BuyCanditatesPerBuyoutCycle
# AuctionHouseBot.Buyer.BuyCanditatesPerBuyCycle
# How many to items to price and attempt to buy. Note, this number of
# items will be selected from each of the auction house types (Alliance,
# Horde, Neutral). Meaning if you set this as 10, then up to 10 items
@@ -88,7 +90,7 @@ AuctionHouseBot.AuctionHouseManagerCyclesBetweenBuyOrSell = 1
###############################################################################
AuctionHouseBot.Buyer.Enabled = 0
AuctionHouseBot.Buyer.BuyCanditatesPerBuyoutCycle = 1
AuctionHouseBot.Buyer.BuyCanditatesPerBuyCycle = 1
AuctionHouseBot.Buyer.AcceptablePriceModifier = 1
###############################################################################

View File

@@ -21,6 +21,7 @@
#include "ObjectMgr.h"
#include "AuctionHouseMgr.h"
#include "AuctionHouseBot.h"
#include "AuctionHouseSearcher.h"
#include "Config.h"
#include "Player.h"
#include "WorldSession.h"
@@ -37,7 +38,7 @@ AuctionHouseBot::AuctionHouseBot() :
SellingBotEnabled(false),
BuyingBotEnabled(false),
CyclesBetweenBuyOrSell(1),
BuyingBotBuyCanditatesPerBuyoutCycle(1),
BuyingBotBuyCanditatesPerBuyCycle(1),
BuyingBotAcceptablePriceModifier(1),
AHCharactersGUIDsForQuery(""),
ItemsPerCycle(75),
@@ -675,13 +676,13 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player* AHBplayer, AHBConfig *con
possibleBids.push_back(tmpdata);
}while (result->NextRow());
for (uint32 count = 1; count <= BuyingBotBuyCanditatesPerBuyoutCycle; ++count)
for (uint32 count = 1; count <= BuyingBotBuyCanditatesPerBuyCycle; ++count)
{
// Do we have anything to bid? If not, stop here.
if (possibleBids.empty())
{
//if (debug_Out) sLog->outError( "AHBuyer: I have no items to bid on.");
count = BuyingBotBuyCanditatesPerBuyoutCycle;
count = BuyingBotBuyCanditatesPerBuyCycle;
continue;
}
@@ -716,15 +717,20 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player* AHBplayer, AHBConfig *con
uint64 discardBidPrice = 0;
calculateItemValue(prototype, discardBidPrice, willingToSpendPerItemPrice);
willingToSpendPerItemPrice = (uint64)((float)willingToSpendPerItemPrice * BuyingBotAcceptablePriceModifier);
uint64 willingToSpendForStackPrice = willingToSpendPerItemPrice * pItem->GetCount();
// Buy it if the price is greater than buy out, otherwise skip
uint64 willingToPayForStackPrice = willingToSpendPerItemPrice * pItem->GetCount();
uint64 bidAmount = 0;
// Determine if it's a bid, buyout, or skip
bool doBuyout = false;
uint32 minBuyoutPrice = 0;
if (auction->buyout != 0 && willingToSpendForStackPrice >= auction->buyout)
doBuyout = true;
bool doBid = false;
if (doBuyout == true)
if (auction->buyout != 0 && auction->buyout < willingToPayForStackPrice)
doBuyout = true;
else if (auction->startbid < willingToPayForStackPrice && auction->GetAuctionOutBid() < willingToPayForStackPrice)
doBid = true;
if (doBuyout == true || doBid == true)
{
if (debug_Out)
{
@@ -738,8 +744,7 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player* AHBplayer, AHBConfig *con
LOG_INFO("module", "AHBuyer: Buyout: {}", auction->buyout);
LOG_INFO("module", "AHBuyer: Deposit: {}", auction->deposit);
LOG_INFO("module", "AHBuyer: Expire Time: {}", uint32(auction->expire_time));
LOG_INFO("module", "AHBuyer: Willing To Spend For Stack Price: {}", willingToSpendForStackPrice);
LOG_INFO("module", "AHBuyer: Minimum Buyout Price: {}", minBuyoutPrice);
LOG_INFO("module", "AHBuyer: Willing To Pay For Stack Price: {}", willingToPayForStackPrice);
LOG_INFO("module", "AHBuyer: Item GUID: {}", auction->item_guid.ToString());
LOG_INFO("module", "AHBuyer: Item Template: {}", auction->item_template);
LOG_INFO("module", "AHBuyer: Item Info:");
@@ -753,12 +758,40 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player* AHBplayer, AHBConfig *con
LOG_INFO("module", "-------------------------------------------------");
}
if (doBid)
{
auto trans = CharacterDatabase.BeginTransaction();
// Perform outbid
uint32 bidAmount = 0;
if (auction->bid == 0)
bidAmount = auction->startbid;
else
bidAmount = auction->GetAuctionOutBid();
if (auction->bidder)
{
sAuctionMgr->SendAuctionOutbiddedMail(auction, bidAmount, AHBplayer, trans);
CharacterDatabase.CommitTransaction(trans);
}
auction->bidder = AHBplayer->GetGUID();
auction->bid = bidAmount;
sAuctionMgr->GetAuctionHouseSearcher()->UpdateBid(auction);
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_AUCTION_BID);
stmt->SetData(0, auction->bidder.GetCounter());
stmt->SetData(1, auction->bid);
stmt->SetData(2, auction->Id);
trans->Append(stmt);
}
else if (doBuyout)
{
auto trans = CharacterDatabase.BeginTransaction();
if ((auction->bidder) && (AHBplayer->GetGUID() != auction->bidder))
{
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, AHBplayer, trans);
}
auction->bidder = AHBplayer->GetGUID();
auction->bid = auction->buyout;
@@ -772,6 +805,7 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player* AHBplayer, AHBConfig *con
CharacterDatabase.CommitTransaction(trans);
}
}
}
}
void AuctionHouseBot::Update()
@@ -800,16 +834,16 @@ void AuctionHouseBot::Update()
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
{
addNewAuctions(&_AHBplayer, &AllianceConfig);
if (BuyingBotBuyCanditatesPerBuyoutCycle > 0)
if (BuyingBotBuyCanditatesPerBuyCycle > 0)
addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig);
addNewAuctions(&_AHBplayer, &HordeConfig);
if (BuyingBotBuyCanditatesPerBuyoutCycle > 0)
if (BuyingBotBuyCanditatesPerBuyCycle > 0)
addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig);
}
addNewAuctions(&_AHBplayer, &NeutralConfig);
if (BuyingBotBuyCanditatesPerBuyoutCycle > 0)
if (BuyingBotBuyCanditatesPerBuyCycle > 0)
addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig);
ObjectAccessor::RemoveObject(&_AHBplayer);
@@ -831,7 +865,7 @@ void AuctionHouseBot::InitializeConfiguration()
// Buyer Bot
BuyingBotEnabled = sConfigMgr->GetOption<bool>("AuctionHouseBot.Buyer.Enabled", false);
CyclesBetweenBuyOrSell = sConfigMgr->GetOption<uint32>("AuctionHouseBot.AuctionHouseManagerCyclesBetweenBuyOrSell", 1);
BuyingBotBuyCanditatesPerBuyoutCycle = sConfigMgr->GetOption<uint32>("AuctionHouseBot.Buyer.BuyCanditatesPerBuyoutCycle", 1);
BuyingBotBuyCanditatesPerBuyCycle = sConfigMgr->GetOption<uint32>("AuctionHouseBot.Buyer.BuyCanditatesPerBuyCycle", 1);
BuyingBotAcceptablePriceModifier = sConfigMgr->GetOption<float>("AuctionHouseBot.Buyer.AcceptablePriceModifier", 1);
if (SellingBotEnabled == false && BuyingBotEnabled == false)

View File

@@ -124,7 +124,7 @@ private:
bool BuyingBotEnabled;
int CyclesBetweenBuyOrSell;
int BuyingBotBuyCanditatesPerBuyoutCycle;
int BuyingBotBuyCanditatesPerBuyCycle;
float BuyingBotAcceptablePriceModifier;
std::string AHCharactersGUIDsForQuery;