diff options
| author | jackpoz <giacomopoz@gmail.com> | 2015-08-01 18:48:55 +0200 |
|---|---|---|
| committer | jackpoz <giacomopoz@gmail.com> | 2015-08-01 18:48:55 +0200 |
| commit | 177b6319d1ad49a38fbd06f37671da1e3d1ae4e6 (patch) | |
| tree | 0dab43a0d1afce97eb920dc90be0889f5673bfad /src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp | |
| parent | 59fe55dfc90482e7de16db1d6756606438182f34 (diff) | |
Core/AHBot: Adjust AHBot bid and buyout chances
Apply an exponential formula to define the chance to bid/buyout an auction depending on auction price and item price ratio. The formula can be adjusted changing the new AuctionHouseBot.Buyer.ChanceFactor config parameter
Chance = 100 ^ (1 + (1 - (auction_price / item_price) / k)
k is the config parameter AuctionHouseBot.Buyer.ChanceFactor, the higher the number the higher chance to buy overpriced auctions.
Diffstat (limited to 'src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp')
| -rw-r--r-- | src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp index 64463948574..4bf6aa950c6 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp @@ -157,18 +157,18 @@ bool AuctionBotBuyer::RollBuyChance(const BuyerItemInfo* ahInfo, const Item* ite if (!auction->buyout) return false; - uint32 itemBuyPrice = auction->buyout / item->GetCount(); - uint32 itemPrice = item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality); + float itemBuyPrice = float(auction->buyout / item->GetCount()); + float itemPrice = float(item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality)); // The AH cut needs to be added to the price, but we dont want a 100% chance to buy if the price is exactly AH default itemPrice *= 1.4f; // This value is between 0 and 100 and is used directly as the chance to buy or bid // Value equal or above 100 means 100% chance and value below 0 means 0% chance - float chance = 100 / sqrt(itemBuyPrice / float(itemPrice)); + float chance = std::min(100.f, std::pow(100.f, 1.f + (1.f - itemBuyPrice / itemPrice) / sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCE_FACTOR))); // If a player has bidded on item, have fifth of normal chance if (auction->bidder) - chance = chance / 5; + chance = chance / 5.f; if (ahInfo) { @@ -178,31 +178,29 @@ bool AuctionBotBuyer::RollBuyChance(const BuyerItemInfo* ahInfo, const Item* ite // If there are more than 5 items on AH of this entry, try weigh in the average buyout price if (ahInfo->BuyItemCount > 5) - { - chance *= 1 / sqrt(itemBuyPrice / avgBuyPrice); - } + chance *= 1.f / std::sqrt(itemBuyPrice / avgBuyPrice); } // Add config weigh in for quality chance *= GetChanceMultiplier(item->GetTemplate()->Quality) / 100.0f; - float rand = frand(0, 100); + float rand = frand(0.f, 100.f); bool win = rand <= chance; - TC_LOG_DEBUG("ahbot", "AHBot: %s BUY! chance = %.2f, price = %u, buyprice = %u.", win ? "WIN" : "LOSE", chance, itemPrice, itemBuyPrice); + TC_LOG_DEBUG("ahbot", "AHBot: %s BUY! chance = %.2f, price = %u, buyprice = %u.", win ? "WIN" : "LOSE", chance, uint32(itemPrice), uint32(itemBuyPrice)); return win; } // ahInfo can be NULL bool AuctionBotBuyer::RollBidChance(const BuyerItemInfo* ahInfo, const Item* item, const AuctionEntry* auction, uint32 bidPrice) { - uint32 itemBidPrice = bidPrice / item->GetCount(); - uint32 itemPrice = item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality); + float itemBidPrice = float(bidPrice / item->GetCount()); + float itemPrice = float(item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality)); // The AH cut needs to be added to the price, but we dont want a 100% chance to buy if the price is exactly AH default itemPrice *= 1.4f; // This value is between 0 and 100 and is used directly as the chance to buy or bid // Value equal or above 100 means 100% chance and value below 0 means 0% chance - float chance = 100 / sqrt(itemBidPrice / float(itemPrice)); + float chance = std::min(100.f, std::pow(100.f, 1.f + (1.f - itemBidPrice / itemPrice) / sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCE_FACTOR))); if (ahInfo) { @@ -212,21 +210,19 @@ bool AuctionBotBuyer::RollBidChance(const BuyerItemInfo* ahInfo, const Item* ite // If there are more than 5 items on AH of this entry, try weigh in the average bid price if (ahInfo->BidItemCount >= 5) - { - chance *= 1 / sqrt(itemBidPrice / avgBidPrice); - } + chance *= 1.f / std::sqrt(itemBidPrice / avgBidPrice); } // If a player has bidded on item, have fifth of normal chance if (auction->bidder) - chance = chance / 5; + chance = chance / 5.f; // Add config weigh in for quality chance *= GetChanceMultiplier(item->GetTemplate()->Quality) / 100.0f; - float rand = frand(0, 100); + float rand = frand(0.f, 100.f); bool win = rand <= chance; - TC_LOG_DEBUG("ahbot", "AHBot: %s BID! chance = %.2f, price = %u, bidprice = %u.", win ? "WIN" : "LOSE", chance, itemPrice, itemBidPrice); + TC_LOG_DEBUG("ahbot", "AHBot: %s BID! chance = %.2f, price = %u, bidprice = %u.", win ? "WIN" : "LOSE", chance, uint32(itemPrice), uint32(itemBidPrice)); return win; } |
