mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-13 01:08:37 +00:00
Merge pull request #28 from zeb139/improve-ahbot-diversity
Improved AHBot diversity during buy/sell cycles
This commit is contained in:
@@ -36,9 +36,8 @@
|
|||||||
# AuctionHouseBot.GUIDs = 3,4 <- Both characters with GUID 3 and 4
|
# AuctionHouseBot.GUIDs = 3,4 <- Both characters with GUID 3 and 4
|
||||||
#
|
#
|
||||||
# AuctionHouseBot.ItemsPerCycle
|
# AuctionHouseBot.ItemsPerCycle
|
||||||
# How many items to post on the auction house every house update. Items
|
# How many items to post on the auction house every house update.
|
||||||
# in a cycle will be posted by a single randomly selected bot, so keep
|
# Items in a cycle will be posted by a randomly selected bot.
|
||||||
# this value low if you want highly diverse "Seller" names in auction listings.
|
|
||||||
# Default 150
|
# Default 150
|
||||||
#
|
#
|
||||||
# AuctionHouseBot.ListingExpireTimeInSecondsMin
|
# AuctionHouseBot.ListingExpireTimeInSecondsMin
|
||||||
|
|||||||
@@ -827,7 +827,7 @@ uint32 AuctionHouseBot::GetRandomItemIDForListing()
|
|||||||
return ItemCandidatesByItemClassAndQuality[listProportionNode.ItemClassID][listProportionNode.ItemQualityID][urand(0, numOfValidItemsInGroup-1)];
|
return ItemCandidatesByItemClassAndQuality[listProportionNode.ItemClassID][listProportionNode.ItemQualityID][urand(0, numOfValidItemsInGroup-1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuctionHouseBot::AddNewAuctions(Player* AHBplayer, FactionSpecificAuctionHouseConfig *config)
|
void AuctionHouseBot::AddNewAuctions(std::vector<Player*> AHBPlayers, FactionSpecificAuctionHouseConfig *config)
|
||||||
{
|
{
|
||||||
if (!SellingBotEnabled)
|
if (!SellingBotEnabled)
|
||||||
{
|
{
|
||||||
@@ -927,6 +927,8 @@ void AuctionHouseBot::AddNewAuctions(Player* AHBplayer, FactionSpecificAuctionHo
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player* AHBplayer = AHBPlayers[urand(0, AHBPlayers.size() - 1)];
|
||||||
|
|
||||||
Item* item = Item::CreateItem(itemID, 1, AHBplayer);
|
Item* item = Item::CreateItem(itemID, 1, AHBplayer);
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
{
|
{
|
||||||
@@ -982,7 +984,7 @@ void AuctionHouseBot::AddNewAuctions(Player* AHBplayer, FactionSpecificAuctionHo
|
|||||||
LOG_INFO("module", "AHSeller: Added {} items", itemsGenerated);
|
LOG_INFO("module", "AHSeller: Added {} items", itemsGenerated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuctionHouseBot::AddNewAuctionBuyerBotBid(Player* AHBplayer, FactionSpecificAuctionHouseConfig *config)
|
void AuctionHouseBot::AddNewAuctionBuyerBotBid(std::vector<Player*> AHBPlayers, FactionSpecificAuctionHouseConfig *config)
|
||||||
{
|
{
|
||||||
if (!BuyingBotEnabled)
|
if (!BuyingBotEnabled)
|
||||||
{
|
{
|
||||||
@@ -1133,6 +1135,9 @@ void AuctionHouseBot::AddNewAuctionBuyerBotBid(Player* AHBplayer, FactionSpecifi
|
|||||||
LOG_INFO("module", "AHBuyer: Stopped from buying due to 'PreventOverpayingForVendorItems'?: {}", preventedOverpayingForVendorItem);
|
LOG_INFO("module", "AHBuyer: Stopped from buying due to 'PreventOverpayingForVendorItems'?: {}", preventedOverpayingForVendorItem);
|
||||||
LOG_INFO("module", "-------------------------------------------------");
|
LOG_INFO("module", "-------------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player* AHBplayer = AHBPlayers[urand(0, AHBPlayers.size() - 1)];
|
||||||
|
|
||||||
if (doBid)
|
if (doBid)
|
||||||
{
|
{
|
||||||
auto trans = CharacterDatabase.BeginTransaction();
|
auto trans = CharacterDatabase.BeginTransaction();
|
||||||
@@ -1189,32 +1194,37 @@ void AuctionHouseBot::Update()
|
|||||||
LastCycleCount = 0;
|
LastCycleCount = 0;
|
||||||
CyclesBetweenBuyOrSell = urand(CyclesBetweenBuyOrSellMin, CyclesBetweenBuyOrSellMax);
|
CyclesBetweenBuyOrSell = urand(CyclesBetweenBuyOrSellMin, CyclesBetweenBuyOrSellMax);
|
||||||
|
|
||||||
// Randomly select the bot to load, and load it
|
// Load all AH Bot Players
|
||||||
uint32 botIndex = urand(0, AHCharacters.size() - 1);
|
std::vector<Player*> AHBPlayers;
|
||||||
CurrentBotCharGUID = AHCharacters[botIndex].CharacterGUID;
|
for (uint32 botIndex = 0; botIndex <= AHCharacters.size() - 1; ++botIndex)
|
||||||
std::string accountName = "AuctionHouseBot" + std::to_string(AHCharacters[botIndex].AccountID);
|
{
|
||||||
WorldSession _session(AHCharacters[botIndex].AccountID, std::move(accountName), 0, nullptr, SEC_PLAYER, sWorld->getIntConfig(CONFIG_EXPANSION), 0, LOCALE_enUS, 0, false, false, 0);
|
CurrentBotCharGUID = AHCharacters[botIndex].CharacterGUID;
|
||||||
Player _AHBplayer(&_session);
|
std::string accountName = "AuctionHouseBot" + std::to_string(AHCharacters[botIndex].AccountID);
|
||||||
_AHBplayer.Initialize(AHCharacters[botIndex].CharacterGUID);
|
WorldSession _session(AHCharacters[botIndex].AccountID, std::move(accountName), 0, nullptr, SEC_PLAYER, sWorld->getIntConfig(CONFIG_EXPANSION), 0, LOCALE_enUS, 0, false, false, 0);
|
||||||
ObjectAccessor::AddObject(&_AHBplayer);
|
Player* _AHBplayer = new Player(&_session);
|
||||||
|
_AHBplayer->Initialize(AHCharacters[botIndex].CharacterGUID);
|
||||||
|
ObjectAccessor::AddObject(_AHBplayer);
|
||||||
|
AHBPlayers.push_back(_AHBplayer);
|
||||||
|
}
|
||||||
|
|
||||||
// Add New Bids
|
// Add New Bids
|
||||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
||||||
{
|
{
|
||||||
AddNewAuctions(&_AHBplayer, &AllianceConfig);
|
AddNewAuctions(AHBPlayers, &AllianceConfig);
|
||||||
if (BuyingBotBuyCandidatesPerBuyCycleMin > 0)
|
if (BuyingBotBuyCandidatesPerBuyCycleMin > 0)
|
||||||
AddNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig);
|
AddNewAuctionBuyerBotBid(AHBPlayers, &AllianceConfig);
|
||||||
|
|
||||||
AddNewAuctions(&_AHBplayer, &HordeConfig);
|
AddNewAuctions(AHBPlayers, &HordeConfig);
|
||||||
if (BuyingBotBuyCandidatesPerBuyCycleMin > 0)
|
if (BuyingBotBuyCandidatesPerBuyCycleMin > 0)
|
||||||
AddNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig);
|
AddNewAuctionBuyerBotBid(AHBPlayers, &HordeConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddNewAuctions(&_AHBplayer, &NeutralConfig);
|
AddNewAuctions(AHBPlayers, &NeutralConfig);
|
||||||
if (BuyingBotBuyCandidatesPerBuyCycleMin > 0)
|
if (BuyingBotBuyCandidatesPerBuyCycleMin > 0)
|
||||||
AddNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig);
|
AddNewAuctionBuyerBotBid(AHBPlayers, &NeutralConfig);
|
||||||
|
|
||||||
ObjectAccessor::RemoveObject(&_AHBplayer);
|
for (Player* p : AHBPlayers)
|
||||||
|
ObjectAccessor::RemoveObject(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuctionHouseBot::InitializeConfiguration()
|
void AuctionHouseBot::InitializeConfiguration()
|
||||||
|
|||||||
@@ -307,8 +307,8 @@ public:
|
|||||||
ItemTemplate const* GetProducedItemFromRecipe(ItemTemplate const* recipeItemTemplate);
|
ItemTemplate const* GetProducedItemFromRecipe(ItemTemplate const* recipeItemTemplate);
|
||||||
void PopulateItemCandidatesAndProportions();
|
void PopulateItemCandidatesAndProportions();
|
||||||
uint32 GetRandomItemIDForListing();
|
uint32 GetRandomItemIDForListing();
|
||||||
void AddNewAuctions(Player* AHBplayer, FactionSpecificAuctionHouseConfig* config);
|
void AddNewAuctions(std::vector<Player*> AHBPlayers, FactionSpecificAuctionHouseConfig* config);
|
||||||
void AddNewAuctionBuyerBotBid(Player* AHBplayer, FactionSpecificAuctionHouseConfig* config);
|
void AddNewAuctionBuyerBotBid(std::vector<Player*> AHBPlayers, FactionSpecificAuctionHouseConfig* config);
|
||||||
void PopulateVendorItemsPrices();
|
void PopulateVendorItemsPrices();
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
|
|||||||
Reference in New Issue
Block a user