diff --git a/doc/ahbot/README.md b/doc/ahbot/README.md index 359892dfaa..a5eae7c04f 100644 --- a/doc/ahbot/README.md +++ b/doc/ahbot/README.md @@ -8,7 +8,12 @@ Seller.cpp has a 3-line hook. Everything stays off unless `AuctionHouseBot.Selle Filter (`AuctionHouseBot.Vanilla.Only = 1`): no gems/glyphs, no later-expansion items, quality up to epic, required level <= `Vanilla.MaxReqLevel` (60), item level <= `Vanilla.MaxItemLevel` (100). Force-include list (`AuctionHouseBot.forceIncludeItems`) bypasses it. Prices come from vendor buy/sell price x the -`AuctionHouseBot.*.Price.Ratio` keys. Per-bot posting/buying lives separately in +`AuctionHouseBot.*.Price.Ratio` keys. `AuctionHouseBot.Items.Crafted = 1` (presets) also lists items a profession recipe makes, which are in no loot or vendor +list and so were dropped by `Items.Misc = 0`. `AuctionHouseBot.Class.WeightByPoolSize = 1` (presets) shares each quality's amount by class priority times +the number of different items in that class, so greens and blues are mostly gear instead of the same few bags, arrows and trade goods. +`AuctionHouseBot.Vanilla.ValueCurve = 1` (presets) prices by item level squared x quality (1/2/15/50/150 copper for gray to epic) +x class (gear, bags, trade goods 100%, recipes and misc 50%, consumables 25%, ammo and reagents vendor price only), never below +vendor price; the buyer's fair price uses the same value. The 70532 data gives loot-only goods such as essences a 1 copper vendor price. Per-bot posting/buying lives separately in `Bot/States/Rules/AuctionRules.cpp`. Not built or run in the cloud (no full toolchain): first test is on the PC. Check the startup log for diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp index 35fb6eed45..5385ac7e7a 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp @@ -170,6 +170,7 @@ void AuctionBotConfig::GetConfigFromFile() SetConfig(CONFIG_AHBOT_ITEMS_VENDOR, "AuctionHouseBot.Items.Vendor", false); SetConfig(CONFIG_AHBOT_ITEMS_LOOT, "AuctionHouseBot.Items.Loot", true); SetConfig(CONFIG_AHBOT_ITEMS_MISC, "AuctionHouseBot.Items.Misc", false); + SetConfig(CONFIG_AHBOT_ITEMS_CRAFTED, "AuctionHouseBot.Items.Crafted", false); SetConfig(CONFIG_AHBOT_BIND_NO, "AuctionHouseBot.Bind.No", true); SetConfig(CONFIG_AHBOT_BIND_PICKUP, "AuctionHouseBot.Bind.Pickup", false); @@ -177,6 +178,7 @@ void AuctionBotConfig::GetConfigFromFile() SetConfig(CONFIG_AHBOT_BIND_USE, "AuctionHouseBot.Bind.Use", true); SetConfig(CONFIG_AHBOT_BIND_QUEST, "AuctionHouseBot.Bind.Quest", false); SetConfig(CONFIG_AHBOT_LOCKBOX_ENABLED, "AuctionHouseBot.LockBox.Enabled", false); + SetConfig(CONFIG_AHBOT_CLASS_WEIGHT_BY_POOL, "AuctionHouseBot.Class.WeightByPoolSize", false); SetConfig(CONFIG_AHBOT_BUYPRICE_SELLER, "AuctionHouseBot.BuyPrice.Seller", false); diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.h b/src/server/game/AuctionHouseBot/AuctionHouseBot.h index c82286b207..f989035b9e 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBot.h +++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.h @@ -171,6 +171,7 @@ enum AuctionBotConfigBoolValues CONFIG_AHBOT_ITEMS_VENDOR, CONFIG_AHBOT_ITEMS_LOOT, CONFIG_AHBOT_ITEMS_MISC, + CONFIG_AHBOT_ITEMS_CRAFTED, CONFIG_AHBOT_BIND_NO, CONFIG_AHBOT_BIND_PICKUP, CONFIG_AHBOT_BIND_EQUIP, @@ -180,6 +181,7 @@ enum AuctionBotConfigBoolValues CONFIG_AHBOT_SELLER_ENABLED, CONFIG_AHBOT_BUYER_ENABLED, CONFIG_AHBOT_LOCKBOX_ENABLED, + CONFIG_AHBOT_CLASS_WEIGHT_BY_POOL, CONFIG_AHBOT_CLASS_CONSUMABLE_ALLOW_ZERO, CONFIG_AHBOT_CLASS_CONTAINER_ALLOW_ZERO, CONFIG_AHBOT_CLASS_WEAPON_ALLOW_ZERO, diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp index ec555b4dbd..fd6940ebdc 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp @@ -85,6 +85,8 @@ bool AuctionBotBuyer::Update(AuctionHouseType houseType) BuyerConfiguration& config = _houseConfig[houseType]; uint32 eligibleItems = GetItemInformation(config); + AuctionBotBuyerPolicy::NoteCycle(eligibleItems); + AuctionBotBuyerPolicy::LogCounters(); if (eligibleItems) { // Prepare list of items to bid or buy - remove old items @@ -351,12 +353,19 @@ void AuctionBotBuyer::BuyAndBidItems(BuyerConfiguration& config) } // never pay above the price cap (AuctionHouseBot.Buyer.MaxPriceMultiplier) + bool capped = false; if (uint64 cap = AuctionBotBuyerPolicy::MaxUnitPrice(auction)) { if (AuctionBotBuyerPolicy::PerItemPrice(auction, auction->BuyoutOrUnitPrice) > cap) + { + capped = capped || successBuy; successBuy = false; + } if (AuctionBotBuyerPolicy::PerItemPrice(auction, bidPrice) > cap) + { + capped = capped || successBid; successBid = false; + } } // If roll bidding succesfully and bid price is above buyout -> buyout @@ -370,9 +379,15 @@ void AuctionBotBuyer::BuyAndBidItems(BuyerConfiguration& config) AuctionBotBuyerPolicy::RecordBuy(auction, AuctionBotBuyerPolicy::TotalPrice(auction, auction->BuyoutOrUnitPrice), AuctionBotConfig::GetHouseTypeName(config.GetHouseType())); BuyEntry(auction, auctionHouse); // buyout + AuctionBotBuyerPolicy::Note(AuctionBotBuyerPolicy::Outcome::Bought); } else if (successBid) + { PlaceBidToEntry(auction, auctionHouse, bidPrice); // bid + AuctionBotBuyerPolicy::Note(AuctionBotBuyerPolicy::Outcome::Bid); + } + else + AuctionBotBuyerPolicy::Note(capped ? AuctionBotBuyerPolicy::Outcome::OverCap : AuctionBotBuyerPolicy::Outcome::LostRoll); itr->second.LastChecked = now; --cycles; diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyerPolicy.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyerPolicy.cpp index dd33567553..6baafa9121 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyerPolicy.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyerPolicy.cpp @@ -16,6 +16,7 @@ */ #include "AuctionHouseBotBuyerPolicy.h" +#include "AuctionHouseBotVanilla.h" #include "AuctionHouseMgr.h" #include "Common.h" #include "Config.h" @@ -48,6 +49,13 @@ namespace time_t _hourStart = 0; uint32 _boughtThisHour = 0; + struct Counters + { + uint32 fresh = 0, hourLimit = 0, dayLimit = 0, bought = 0, bid = 0, lostRoll = 0, overCap = 0; + uint32 cycles = 0, emptyCycles = 0; + } _counters; + time_t _countersLogged = 0; + void RollWindows(time_t now) { if (!_dayStart || now - _dayStart >= DAY) @@ -69,7 +77,8 @@ namespace { uint64 buy = proto->GetBuyPrice() / std::max(1, proto->GetBuyCount()); uint64 sell = uint64(proto->GetSellPrice()) * 4; - return std::max({ buy, sell, SILVER }); + // the seller's market value when AuctionHouseBot.Vanilla.ValueCurve is on, so the buyer pays what the bot asks + return std::max({ buy, sell, AuctionBotVanilla::UnitValue(proto), SILVER }); } } @@ -96,14 +105,60 @@ bool Eligible(AuctionPosting const* auction) RollWindows(now); if (_maxBuysPerHour && _boughtThisHour >= _maxBuysPerHour) + { + Note(Outcome::SkippedHourLimit); return false; + } if (_dailyBudget && _spentToday >= _dailyBudget) + { + Note(Outcome::SkippedDayLimit); return false; + } // Leave new listings alone for a while; the delay differs per listing but never changes for one. uint32 const span = _maxDelay - _minDelay; uint32 const delay = _minDelay + (span ? (auction->Id * 2654435761u) % (span + 1) : 0); - return now - time_t(std::chrono::duration_cast(auction->StartTime.time_since_epoch()).count()) >= time_t(delay); + if (now - time_t(std::chrono::duration_cast(auction->StartTime.time_since_epoch()).count()) >= time_t(delay)) + return true; + Note(Outcome::SkippedFresh); + return false; +} + +void Note(Outcome outcome) +{ + switch (outcome) + { + case Outcome::SkippedFresh: ++_counters.fresh; break; + case Outcome::SkippedHourLimit: ++_counters.hourLimit; break; + case Outcome::SkippedDayLimit: ++_counters.dayLimit; break; + case Outcome::Bought: ++_counters.bought; break; + case Outcome::Bid: ++_counters.bid; break; + case Outcome::LostRoll: ++_counters.lostRoll; break; + case Outcome::OverCap: ++_counters.overCap; break; + } +} + +void NoteCycle(uint32 eligible) +{ + ++_counters.cycles; + if (!eligible) + ++_counters.emptyCycles; +} + +void LogCounters() +{ + time_t const now = GameTime::GetGameTime(); + if (!_countersLogged) + _countersLogged = now; + if (now - _countersLogged < 10 * MINUTE) + return; + _countersLogged = now; + + Counters const c = _counters; + _counters = Counters(); + uint32 const fail = c.lostRoll + c.overCap; + TC_LOG_INFO("ahbot", "[ahbot] buyouts attempts={} ok={} fail={} (lost_roll={} over_cap={}) bids={} skipped(fresh={} hour_limit={} day_limit={}) cycles={} empty_cycles={}", + c.bought + c.bid + fail, c.bought, fail, c.lostRoll, c.overCap, c.bid, c.fresh, c.hourLimit, c.dayLimit, c.cycles, c.emptyCycles); } bool FairPricingEnabled() @@ -161,7 +216,7 @@ void RecordBuy(AuctionPosting const* auction, uint64 totalPrice, char const* hou ++_boughtToday; ++_boughtThisHour; - TC_LOG_DEBUG("ahbot", "AHBot: buy {} x{} for {:.2f}g in {} (today: {} buys, {:.2f}g)", + TC_LOG_INFO("ahbot", "AHBot: buy {} x{} for {:.2f}g in {} (today: {} buys, {:.2f}g)", auction->Items[0]->GetTemplate()->GetName(sWorld->GetDefaultDbcLocale()), auction->GetTotalItemCount(), float(totalPrice) / float(GOLD), house, _boughtToday, float(_spentToday) / float(GOLD)); } diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyerPolicy.h b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyerPolicy.h index cac51653a1..12d009eb1c 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyerPolicy.h +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyerPolicy.h @@ -55,6 +55,25 @@ namespace AuctionBotBuyerPolicy // Updates the hourly/daily counters after a buyout. TC_GAME_API void RecordBuy(AuctionPosting const* auction, uint64 totalPrice, char const* house); + // What became of one auction the buyer looked at, for the periodic counter line. + enum class Outcome : uint8 + { + SkippedFresh, // the listing is too new (Buyer.MinDelay / MaxDelay) + SkippedHourLimit, // Buyer.MaxBuysPerHour is spent + SkippedDayLimit, // Buyer.DailyBudgetGold is spent + Bought, // buyout done + Bid, // a bid was placed instead + LostRoll, // rolled for a buyout and a bid, neither came up + OverCap // a roll came up but the price is above Buyer.MaxPriceMultiplier + }; + TC_GAME_API void Note(Outcome outcome); + + // One buyer cycle ran for a house, with `eligible` listings the buyer may buy or bid on (0 = nothing to look at). + TC_GAME_API void NoteCycle(uint32 eligible); + + // Every ten minutes: one info line with the counters since the last one, then they start again. + TC_GAME_API void LogCounters(); + // Buyer spend today and limits, for .ahbot stats TC_GAME_API std::string Describe(); } diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp index 2378e1b81f..06914c3b0b 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp @@ -26,7 +26,10 @@ #include "Containers.h" #include "ObjectMgr.h" #include "Random.h" +#include "SpellInfo.h" +#include "SpellMgr.h" #include +#include #include AuctionBotSeller::AuctionBotSeller() @@ -44,6 +47,7 @@ bool AuctionBotSeller::Initialize() { std::unordered_set npcItems; std::unordered_set lootItems; + std::unordered_set craftedItems; std::unordered_set includeItems; std::unordered_set excludeItems; @@ -107,6 +111,28 @@ bool AuctionBotSeller::Initialize() } TC_LOG_DEBUG("ahbot", "Loot filter has {} items", lootItems.size()); + + // AuctionHouseBot.Items.Crafted: items a profession recipe makes (Lesser Magic Wand, crafted gear) are in no loot or + // vendor table, so Items.Misc = 0 dropped every one of them + if (sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ITEMS_CRAFTED)) + { + for (SkillLineAbilityEntry const* ability : sSkillLineAbilityStore) + { + SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(ability->SkillLine); + if (!skillLine || (skillLine->CategoryID != SKILL_CATEGORY_PROFESSION && skillLine->CategoryID != SKILL_CATEGORY_SECONDARY)) + continue; + + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(ability->Spell, DIFFICULTY_NONE); + if (!spellInfo) + continue; + + for (SpellEffectInfo const& effect : spellInfo->GetEffects()) + if (effect.IsEffect(SPELL_EFFECT_CREATE_ITEM) && effect.ItemType) + craftedItems.insert(effect.ItemType); + } + } + + TC_LOG_DEBUG("ahbot", "Crafted filter has {} items", craftedItems.size()); TC_LOG_DEBUG("ahbot", "Sorting and cleaning items for AHBot seller..."); uint32 itemsAdded = 0; @@ -229,8 +255,9 @@ bool AuctionBotSeller::Initialize() { bool const isVendorItem = npcItems.count(itemId) > 0; bool const isLootItem = lootItems.count(itemId) > 0; + bool const isCraftedItem = craftedItems.count(itemId) > 0; - if (!isLootItem && !isVendorItem) + if (!isLootItem && !isVendorItem && !isCraftedItem) continue; } @@ -453,6 +480,15 @@ void AuctionBotSeller::LoadItemsQuantity(SellerConfiguration& config) return sAuctionBotConfig->GetConfig(index); }; + // AuctionHouseBot.Class.WeightByPoolSize: a class's share also grows with its number of different items, + // so a few green bags or arrows are not listed dozens of times each while green gear gets few slots + bool const weightByPool = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEIGHT_BY_POOL); + auto getWeight = [&](uint32 quality, uint32 itemClass) -> uint32 + { + uint32 prio = getPriorityForClass(itemClass); + return weightByPool ? prio * uint32(_itemPool[quality][itemClass].size()) : prio; + }; + std::vector totalPrioPerQuality(MAX_AUCTION_QUALITY); for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j) { @@ -462,7 +498,7 @@ void AuctionBotSeller::LoadItemsQuantity(SellerConfiguration& config) if (_itemPool[j][i].empty()) continue; - totalPrioPerQuality[j] += getPriorityForClass(i); + totalPrioPerQuality[j] += getWeight(j, i); } } @@ -474,7 +510,7 @@ void AuctionBotSeller::LoadItemsQuantity(SellerConfiguration& config) for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i) { - uint32 classPrio = getPriorityForClass(i); + uint32 classPrio = getWeight(j, i); if (_itemPool[j][i].empty()) classPrio = 0; @@ -532,14 +568,32 @@ void AuctionBotSeller::LoadSellerValues(SellerConfiguration& config) // Fill ItemInfos object with real content of AH. uint32 AuctionBotSeller::SetStat(SellerConfiguration& config) { - AllItemsArray itemsSaved; + AllItemsArray itemsSaved = {}; + std::map, uint32> bonusQualityDiffers; // (item quality, bonus quality) -> listings AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsById(sAuctionBotConfig->GetAuctionHouseId(config.GetHouseType())); for (auto itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr) { AuctionPosting const* auctionEntry = &itr->second; if (auctionEntry->Owner.IsEmpty() || sAuctionBotConfig->IsBotChar(auctionEntry->Owner)) // Add only ahbot items - ++itemsSaved[auctionEntry->Items[0]->GetQuality()][auctionEntry->Bucket->ItemClass]; + { + // count by the template, the same key _itemPool and the listing were chosen by: a bonus list + // can change the item's quality, and such a listing was then never counted in its own slot + ItemTemplate const* proto = auctionEntry->Items[0]->GetTemplate(); + if (proto->GetQuality() >= MAX_AUCTION_QUALITY || proto->GetClass() >= MAX_ITEM_CLASS) + continue; + if (auctionEntry->Items[0]->GetQuality() != proto->GetQuality()) + ++bonusQualityDiffers[{ proto->GetQuality(), auctionEntry->Items[0]->GetQuality() }]; + ++itemsSaved[proto->GetQuality()][proto->GetClass()]; + } + } + + if (!bonusQualityDiffers.empty() && !_bonusQualityReported) + { + for (auto const& [qualities, listings] : bonusQualityDiffers) + TC_LOG_INFO("ahbot", "AHBot: {} listings in the {} house: item quality {}, bonus list quality {}", + listings, AuctionBotConfig::GetHouseTypeName(config.GetHouseType()), qualities.first, qualities.second); + _bonusQualityReported = true; } uint32 count = 0; @@ -625,6 +679,8 @@ void AuctionBotSeller::SetPricesOfItem(ItemTemplate const* itemProto, SellerConf buyPrice = sellPrice; float basePriceFloat = buyPrice * stackCount / (itemProto->GetClass() == 6 ? 200.0f : static_cast(itemProto->GetBuyCount())); + if (uint64 unitValue = AuctionBotVanilla::UnitValue(itemProto)) + basePriceFloat = float(unitValue) * stackCount; basePriceFloat *= priceRatio; float range = basePriceFloat * 0.04f; @@ -837,7 +893,7 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config) AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsById(sAuctionBotConfig->GetAuctionHouseId(config.GetHouseType())); ItemsToSellArray itemsToSell; - AllItemsArray allItems; + AllItemsArray allItems = {}; // Main loop // getRandomArray will give what categories of items should be added (return true if there is at least 1 items missed) CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); @@ -871,7 +927,7 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config) if (!item) { TC_LOG_ERROR("ahbot", "AHBot: Item::CreateItem() returned NULL for item {} (stack: {})", itemId, stackCount); - return; + continue; } // Update the just created item so that if it needs random properties it has them. @@ -912,13 +968,16 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config) auction.StartTime = GameTime::GetSystemTime(); auction.EndTime = auction.StartTime + Hours(urand(config.GetMinTime(), config.GetMaxTime())); + // save the item like a player listing does, otherwise the next start finds no item and deletes the auction + item->SaveToDB(trans); auctionHouse->AddAuction(trans, std::move(auction)); ++count; } CharacterDatabase.CommitTransaction(trans); - TC_LOG_DEBUG("ahbot", "AHBot: Added {} items to auction", count); + if (count) + TC_LOG_INFO("ahbot", "AHBot: sold {} items into the {} house", count, AuctionBotConfig::GetHouseTypeName(config.GetHouseType())); } bool AuctionBotSeller::Update(AuctionHouseType houseType) diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.h b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.h index 49f4387291..64ac505c6a 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.h +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.h @@ -138,6 +138,7 @@ private: SellerConfiguration _houseConfig[MAX_AUCTION_HOUSE_TYPE]; ItemPool _itemPool[MAX_AUCTION_QUALITY][MAX_ITEM_CLASS]; + bool _bonusQualityReported = false; void LoadSellerValues(SellerConfiguration& config); uint32 SetStat(SellerConfiguration& config); diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotVanilla.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotVanilla.cpp index 93b6470ae8..f8736e1422 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotVanilla.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotVanilla.cpp @@ -19,6 +19,8 @@ #include "Config.h" #include "ItemTemplate.h" #include "SharedDefines.h" +#include +#include namespace AuctionBotVanilla { @@ -27,6 +29,10 @@ namespace bool _enabled = false; int32 _maxReqLevel = 60; uint32 _maxItemLevel = 100; // Naxxramas epics top out around 92 + bool _valueCurve = false; + + // copper per item level squared, by quality (gray .. epic) + constexpr std::array QualityFactor = { 1, 2, 15, 50, 150 }; } void LoadConfig() @@ -34,6 +40,7 @@ void LoadConfig() _enabled = sConfigMgr->GetBoolDefault("AuctionHouseBot.Vanilla.Only", false); _maxReqLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.Vanilla.MaxReqLevel", 60); _maxItemLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.Vanilla.MaxItemLevel", 100); + _valueCurve = sConfigMgr->GetBoolDefault("AuctionHouseBot.Vanilla.ValueCurve", false); } bool Enabled() @@ -72,4 +79,41 @@ bool IsAllowed(ItemTemplate const* proto) return true; } + +uint64 UnitValue(ItemTemplate const* proto) +{ + if (!_valueCurve) + return 0; + + // the 70532 data gives most loot-only goods a token vendor price (enchanting essences and shards: 1 copper), + // so the vendor price alone lists them for a few copper + uint64 vendor = std::max(proto->GetBuyPrice() / std::max(1, proto->GetBuyCount()), uint64(proto->GetSellPrice()) * 4); + if (proto->GetClass() == ITEM_CLASS_PROJECTILE) + vendor = proto->GetBuyPrice() / 200; // ammo is bought in stacks of 200 + + uint32 classPct = 0; + switch (proto->GetClass()) + { + case ITEM_CLASS_WEAPON: + case ITEM_CLASS_ARMOR: + case ITEM_CLASS_CONTAINER: + case ITEM_CLASS_TRADE_GOODS: + classPct = 100; + break; + case ITEM_CLASS_RECIPE: + case ITEM_CLASS_MISCELLANEOUS: + classPct = 50; + break; + case ITEM_CLASS_CONSUMABLE: + classPct = 25; + break; + default: // ammo, reagents, quivers: vendor goods, vendor price + break; + } + + uint32 quality = std::min(proto->GetQuality(), QualityFactor.size() - 1); + uint64 itemLevel = proto->GetBaseItemLevel(); + uint64 curve = itemLevel * itemLevel * QualityFactor[quality] * classPct / 100; + return std::max(vendor, curve); +} } diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotVanilla.h b/src/server/game/AuctionHouseBot/AuctionHouseBotVanilla.h index 329abf3ec9..7cd4c9ecdd 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotVanilla.h +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotVanilla.h @@ -18,6 +18,8 @@ #ifndef AUCTION_HOUSE_BOT_VANILLA_H #define AUCTION_HOUSE_BOT_VANILLA_H +#include "Define.h" + struct ItemTemplate; // Optional vanilla-era item filter for the AuctionHouseBot seller (AuctionHouseBot.Vanilla.*). @@ -31,6 +33,10 @@ namespace AuctionBotVanilla // False for anything that is not level-60 vanilla content; always true while the filter is off. bool IsAllowed(ItemTemplate const* proto); + + // AuctionHouseBot.Vanilla.ValueCurve = 1: per-unit market value in copper from item level, quality and class, + // never below the vendor price. 0 while the curve is off (callers keep the vendor price). + uint64 UnitValue(ItemTemplate const* proto); } #endif diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 35def57596..5b8ff13c8b 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -3821,6 +3821,14 @@ AuctionHouseBot.Vanilla.Only = 0 AuctionHouseBot.Vanilla.MaxReqLevel = 60 AuctionHouseBot.Vanilla.MaxItemLevel = 100 +# AuctionHouseBot.Vanilla.ValueCurve +# Description: Price bot listings (and the buyer's fair price) by item level squared x quality x class, +# never below the vendor price. For client data whose loot-only goods carry a token vendor price. +# Default: 0 - (Disabled, vendor price) +# 1 - (Enabled) + +AuctionHouseBot.Vanilla.ValueCurve = 0 + # # AuctionHouseBot.Alliance.Items.Amount.Ratio # Description: Enable/Disable (disabled if 0) the part of AHBot that puts items up for auction on Alliance AH @@ -3901,6 +3909,14 @@ AuctionHouseBot.Items.Loot = 1 AuctionHouseBot.Items.Misc = 0 +# AuctionHouseBot.Items.Crafted +# Description: Include items made by a profession recipe even when no loot or vendor list has them +# (only matters with AuctionHouseBot.Items.Misc = 0) +# Default: 0 - (Disabled) +# 1 - (Enabled) + +AuctionHouseBot.Items.Crafted = 0 + # # AuctionHouseBot.Bind.* # Description: Indicates which bonding types to allow the bot to put up for auction @@ -4090,6 +4106,14 @@ AuctionHouseBot.Class.Key = 1 AuctionHouseBot.Class.Misc = 5 AuctionHouseBot.Class.Glyph = 3 +# AuctionHouseBot.Class.WeightByPoolSize +# Description: Also weight each class's share of a quality by how many different items it has, so a +# class with a handful of items (green bags, arrows) is not listed dozens of times each. +# Default: 0 - (Disabled, share by AuctionHouseBot.Class.* only) +# 1 - (Enabled) + +AuctionHouseBot.Class.WeightByPoolSize = 0 + # ###################################################################################################