mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-13 01:08:37 +00:00
Fix and re-enable bid support on buyer bot
This commit is contained in:
@@ -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.
|
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.
|
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.
|
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.
|
||||||
|
|
||||||
|
|||||||
@@ -48,14 +48,16 @@ AuctionHouseBot.AuctionHouseManagerCyclesBetweenBuyOrSell = 1
|
|||||||
# BUYER PROPERTIES
|
# BUYER PROPERTIES
|
||||||
# Behavior:
|
# Behavior:
|
||||||
# 1) Determining Items to Buy: Every minute the buyer bot will select
|
# 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.
|
# listed by players as potential purchase items.
|
||||||
# 2) Price Willing to Pay: The buyer bot will use the same item price
|
# 2) Price Willing to Pay: The buyer bot will use the same item price
|
||||||
# calculation the seller bot uses, including the random +/- 25%, and
|
# calculation the seller bot uses, including the random +/- 25%, and
|
||||||
# that calculated price is then multiplied by (AcceptablePriceModifier)
|
# that calculated price is then multiplied by (AcceptablePriceModifier)
|
||||||
# which then becomes the price the buyer will be willing to spend.
|
# 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,
|
# 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.
|
# - The above behavior is replicated on each enabled auction house.
|
||||||
# - If left to default settings, 1 item in each auction house will attempt
|
# - If left to default settings, 1 item in each auction house will attempt
|
||||||
# to be bought from, if the price calculation seems favorable.
|
# to be bought from, if the price calculation seems favorable.
|
||||||
@@ -67,7 +69,7 @@ AuctionHouseBot.AuctionHouseManagerCyclesBetweenBuyOrSell = 1
|
|||||||
# Enable/Disable the buying bot.
|
# Enable/Disable the buying bot.
|
||||||
# Default 0 (disabled)
|
# Default 0 (disabled)
|
||||||
#
|
#
|
||||||
# AuctionHouseBot.Buyer.BuyCanditatesPerBuyoutCycle
|
# AuctionHouseBot.Buyer.BuyCanditatesPerBuyCycle
|
||||||
# How many to items to price and attempt to buy. Note, this number of
|
# 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,
|
# 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
|
# 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.Enabled = 0
|
||||||
AuctionHouseBot.Buyer.BuyCanditatesPerBuyoutCycle = 1
|
AuctionHouseBot.Buyer.BuyCanditatesPerBuyCycle = 1
|
||||||
AuctionHouseBot.Buyer.AcceptablePriceModifier = 1
|
AuctionHouseBot.Buyer.AcceptablePriceModifier = 1
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "AuctionHouseMgr.h"
|
#include "AuctionHouseMgr.h"
|
||||||
#include "AuctionHouseBot.h"
|
#include "AuctionHouseBot.h"
|
||||||
|
#include "AuctionHouseSearcher.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
@@ -37,7 +38,7 @@ AuctionHouseBot::AuctionHouseBot() :
|
|||||||
SellingBotEnabled(false),
|
SellingBotEnabled(false),
|
||||||
BuyingBotEnabled(false),
|
BuyingBotEnabled(false),
|
||||||
CyclesBetweenBuyOrSell(1),
|
CyclesBetweenBuyOrSell(1),
|
||||||
BuyingBotBuyCanditatesPerBuyoutCycle(1),
|
BuyingBotBuyCanditatesPerBuyCycle(1),
|
||||||
BuyingBotAcceptablePriceModifier(1),
|
BuyingBotAcceptablePriceModifier(1),
|
||||||
AHCharactersGUIDsForQuery(""),
|
AHCharactersGUIDsForQuery(""),
|
||||||
ItemsPerCycle(75),
|
ItemsPerCycle(75),
|
||||||
@@ -675,13 +676,13 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player* AHBplayer, AHBConfig *con
|
|||||||
possibleBids.push_back(tmpdata);
|
possibleBids.push_back(tmpdata);
|
||||||
}while (result->NextRow());
|
}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.
|
// Do we have anything to bid? If not, stop here.
|
||||||
if (possibleBids.empty())
|
if (possibleBids.empty())
|
||||||
{
|
{
|
||||||
//if (debug_Out) sLog->outError( "AHBuyer: I have no items to bid on.");
|
//if (debug_Out) sLog->outError( "AHBuyer: I have no items to bid on.");
|
||||||
count = BuyingBotBuyCanditatesPerBuyoutCycle;
|
count = BuyingBotBuyCanditatesPerBuyCycle;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,15 +717,20 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player* AHBplayer, AHBConfig *con
|
|||||||
uint64 discardBidPrice = 0;
|
uint64 discardBidPrice = 0;
|
||||||
calculateItemValue(prototype, discardBidPrice, willingToSpendPerItemPrice);
|
calculateItemValue(prototype, discardBidPrice, willingToSpendPerItemPrice);
|
||||||
willingToSpendPerItemPrice = (uint64)((float)willingToSpendPerItemPrice * BuyingBotAcceptablePriceModifier);
|
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;
|
bool doBuyout = false;
|
||||||
uint32 minBuyoutPrice = 0;
|
bool doBid = false;
|
||||||
if (auction->buyout != 0 && willingToSpendForStackPrice >= auction->buyout)
|
|
||||||
doBuyout = true;
|
|
||||||
|
|
||||||
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)
|
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: Buyout: {}", auction->buyout);
|
||||||
LOG_INFO("module", "AHBuyer: Deposit: {}", auction->deposit);
|
LOG_INFO("module", "AHBuyer: Deposit: {}", auction->deposit);
|
||||||
LOG_INFO("module", "AHBuyer: Expire Time: {}", uint32(auction->expire_time));
|
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: Willing To Pay For Stack Price: {}", willingToPayForStackPrice);
|
||||||
LOG_INFO("module", "AHBuyer: Minimum Buyout Price: {}", minBuyoutPrice);
|
|
||||||
LOG_INFO("module", "AHBuyer: Item GUID: {}", auction->item_guid.ToString());
|
LOG_INFO("module", "AHBuyer: Item GUID: {}", auction->item_guid.ToString());
|
||||||
LOG_INFO("module", "AHBuyer: Item Template: {}", auction->item_template);
|
LOG_INFO("module", "AHBuyer: Item Template: {}", auction->item_template);
|
||||||
LOG_INFO("module", "AHBuyer: Item Info:");
|
LOG_INFO("module", "AHBuyer: Item Info:");
|
||||||
@@ -753,23 +758,52 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player* AHBplayer, AHBConfig *con
|
|||||||
LOG_INFO("module", "-------------------------------------------------");
|
LOG_INFO("module", "-------------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto trans = CharacterDatabase.BeginTransaction();
|
if (doBid)
|
||||||
|
|
||||||
if ((auction->bidder) && (AHBplayer->GetGUID() != auction->bidder))
|
|
||||||
{
|
{
|
||||||
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, AHBplayer, trans);
|
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);
|
||||||
}
|
}
|
||||||
auction->bidder = AHBplayer->GetGUID();
|
else if (doBuyout)
|
||||||
auction->bid = auction->buyout;
|
{
|
||||||
|
auto trans = CharacterDatabase.BeginTransaction();
|
||||||
|
|
||||||
// Send mails to buyer & seller
|
if ((auction->bidder) && (AHBplayer->GetGUID() != auction->bidder))
|
||||||
sAuctionMgr->SendAuctionSuccessfulMail(auction, trans);
|
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, AHBplayer, trans);
|
||||||
sAuctionMgr->SendAuctionWonMail(auction, trans);
|
auction->bidder = AHBplayer->GetGUID();
|
||||||
auction->DeleteFromDB(trans);
|
auction->bid = auction->buyout;
|
||||||
|
|
||||||
sAuctionMgr->RemoveAItem(auction->item_guid);
|
// Send mails to buyer & seller
|
||||||
auctionHouse->RemoveAuction(auction);
|
sAuctionMgr->SendAuctionSuccessfulMail(auction, trans);
|
||||||
CharacterDatabase.CommitTransaction(trans);
|
sAuctionMgr->SendAuctionWonMail(auction, trans);
|
||||||
|
auction->DeleteFromDB(trans);
|
||||||
|
|
||||||
|
sAuctionMgr->RemoveAItem(auction->item_guid);
|
||||||
|
auctionHouse->RemoveAuction(auction);
|
||||||
|
CharacterDatabase.CommitTransaction(trans);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -800,16 +834,16 @@ void AuctionHouseBot::Update()
|
|||||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
||||||
{
|
{
|
||||||
addNewAuctions(&_AHBplayer, &AllianceConfig);
|
addNewAuctions(&_AHBplayer, &AllianceConfig);
|
||||||
if (BuyingBotBuyCanditatesPerBuyoutCycle > 0)
|
if (BuyingBotBuyCanditatesPerBuyCycle > 0)
|
||||||
addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig);
|
addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig);
|
||||||
|
|
||||||
addNewAuctions(&_AHBplayer, &HordeConfig);
|
addNewAuctions(&_AHBplayer, &HordeConfig);
|
||||||
if (BuyingBotBuyCanditatesPerBuyoutCycle > 0)
|
if (BuyingBotBuyCanditatesPerBuyCycle > 0)
|
||||||
addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig);
|
addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
addNewAuctions(&_AHBplayer, &NeutralConfig);
|
addNewAuctions(&_AHBplayer, &NeutralConfig);
|
||||||
if (BuyingBotBuyCanditatesPerBuyoutCycle > 0)
|
if (BuyingBotBuyCanditatesPerBuyCycle > 0)
|
||||||
addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig);
|
addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig);
|
||||||
|
|
||||||
ObjectAccessor::RemoveObject(&_AHBplayer);
|
ObjectAccessor::RemoveObject(&_AHBplayer);
|
||||||
@@ -831,7 +865,7 @@ void AuctionHouseBot::InitializeConfiguration()
|
|||||||
// Buyer Bot
|
// Buyer Bot
|
||||||
BuyingBotEnabled = sConfigMgr->GetOption<bool>("AuctionHouseBot.Buyer.Enabled", false);
|
BuyingBotEnabled = sConfigMgr->GetOption<bool>("AuctionHouseBot.Buyer.Enabled", false);
|
||||||
CyclesBetweenBuyOrSell = sConfigMgr->GetOption<uint32>("AuctionHouseBot.AuctionHouseManagerCyclesBetweenBuyOrSell", 1);
|
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);
|
BuyingBotAcceptablePriceModifier = sConfigMgr->GetOption<float>("AuctionHouseBot.Buyer.AcceptablePriceModifier", 1);
|
||||||
|
|
||||||
if (SellingBotEnabled == false && BuyingBotEnabled == false)
|
if (SellingBotEnabled == false && BuyingBotEnabled == false)
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ private:
|
|||||||
bool BuyingBotEnabled;
|
bool BuyingBotEnabled;
|
||||||
int CyclesBetweenBuyOrSell;
|
int CyclesBetweenBuyOrSell;
|
||||||
|
|
||||||
int BuyingBotBuyCanditatesPerBuyoutCycle;
|
int BuyingBotBuyCanditatesPerBuyCycle;
|
||||||
float BuyingBotAcceptablePriceModifier;
|
float BuyingBotAcceptablePriceModifier;
|
||||||
|
|
||||||
std::string AHCharactersGUIDsForQuery;
|
std::string AHCharactersGUIDsForQuery;
|
||||||
|
|||||||
Reference in New Issue
Block a user