Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selling of items with zero value as buy/sell price #113

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions conf/mod_ahbot.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
# 2 = shorts, auctions lasts within an hour
# Default 1
#
# AuctionHouseBot.SellZeroPriceItems
# Sell items which does not have a price associated (depending also on UseBuyPriceForSeller) by
# proposing a price which depends on the item level and its rarity class.
# Default 0 (disabled)
#
###############################################################################

AuctionHouseBot.DEBUG = 0
Expand All @@ -117,6 +122,7 @@ AuctionHouseBot.ConsiderOnlyBotAuctions = 0
AuctionHouseBot.DuplicatesCount = 0
AuctionHouseBot.DivisibleStacks = 0
AuctionHouseBot.ElapsingTimeClass = 1
AuctionHouseBot.SellZeroPriceItems = 0

###############################################################################
# AUCTION HOUSE BOT FILTERS PART 1
Expand Down
25 changes: 24 additions & 1 deletion src/AuctionHouseBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,29 @@ void AuctionHouseBot::Sell(Player* AHBplayer, AHBConfig* config)
}
}

//
// If the buyout price is still zero, determine a random one using the item level
//

if (config->SellZeroPriceItems)
{
if (buyoutPrice == 0)
{
buyoutPrice = urand(prototype->ItemLevel, prototype->ItemLevel + 10) * 10;

if (buyoutPrice <= 0)
{
if (config->DebugOutSeller)
{
LOG_ERROR("module", "AHBot [{}]: Could not determine a price for item {} of quality {} (min={}, max={})", _id, itemID, prototype->Quality, config->GetMinPrice(prototype->Quality), config->GetMaxPrice(prototype->Quality));
}

item->RemoveFromUpdateQueueOf(AHBplayer);
continue;
}
}
}

buyoutPrice = buyoutPrice * urand(config->GetMinPrice(prototype->Quality), config->GetMaxPrice(prototype->Quality));
buyoutPrice = buyoutPrice / 100;

Expand Down Expand Up @@ -1450,5 +1473,5 @@ void AuctionHouseBot::Initialize(AHBConfig* allianceConfig, AHBConfig* hordeConf
// Done
//

LOG_INFO("module", "AHBot [{}]: initialization complete", uint32(_id));
LOG_INFO("module", "AHBot [{}]: initialization complete\n", uint32(_id));
}
83 changes: 47 additions & 36 deletions src/AuctionHouseBotConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ AHBConfig::AHBConfig(uint32 ahid, AHBConfig* conf)
BuyMethod = conf->BuyMethod;
SellMethod = conf->SellMethod;
ConsiderOnlyBotAuctions = conf->ConsiderOnlyBotAuctions;
SellZeroPriceItems = conf->SellZeroPriceItems;
ItemsPerCycle = conf->ItemsPerCycle;
Vendor_Items = conf->Vendor_Items;
Loot_Items = conf->Loot_Items;
Expand Down Expand Up @@ -510,6 +511,7 @@ void AHBConfig::Reset()
SellMethod = false;
SellAtMarketPrice = false;
ConsiderOnlyBotAuctions = false;
SellZeroPriceItems = false;
ItemsPerCycle = 200;

Vendor_Items = false;
Expand Down Expand Up @@ -2014,6 +2016,8 @@ uint64 AHBConfig::GetItemPrice(uint32 id)

void AHBConfig::Initialize(std::set<uint32> botsIds)
{
LOG_INFO("module", "Initializing configuration for AH {}...", AHID);

InitializeFromFile();
InitializeFromSql(botsIds);
InitializeBins();
Expand Down Expand Up @@ -2044,6 +2048,7 @@ void AHBConfig::InitializeFromFile()
DivisibleStacks = sConfigMgr->GetOption<bool> ("AuctionHouseBot.DivisibleStacks" , false);
ElapsingTimeClass = sConfigMgr->GetOption<uint32>("AuctionHouseBot.DuplicatesCount" , 1);
ConsiderOnlyBotAuctions = sConfigMgr->GetOption<bool> ("AuctionHouseBot.ConsiderOnlyBotAuctions", false);
SellZeroPriceItems = sConfigMgr->GetOption<bool> ("AuctionHouseBot.SellZeroPriceItems" , false);
ItemsPerCycle = sConfigMgr->GetOption<uint32>("AuctionHouseBot.ItemsPerCycle" , 200);

//
Expand Down Expand Up @@ -2590,31 +2595,34 @@ void AHBConfig::InitializeBins()
}

//
// Exclude items with no possible price
// Exclude items that does not have a price
//

if (SellMethod)
if (!SellZeroPriceItems)
{
if (itr->second.BuyPrice == 0)
if (SellMethod)
{
continue;
if (itr->second.BuyPrice == 0)
{
continue;
}
}
}
else
{
if (itr->second.SellPrice == 0)
else
{
continue;
if (itr->second.SellPrice == 0)
{
continue;
}
}
}

//
// Exclude items with no costs associated, in any case
//
//
// Exclude items with no costs associated, in any case
//

if ((itr->second.BuyPrice == 0) && (itr->second.SellPrice == 0))
{
continue;
if ((itr->second.BuyPrice == 0) && (itr->second.SellPrice == 0))
{
continue;
}
}

//
Expand Down Expand Up @@ -3329,8 +3337,6 @@ void AHBConfig::InitializeBins()
// Perform reporting and the last check: if no items are disabled or in the whitelist clear the bin making the selling useless
//

LOG_INFO("module", "AHBot: Configuration for ah {}", AHID);

if (SellerWhiteList.size() == 0)
{
if (DisableItemStore.size() == 0)
Expand All @@ -3357,27 +3363,32 @@ void AHBConfig::InitializeBins()
return;
}

LOG_INFO("module", "AHBot: {} disabled items", uint32(DisableItemStore.size()));
LOG_INFO("module", ">> Using all compatible items ({} disabled)", uint32(DisableItemStore.size()));
}
else
{
LOG_INFO("module", "AHBot: Using a whitelist of {} items", uint32(SellerWhiteList.size()));
}

LOG_INFO("module", "AHBot: loaded {} grey trade goods", uint32(GreyTradeGoodsBin.size()));
LOG_INFO("module", "AHBot: loaded {} white trade goods", uint32(WhiteTradeGoodsBin.size()));
LOG_INFO("module", "AHBot: loaded {} green trade goods", uint32(GreenTradeGoodsBin.size()));
LOG_INFO("module", "AHBot: loaded {} blue trade goods", uint32(BlueTradeGoodsBin.size()));
LOG_INFO("module", "AHBot: loaded {} purple trade goods", uint32(PurpleTradeGoodsBin.size()));
LOG_INFO("module", "AHBot: loaded {} orange trade goods", uint32(OrangeTradeGoodsBin.size()));
LOG_INFO("module", "AHBot: loaded {} yellow trade goods", uint32(YellowTradeGoodsBin.size()));
LOG_INFO("module", "AHBot: loaded {} grey items" , uint32(GreyItemsBin.size()));
LOG_INFO("module", "AHBot: loaded {} white items" , uint32(WhiteItemsBin.size()));
LOG_INFO("module", "AHBot: loaded {} green items" , uint32(GreenItemsBin.size()));
LOG_INFO("module", "AHBot: loaded {} blue items" , uint32(BlueItemsBin.size()));
LOG_INFO("module", "AHBot: loaded {} purple items" , uint32(PurpleItemsBin.size()));
LOG_INFO("module", "AHBot: loaded {} orange items" , uint32(OrangeItemsBin.size()));
LOG_INFO("module", "AHBot: loaded {} yellow items" , uint32(YellowItemsBin.size()));
LOG_INFO("module", ">> Using a whitelist of {} items", uint32(SellerWhiteList.size()));
}

LOG_INFO("module", ">>\tgrey\twhite\tgreen\tblue\tpurple\torange\tyellow", uint32(GreyTradeGoodsBin.size()));

LOG_INFO("module", ">>\t{}\t{}\t{}\t{}\t{}\t{}\t{}\ttrade goods",
uint32(GreyTradeGoodsBin.size()),
uint32(WhiteTradeGoodsBin.size()),
uint32(GreenTradeGoodsBin.size()),
uint32(BlueTradeGoodsBin.size()),
uint32(PurpleTradeGoodsBin.size()),
uint32(OrangeTradeGoodsBin.size()),
uint32(YellowTradeGoodsBin.size()));

LOG_INFO("module", ">>\t{}\t{}\t{}\t{}\t{}\t{}\t{}\titems\n",
uint32(GreyItemsBin.size()),
uint32(WhiteItemsBin.size()),
uint32(GreenItemsBin.size()),
uint32(BlueItemsBin.size()),
uint32(PurpleItemsBin.size()),
uint32(OrangeItemsBin.size()),
uint32(YellowItemsBin.size()));
}

std::set<uint32> AHBConfig::getCommaSeparatedIntegers(std::string text)
Expand Down
1 change: 1 addition & 0 deletions src/AuctionHouseBotConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class AHBConfig
bool BuyMethod;
bool SellMethod;
bool SellAtMarketPrice;
bool SellZeroPriceItems;
uint32 MarketResetThreshold;
bool ConsiderOnlyBotAuctions;
uint32 ItemsPerCycle;
Expand Down
2 changes: 0 additions & 2 deletions src/AuctionHouseBotWorldScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ void AHBot_WorldScript::OnBeforeConfigLoad(bool reload)

void AHBot_WorldScript::OnStartup()
{
LOG_INFO("server.loading", "Initialize AuctionHouseBot...");

//
// Initialize the configuration (done only once at startup)
//
Expand Down