[3.3.5] AHBot Characters (#17885)

This commit is contained in:
iridinite authored and Aokromes committed 2016-10-24 13:27:54 +02:00
1 parent 1e60c73ad9
commit d364576cce
6 files changed
+93 -16

No files matched your search

@@ -19,6 +19,7 @@
#include "Item.h"
#include "World.h"
#include "Config.h"
#include "AccountMgr.h"
#include "AuctionHouseMgr.h"
#include "AuctionHouseBot.h"
#include "AuctionHouseBotBuyer.h"
@@ -56,6 +57,36 @@ bool AuctionBotConfig::Initialize()
_itemsPerCycleBoost = GetConfig(CONFIG_AHBOT_ITEMS_PER_CYCLE_BOOST);
_itemsPerCycleNormal = GetConfig(CONFIG_AHBOT_ITEMS_PER_CYCLE_NORMAL);
if (GetConfig(CONFIG_AHBOT_ACCOUNT_ID))
{
// check character count
uint32 charcount = AccountMgr::GetCharactersCount(GetConfig(CONFIG_AHBOT_ACCOUNT_ID));
if (charcount)
{
// find account guids associated with ahbot account
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID);
stmt->setUInt32(0, GetConfig(CONFIG_AHBOT_ACCOUNT_ID));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
for (uint32 charno = 0; charno < result->GetRowCount(); charno++)
{
_AHBotCharacters.push_back((*result)[0].GetUInt32());
result->NextRow();
}
TC_LOG_DEBUG("ahbot", "AuctionHouseBot found %i characters", charcount);
}
else
{
_AHBotCharacters.push_back(uint32(0));
TC_LOG_WARN("ahbot", "AuctionHouseBot Account ID has no associated characters.");
}
}
else
{
_AHBotCharacters.push_back(uint32(0));
}
return true;
}
@@ -111,6 +142,8 @@ void AuctionBotConfig::SetConfig(AuctionBotConfigFloatValues index, char const*
//Get AuctionHousebot configuration file
void AuctionBotConfig::GetConfigFromFile()
{
SetConfig(CONFIG_AHBOT_ACCOUNT_ID, "AuctionHouseBot.Account", 0);
SetConfigMax(CONFIG_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO, "AuctionHouseBot.Alliance.Items.Amount.Ratio", 100, 10000);
SetConfigMax(CONFIG_AHBOT_HORDE_ITEM_AMOUNT_RATIO, "AuctionHouseBot.Horde.Items.Amount.Ratio", 100, 10000);
SetConfigMax(CONFIG_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO, "AuctionHouseBot.Neutral.Items.Amount.Ratio", 100, 10000);
@@ -272,6 +305,35 @@ char const* AuctionBotConfig::GetHouseTypeName(AuctionHouseType houseType)
return names[houseType];
}
// Picks a random character from the list of AHBot chars
uint32 AuctionBotConfig::GetRandChar() const
{
return _AHBotCharacters[urand(0, _AHBotCharacters.size() - 1)];
}
// Picks a random AHBot character, but excludes a specific one. This is used
// to have another character than the auction owner place bids
uint32 AuctionBotConfig::GetRandCharExclude(uint32 exclude) const
{
// avoid freezing if only one ahbot char (which defeats the purpose but oh well)
if (_AHBotCharacters.size() == 1)
return _AHBotCharacters[0];
uint32 result;
do
{
result = GetRandChar();
}
while (result == exclude);
return result;
}
bool AuctionBotConfig::IsBotChar(uint32 characterID) const
{
return !characterID || std::find(_AHBotCharacters.begin(), _AHBotCharacters.end(), characterID) != _AHBotCharacters.end();
}
uint32 AuctionBotConfig::GetConfigItemAmountRatio(AuctionHouseType houseType) const
{
switch (houseType)
@@ -408,7 +470,7 @@ void AuctionHouseBot::PrepareStatusInfos(AuctionHouseBotStatusInfo& statusInfo)
if (Item* item = sAuctionMgr->GetAItem(auctionEntry->itemGUIDLow))
{
ItemTemplate const* prototype = item->GetTemplate();
if (!auctionEntry->owner) // Add only ahbot items
if (!auctionEntry->owner || sAuctionBotConfig->IsBotChar(auctionEntry->owner)) // Add only ahbot items
{
if (prototype->Quality < MAX_AUCTION_QUALITY)
++statusInfo[i].QualityInfo[prototype->Quality];
@@ -426,7 +488,7 @@ void AuctionHouseBot::Rebuild(bool all)
{
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(AuctionHouseType(i));
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr)
if (!itr->second->owner) // ahbot auction
if (!itr->second->owner || sAuctionBotConfig->IsBotChar(itr->second->owner)) // ahbot auction
if (all || itr->second->bid == 0) // expire now auction if no bid or forced
itr->second->expire_time = sWorld->GetGameTime();
}