Make the Auction House Bot consistent with the new sell as existing character feature. (#139)
This commit is contained in:
parent
d77becbf21
commit
e41bc4df70
@ -717,7 +717,11 @@ uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config)
|
||||
else if (buyerItem.MinBidPrice == 0)
|
||||
{ buyerItem.MinBidPrice = Aentry->startbid / item->GetCount(); }
|
||||
|
||||
if (!Aentry->owner)
|
||||
uint32 AHBotGuid;
|
||||
std::string AHBotCharacterName = sAuctionBotConfig.GetAHBotCharacterName();
|
||||
if (!AHBotCharacterName.empty())
|
||||
{ AHBotGuid = sObjectMgr.GetPlayerGuidByName(AHBotCharacterName.c_str()); }
|
||||
if (!Aentry->owner || Aentry->owner == AHBotGuid)
|
||||
{
|
||||
if ((Aentry->bid != 0) && Aentry->bidder) // Add bided by player
|
||||
{
|
||||
@ -992,11 +996,15 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config)
|
||||
minBuyPrice / 10000, minBidPrice / 10000);
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Actual Entry price, Buy=%ug, Bid=%ug.", buyoutPrice / 10000, bidPrice / 10000);
|
||||
|
||||
if (!auction->owner) // Original auction owner
|
||||
uint32 AHBotGuid;
|
||||
std::string AHBotCharacterName = sAuctionBotConfig.GetAHBotCharacterName();
|
||||
if (!AHBotCharacterName.empty())
|
||||
{ AHBotGuid = sObjectMgr.GetPlayerGuidByName(AHBotCharacterName.c_str()); }
|
||||
if (!auction->owner || auction->owner == AHBotGuid) // Original auction owner
|
||||
{
|
||||
MaxChance = MaxChance / 5; // if Owner is AHBot this mean player placed bid on this auction. We divide by 5 chance for AhBuyer to place bid on it. (This make more challenge than ignore entry)
|
||||
MaxChance = MaxChance / 5; // if Owner is AHBot this mean player placed bid on this auction. We divide by 5 chance for AhBuyer to place bid on it. (This make more challenge than ignore entry)
|
||||
}
|
||||
if (auction->buyout != 0) // Is the item directly buyable?
|
||||
if (auction->buyout != 0) // Is the item directly buyable?
|
||||
{
|
||||
if (IsBuyableEntry(buyoutPrice, InGame_BuyPrice, MaxBuyablePrice, minBuyPrice, MaxChance, config.FactionChance))
|
||||
{
|
||||
@ -1544,7 +1552,11 @@ uint32 AuctionBotSeller::SetStat(AHB_Seller_Config& config)
|
||||
ItemPrototype const* prototype = item->GetProto();
|
||||
if (prototype)
|
||||
{
|
||||
if (!Aentry->owner) // Add only ahbot items
|
||||
uint32 AHBotGuid;
|
||||
std::string AHBotCharacterName = sAuctionBotConfig.GetAHBotCharacterName();
|
||||
if (!AHBotCharacterName.empty())
|
||||
{ AHBotGuid = sObjectMgr.GetPlayerGuidByName(AHBotCharacterName.c_str()); }
|
||||
if (!Aentry->owner || Aentry->owner == AHBotGuid) // Add only ahbot items
|
||||
{
|
||||
++ItemsInAH[prototype->Quality][prototype->Class];
|
||||
}
|
||||
@ -1746,7 +1758,11 @@ void AuctionBotSeller::addNewAuctions(AHB_Seller_Config& config)
|
||||
// Add the auction under the player name specified in the configuration.
|
||||
std::string AHBotCharacterName = sAuctionBotConfig.GetAHBotCharacterName();
|
||||
if (!AHBotCharacterName.empty())
|
||||
{ auctionHouse->AddAuction(ahEntry, item, urand(config.GetMinTime(), config.GetMaxTime()) * HOUR, bidPrice, buyoutPrice, 0, sObjectMgr.GetPlayer(AHBotCharacterName.c_str())); }
|
||||
{
|
||||
ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(AHBotCharacterName.c_str());
|
||||
if (guid)
|
||||
{ auctionHouse->AddAuctionByGuid(ahEntry, item, urand(config.GetMinTime(), config.GetMaxTime()) * HOUR, bidPrice, buyoutPrice, guid.GetCounter()); }
|
||||
}
|
||||
else
|
||||
{ auctionHouse->AddAuction(ahEntry, item, urand(config.GetMinTime(), config.GetMaxTime()) * HOUR, bidPrice, buyoutPrice); }
|
||||
}
|
||||
@ -1859,7 +1875,11 @@ void AuctionHouseBot::PrepareStatusInfos(AuctionHouseBotStatusInfo& statusInfo)
|
||||
if (Item* item = sAuctionMgr.GetAItem(Aentry->itemGuidLow))
|
||||
{
|
||||
ItemPrototype const* prototype = item->GetProto();
|
||||
if (!Aentry->owner) // Add only ahbot items
|
||||
uint32 AHBotGuid;
|
||||
std::string AHBotCharacterName = sAuctionBotConfig.GetAHBotCharacterName();
|
||||
if (!AHBotCharacterName.empty())
|
||||
{ AHBotGuid = sObjectMgr.GetPlayerGuidByName(AHBotCharacterName.c_str()); }
|
||||
if (!Aentry->owner || Aentry->owner == AHBotGuid) // Add only ahbot items
|
||||
{
|
||||
if (prototype->Quality < MAX_AUCTION_QUALITY)
|
||||
{ ++statusInfo[i].QualityInfo[prototype->Quality]; }
|
||||
@ -1880,8 +1900,12 @@ void AuctionHouseBot::Rebuild(bool all)
|
||||
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
|
||||
{
|
||||
AuctionEntry* entry = itr->second;
|
||||
if (!entry->owner) // ahbot auction
|
||||
if (all || entry->bid == 0) // expire now auction if no bid or forced
|
||||
uint32 AHBotGuid;
|
||||
std::string AHBotCharacterName = sAuctionBotConfig.GetAHBotCharacterName();
|
||||
if (!AHBotCharacterName.empty())
|
||||
{ AHBotGuid = sObjectMgr.GetPlayerGuidByName(AHBotCharacterName.c_str()); };
|
||||
if (!entry->owner || entry->owner == AHBotGuid) // ahbot auction
|
||||
if (all || entry->bid == 0) // expire now auction if no bid or forced
|
||||
entry->expireTime = sWorld.GetGameTime();
|
||||
}
|
||||
}
|
||||
|
@ -695,6 +695,39 @@ AuctionEntry* AuctionHouseObject::AddAuction(AuctionHouseEntry const* auctionHou
|
||||
return AH;
|
||||
}
|
||||
|
||||
AuctionEntry* AuctionHouseObject::AddAuctionByGuid(AuctionHouseEntry const* auctionHouseEntry, Item* newItem, uint32 etime, uint32 bid, uint32 buyout, uint32 lowguid)
|
||||
{
|
||||
uint32 auction_time = uint32(etime * sWorld.getConfig(CONFIG_FLOAT_RATE_AUCTION_TIME));
|
||||
|
||||
AuctionEntry* AH = new AuctionEntry;
|
||||
AH->Id = sObjectMgr.GenerateAuctionID();
|
||||
AH->itemGuidLow = newItem->GetObjectGuid().GetCounter();
|
||||
AH->itemTemplate = newItem->GetEntry();
|
||||
AH->itemCount = newItem->GetCount();
|
||||
AH->itemRandomPropertyId = newItem->GetItemRandomPropertyId();
|
||||
AH->owner = lowguid;
|
||||
AH->startbid = bid;
|
||||
AH->bidder = 0;
|
||||
AH->bid = 0;
|
||||
AH->buyout = buyout;
|
||||
AH->expireTime = time(NULL) + auction_time;
|
||||
AH->deposit = 0;
|
||||
AH->auctionHouseEntry = auctionHouseEntry;
|
||||
|
||||
AddAuction(AH);
|
||||
|
||||
sAuctionMgr.AddAItem(newItem);
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
|
||||
newItem->SaveToDB();
|
||||
AH->SaveToDB();
|
||||
|
||||
CharacterDatabase.CommitTransaction();
|
||||
|
||||
return AH;
|
||||
}
|
||||
|
||||
// this function inserts to WorldPacket auction's data
|
||||
bool AuctionEntry::BuildAuctionInfo(WorldPacket& data) const
|
||||
{
|
||||
|
@ -152,6 +152,7 @@ class AuctionHouseObject
|
||||
uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
|
||||
uint32& count, uint32& totalcount);
|
||||
AuctionEntry* AddAuction(AuctionHouseEntry const* auctionHouseEntry, Item* newItem, uint32 etime, uint32 bid, uint32 buyout = 0, uint32 deposit = 0, Player* pl = NULL);
|
||||
AuctionEntry* AddAuctionByGuid(AuctionHouseEntry const* auctionHouseEntry, Item* newItem, uint32 etime, uint32 bid, uint32 buyout, uint32 lowguid);
|
||||
private:
|
||||
AuctionEntryMap AuctionsMap;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user