TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AuctionBotSeller Class Reference

#include <AuctionHouseBotSeller.h>

Public Types

typedef std::vector< uint32ItemPool
 

Public Member Functions

 AuctionBotSeller ()
 
 ~AuctionBotSeller ()
 
bool Initialize () override
 
bool Update (AuctionHouseType houseType) override
 
void AddNewAuctions (SellerConfiguration &config)
 
void SetItemsRatio (uint32 al, uint32 ho, uint32 ne)
 
void SetItemsRatioForHouse (AuctionHouseType house, uint32 val)
 
void SetItemsAmount (uint32(&vals)[MAX_AUCTION_QUALITY])
 
void SetItemsAmountForQuality (AuctionQuality quality, uint32 val)
 
void LoadConfig ()
 
- Public Member Functions inherited from AuctionBotAgent
 AuctionBotAgent ()
 
virtual ~AuctionBotAgent ()
 

Private Member Functions

void LoadSellerValues (SellerConfiguration &config)
 
uint32 SetStat (SellerConfiguration &config)
 
bool GetItemsToSell (SellerConfiguration &config, ItemsToSellArray &itemsToSellArray, AllItemsArray const &addedItem)
 
void SetPricesOfItem (ItemTemplate const *itemProto, SellerConfiguration &config, uint32 &buyp, uint32 &bidp, uint32 stackcnt)
 
uint32 GetStackSizeForItem (ItemTemplate const *itemProto, SellerConfiguration &config) const
 
void LoadItemsQuantity (SellerConfiguration &config)
 

Static Private Member Functions

static uint32 GetBuyModifier (ItemTemplate const *prototype)
 
static uint32 GetSellModifier (ItemTemplate const *itemProto)
 

Private Attributes

SellerConfiguration _houseConfig [MAX_AUCTION_HOUSE_TYPE]
 
ItemPool _itemPool [MAX_AUCTION_QUALITY][MAX_ITEM_CLASS]
 

Member Typedef Documentation

typedef std::vector<uint32> AuctionBotSeller::ItemPool

Constructor & Destructor Documentation

AuctionBotSeller::AuctionBotSeller ( )
25 {
26  // Define faction for our main data class.
27  for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i)
29 }
AuctionHouseType
Definition: AuctionHouseBot.h:40
#define MAX_AUCTION_HOUSE_TYPE
Definition: AuctionHouseBot.h:47
SellerConfiguration _houseConfig[MAX_AUCTION_HOUSE_TYPE]
Definition: AuctionHouseBotSeller.h:137
bool Initialize() override
Definition: AuctionHouseBotSeller.cpp:35

+ Here is the call graph for this function:

AuctionBotSeller::~AuctionBotSeller ( )
32 {
33 }

Member Function Documentation

void AuctionBotSeller::AddNewAuctions ( SellerConfiguration config)
921 {
922  uint32 count = 0;
923  uint32 items = 0;
924 
925  // If there is large amount of items missed we can use boost value to get fast filled AH
926  if (config.LastMissedItem > sAuctionBotConfig->GetItemPerCycleBoost())
927  {
928  items = sAuctionBotConfig->GetItemPerCycleBoost();
929  TC_LOG_DEBUG("ahbot", "AHBot: Boost value used to fill AH! (if this happens often adjust both ItemsPerCycle in worldserver.conf)");
930  }
931  else
932  items = sAuctionBotConfig->GetItemPerCycleNormal();
933 
934  uint32 houseid = 0;
935  uint64 auctioneer = 0;
936  switch (config.GetHouseType())
937  {
939  houseid = 1; auctioneer = 79707; break;
940  case AUCTION_HOUSE_HORDE:
941  houseid = 6; auctioneer = 4656; break;
942  default:
943  houseid = 7; auctioneer = 23442; break;
944  }
945 
946  AuctionHouseEntry const* ahEntry = sAuctionHouseStore.LookupEntry(houseid);
947 
948  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
949 
950  ItemsToSellArray itemsToSell;
951  AllItemsArray allItems(MAX_AUCTION_QUALITY, std::vector<uint32>(MAX_ITEM_CLASS));
952  // Main loop
953  // getRandomArray will give what categories of items should be added (return true if there is at least 1 items missed)
955  while (GetItemsToSell(config, itemsToSell, allItems) && items > 0)
956  {
957  --items;
958 
959  // Select random position from missed items table
960  uint32 pos = urand(0, itemsToSell.size() - 1);
961 
962  // Set itemId with random item ID for selected categories and color, from _itemPool table
963  uint32 itemId = _itemPool[itemsToSell[pos].Color][itemsToSell[pos].Itemclass][urand(0, _itemPool[itemsToSell[pos].Color][itemsToSell[pos].Itemclass].size() - 1)];
964  ++allItems[itemsToSell[pos].Color][itemsToSell[pos].Itemclass]; // Helper table to avoid rescan from DB in this loop. (has we add item in random orders)
965 
966  if (!itemId)
967  {
968  TC_LOG_DEBUG("ahbot", "AHBot: Item entry 0 auction creating attempt.");
969  continue;
970  }
971 
972  ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(itemId);
973  if (!prototype)
974  {
975  TC_LOG_DEBUG("ahbot", "AHBot: Unknown item %u auction creating attempt.", itemId);
976  continue;
977  }
978 
979  uint32 stackCount = GetStackSizeForItem(prototype, config);
980 
981  Item* item = Item::CreateItem(itemId, stackCount);
982  if (!item)
983  {
984  TC_LOG_ERROR("ahbot", "AHBot: Item::CreateItem() returned NULL for item %u (stack: %u)", itemId, stackCount);
985  return;
986  }
987 
988  // Update the just created item so that if it needs random properties it has them.
989  // Ex: Notched Shortsword of Stamina will only generate as a Notched Shortsword without this.
990  if (int32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemId))
991  item->SetItemRandomProperties(randomPropertyId);
992 
993  uint32 buyoutPrice;
994  uint32 bidPrice = 0;
995 
996  // Price of items are set here
997  SetPricesOfItem(prototype, config, buyoutPrice, bidPrice, stackCount);
998 
999  // Deposit time
1000  uint32 etime = urand(1, 3);
1001  switch (etime)
1002  {
1003  case 1:
1004  etime = 43200;
1005  break;
1006  case 2:
1007  etime = 86400;
1008  break;
1009  case 3:
1010  etime = 172800;
1011  break;
1012  default:
1013  etime = 86400;
1014  break;
1015  }
1016 
1017  AuctionEntry* auctionEntry = new AuctionEntry();
1018  auctionEntry->Id = sObjectMgr->GenerateAuctionID();
1019  auctionEntry->owner = UI64LIT(0);
1020  auctionEntry->itemGUIDLow = item->GetGUID().GetCounter();
1021  auctionEntry->itemEntry = item->GetEntry();
1022  auctionEntry->startbid = bidPrice;
1023  auctionEntry->buyout = buyoutPrice;
1024  auctionEntry->auctioneer = auctioneer;
1025  auctionEntry->bidder = UI64LIT(0);
1026  auctionEntry->bid = 0;
1027  auctionEntry->deposit = sAuctionMgr->GetAuctionDeposit(ahEntry, etime, item, stackCount);
1028  auctionEntry->auctionHouseEntry = ahEntry;
1029  auctionEntry->expire_time = time(NULL) + urand(config.GetMinTime(), config.GetMaxTime()) * HOUR;
1030 
1031  item->SaveToDB(trans);
1032  sAuctionMgr->AddAItem(item);
1033  auctionHouse->AddAuction(auctionEntry);
1034  auctionEntry->SaveToDB(trans);
1035 
1036  auctionHouse->AddAuction(auctionEntry);
1037 
1038  ++count;
1039  }
1041 
1042  TC_LOG_DEBUG("ahbot", "AHBot: Added %u items to auction", count);
1043 }
uint32 LastMissedItem
Definition: AuctionHouseBotSeller.h:72
void SaveToDB(SQLTransaction &trans) const
Definition: AuctionHouseMgr.cpp:807
bool GetItemsToSell(SellerConfiguration &config, ItemsToSellArray &itemsToSellArray, AllItemsArray const &addedItem)
Definition: AuctionHouseBotSeller.cpp:676
uint32 itemEntry
Definition: AuctionHouseMgr.h:72
DB2Storage< AuctionHouseEntry > sAuctionHouseStore("AuctionHouse.db2", AuctionHouseFormat, HOTFIX_SEL_AUCTION_HOUSE)
std::vector< ItemToSell > ItemsToSellArray
Definition: AuctionHouseBotSeller.h:31
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
Definition: Common.h:98
AuctionHouseType GetHouseType() const
Definition: AuctionHouseBotSeller.h:70
uint32 GetStackSizeForItem(ItemTemplate const *itemProto, SellerConfiguration &config) const
Definition: AuctionHouseBotSeller.cpp:740
ObjectGuid::LowType itemGUIDLow
Definition: AuctionHouseMgr.h:71
#define MAX_AUCTION_QUALITY
Definition: AuctionHouseBot.h:38
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
#define UI64LIT(N)
Definition: Define.h:138
Definition: AuctionHouseMgr.h:67
#define MAX_ITEM_CLASS
Definition: ItemTemplate.h:386
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SetPricesOfItem(ItemTemplate const *itemProto, SellerConfiguration &config, uint32 &buyp, uint32 &bidp, uint32 stackcnt)
Definition: AuctionHouseBotSeller.cpp:700
void SetItemRandomProperties(int32 randomPropId)
Definition: Item.cpp:640
#define sObjectMgr
Definition: ObjectMgr.h:1567
AuctionHouseEntry const * auctionHouseEntry
Definition: AuctionHouseMgr.h:82
uint32 Id
Definition: AuctionHouseMgr.h:69
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: AuctionHouseBot.h:44
virtual void SaveToDB(SQLTransaction &trans)
Definition: Item.cpp:311
std::vector< std::vector< uint32 > > AllItemsArray
Definition: AuctionHouseBotSeller.h:32
uint32 GetMinTime() const
Definition: AuctionHouseBotSeller.h:78
static int32 GenerateItemRandomPropertyId(uint32 item_id)
Definition: Item.cpp:594
ObjectGuid::LowType owner
Definition: AuctionHouseMgr.h:74
ItemPool _itemPool[MAX_AUCTION_QUALITY][MAX_ITEM_CLASS]
Definition: AuctionHouseBotSeller.h:139
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
Definition: Item.h:259
uint32 startbid
Definition: AuctionHouseMgr.h:75
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
uint32 bid
Definition: AuctionHouseMgr.h:76
time_t expire_time
Definition: AuctionHouseMgr.h:78
static Item * CreateItem(uint32 itemEntry, uint32 count, Player const *player=NULL)
Definition: Item.cpp:1068
ObjectGuid::LowType bidder
Definition: AuctionHouseMgr.h:79
uint32 buyout
Definition: AuctionHouseMgr.h:77
Color
Definition: format.h:3029
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ItemTemplate.h:647
ObjectGuid::LowType auctioneer
Definition: AuctionHouseMgr.h:70
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
Definition: AuctionHouseMgr.h:100
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void AddAuction(AuctionEntry *auction)
Definition: AuctionHouseMgr.cpp:556
uint32 GetMaxTime() const
Definition: AuctionHouseBotSeller.h:84
Definition: DB2Structure.h:53
Definition: AuctionHouseBot.h:43
uint32 deposit
Definition: AuctionHouseMgr.h:80
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 AuctionBotSeller::GetBuyModifier ( ItemTemplate const prototype)
staticprivate
765 {
766  switch (prototype->GetClass())
767  {
769  {
770  switch (prototype->GetSubClass())
771  {
773  return 100;
774  case ITEM_SUBCLASS_FLASK:
775  return 400;
777  return 15;
779  return 250;
781  return 125;
782  default:
783  return 300;
784  }
785  }
786  case ITEM_CLASS_WEAPON:
787  {
788  switch (prototype->GetSubClass())
789  {
795  return 1200;
801  return 1500;
803  return 350;
804  default:
805  return 1000;
806  }
807  }
808  case ITEM_CLASS_ARMOR:
809  {
810  switch (prototype->GetSubClass())
811  {
814  return 500;
816  return 600;
818  return 700;
821  return 800;
822  default:
823  return 400;
824  }
825  }
826  case ITEM_CLASS_REAGENT:
828  return 50;
830  {
831  switch (prototype->GetSubClass())
832  {
834  case ITEM_SUBCLASS_PARTS:
835  case ITEM_SUBCLASS_MEAT:
836  return 50;
838  return 250;
840  return 500;
844  return 300;
845  default:
846  return 100;
847  }
848  }
849  case ITEM_CLASS_QUEST: return 1000;
850  case ITEM_CLASS_KEY: return 3000;
851  default:
852  return 500;
853  }
854 }
Definition: ItemTemplate.h:506
Definition: ItemTemplate.h:437
Definition: ItemTemplate.h:373
Definition: ItemTemplate.h:397
Definition: ItemTemplate.h:516
Definition: ItemTemplate.h:435
Definition: ItemTemplate.h:517
Definition: ItemTemplate.h:393
Definition: ItemTemplate.h:507
Definition: ItemTemplate.h:474
Definition: ItemTemplate.h:432
Definition: ItemTemplate.h:473
Definition: ItemTemplate.h:428
Definition: ItemTemplate.h:426
Definition: ItemTemplate.h:518
Definition: ItemTemplate.h:380
Definition: ItemTemplate.h:508
Definition: ItemTemplate.h:430
Definition: ItemTemplate.h:438
Definition: ItemTemplate.h:509
Definition: ItemTemplate.h:472
Definition: ItemTemplate.h:396
Definition: ItemTemplate.h:394
Definition: ItemTemplate.h:514
Definition: ItemTemplate.h:369
Definition: ItemTemplate.h:470
Definition: ItemTemplate.h:367
Definition: ItemTemplate.h:422
Definition: ItemTemplate.h:372
Definition: ItemTemplate.h:429
Definition: ItemTemplate.h:379
Definition: ItemTemplate.h:423
Definition: ItemTemplate.h:371
Definition: ItemTemplate.h:471
Definition: ItemTemplate.h:476
Definition: ItemTemplate.h:427
Definition: ItemTemplate.h:374
Definition: ItemTemplate.h:390

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AuctionBotSeller::GetItemsToSell ( SellerConfiguration config,
ItemsToSellArray itemsToSellArray,
AllItemsArray const addedItem 
)
private
677 {
678  itemsToSellArray.clear();
679  bool found = false;
680 
681  for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j)
682  {
683  for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i)
684  {
685  if (config.GetMissedItemsPerClass(AuctionQuality(j), ItemClass(i)) > addedItem[j][i] && !_itemPool[j][i].empty())
686  {
687  ItemToSell miss_item;
688  miss_item.Color = j;
689  miss_item.Itemclass = i;
690  itemsToSellArray.push_back(miss_item);
691  found = true;
692  }
693  }
694  }
695 
696  return found;
697 }
AuctionQuality
Definition: AuctionHouseBot.h:27
#define MAX_AUCTION_QUALITY
Definition: AuctionHouseBot.h:38
#define MAX_ITEM_CLASS
Definition: ItemTemplate.h:386
uint32 Color
Definition: AuctionHouseBotSeller.h:27
uint32 GetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass) const
Definition: AuctionHouseBotSeller.h:97
ItemPool _itemPool[MAX_AUCTION_QUALITY][MAX_ITEM_CLASS]
Definition: AuctionHouseBotSeller.h:139
uint32_t uint32
Definition: Define.h:150
ItemClass
Definition: ItemTemplate.h:365
Definition: AuctionHouseBotSeller.h:25
uint32 Itemclass
Definition: AuctionHouseBotSeller.h:28

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 AuctionBotSeller::GetSellModifier ( ItemTemplate const itemProto)
staticprivate
750 {
751  switch (prototype->GetClass())
752  {
753  case ITEM_CLASS_WEAPON:
754  case ITEM_CLASS_ARMOR:
755  case ITEM_CLASS_REAGENT:
757  return 5;
758  default:
759  return 4;
760  }
761 }
Definition: ItemTemplate.h:373
Definition: ItemTemplate.h:369
Definition: ItemTemplate.h:372
Definition: ItemTemplate.h:371

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 AuctionBotSeller::GetStackSizeForItem ( ItemTemplate const itemProto,
SellerConfiguration config 
) const
private
741 {
742  if (config.GetRandomStackRatioPerClass(ItemClass(itemProto->GetClass())) > urand(0, 99))
743  return urand(1, itemProto->GetMaxStackSize());
744  else
745  return 1;
746 }
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
ItemClass
Definition: ItemTemplate.h:365
uint32 GetRandomStackRatioPerClass(ItemClass item) const
Definition: AuctionHouseBotSeller.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AuctionBotSeller::Initialize ( )
overridevirtual

Implements AuctionBotAgent.

36 {
37  std::vector<uint32> npcItems;
38  std::vector<uint32> lootItems;
39  std::vector<uint32> includeItems;
40  std::vector<uint32> excludeItems;
41 
42  TC_LOG_DEBUG("ahbot", "AHBot seller filters:");
43 
44  {
45  std::stringstream includeStream(sAuctionBotConfig->GetAHBotIncludes());
46  std::string temp;
47  while (std::getline(includeStream, temp, ','))
48  includeItems.push_back(atoi(temp.c_str()));
49  }
50 
51  {
52  std::stringstream excludeStream(sAuctionBotConfig->GetAHBotExcludes());
53  std::string temp;
54  while (std::getline(excludeStream, temp, ','))
55  excludeItems.push_back(atoi(temp.c_str()));
56  }
57 
58  TC_LOG_DEBUG("ahbot", "Forced Inclusion %u items", (uint32)includeItems.size());
59  TC_LOG_DEBUG("ahbot", "Forced Exclusion %u items", (uint32)excludeItems.size());
60 
61  TC_LOG_DEBUG("ahbot", "Loading npc vendor items for filter..");
62  const CreatureTemplateContainer* creatures = sObjectMgr->GetCreatureTemplates();
63  std::set<uint32> tempItems;
64  for (CreatureTemplateContainer::const_iterator it = creatures->begin(); it != creatures->end(); ++it)
65  {
66  if (const VendorItemData* data = sObjectMgr->GetNpcVendorItemList(it->first))
67  {
68  for (VendorItemList::const_iterator it2 = data->m_items.begin(); it2 != data->m_items.end(); ++it2)
69  tempItems.insert((*it2)->item);
70  }
71  }
72  for (std::set<uint32>::const_iterator it = tempItems.begin(); it != tempItems.end(); ++it)
73  npcItems.push_back(*it);
74 
75  TC_LOG_DEBUG("ahbot", "Npc vendor filter has %u items", (uint32)npcItems.size());
76 
77  TC_LOG_DEBUG("ahbot", "Loading loot items for filter..");
79  "SELECT `item` FROM `creature_loot_template` WHERE `Reference` = 0 UNION "
80  "SELECT `item` FROM `disenchant_loot_template` WHERE `Reference` = 0 UNION "
81  "SELECT `item` FROM `fishing_loot_template` WHERE `Reference` = 0 UNION "
82  "SELECT `item` FROM `gameobject_loot_template` WHERE `Reference` = 0 UNION "
83  "SELECT `item` FROM `item_loot_template` WHERE `Reference` = 0 UNION "
84  "SELECT `item` FROM `milling_loot_template` WHERE `Reference` = 0 UNION "
85  "SELECT `item` FROM `pickpocketing_loot_template` WHERE `Reference` = 0 UNION "
86  "SELECT `item` FROM `prospecting_loot_template` WHERE `Reference` = 0 UNION "
87  "SELECT `item` FROM `reference_loot_template` WHERE `Reference` = 0 UNION "
88  "SELECT `item` FROM `skinning_loot_template` WHERE `Reference` = 0 UNION "
89  "SELECT `item` FROM `spell_loot_template` WHERE `Reference` = 0");
90 
91  if (result)
92  {
93  do
94  {
95  Field* fields = result->Fetch();
96 
97  uint32 entry = fields[0].GetUInt32();
98  if (!entry)
99  continue;
100 
101  lootItems.push_back(entry);
102  } while (result->NextRow());
103  }
104 
105  TC_LOG_DEBUG("ahbot", "Loot filter has %u items", (uint32)lootItems.size());
106  TC_LOG_DEBUG("ahbot", "Sorting and cleaning items for AHBot seller...");
107 
108  uint32 itemsAdded = 0;
109 
110  for (uint32 itemId = 0; itemId < sItemStore.GetNumRows(); ++itemId)
111  {
112  ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(itemId);
113 
114  if (!prototype)
115  continue;
116 
117  // skip items with too high quality (code can't properly work with its)
118  if (prototype->GetQuality() >= MAX_AUCTION_QUALITY)
119  continue;
120 
121  // forced exclude filter
122  bool isExcludeItem = false;
123  for (size_t i = 0; i < excludeItems.size() && !isExcludeItem; ++i)
124  if (itemId == excludeItems[i])
125  isExcludeItem = true;
126 
127  if (isExcludeItem)
128  continue;
129 
130  // forced include filter
131  bool isForcedIncludeItem = false;
132  for (size_t i = 0; i < includeItems.size() && !isForcedIncludeItem; ++i)
133  if (itemId == includeItems[i])
134  isForcedIncludeItem = true;
135 
136  if (isForcedIncludeItem)
137  {
138  _itemPool[prototype->GetQuality()][prototype->GetClass()].push_back(itemId);
139  ++itemsAdded;
140  continue;
141  }
142 
143  // bounding filters
144  switch (prototype->GetBonding())
145  {
146  case NO_BIND:
147  if (!sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BIND_NO))
148  continue;
149  break;
150  case BIND_WHEN_PICKED_UP:
152  continue;
153  break;
154  case BIND_WHEN_EQUIPED:
156  continue;
157  break;
158  case BIND_WHEN_USE:
159  if (!sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BIND_USE))
160  continue;
161  break;
162  case BIND_QUEST_ITEM:
164  continue;
165  break;
166  default:
167  continue;
168  }
169 
170  bool allowZero = false;
171  switch (prototype->GetClass())
172  {
174  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONSUMABLE_ALLOW_ZERO); break;
176  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_CONTAINER_ALLOW_ZERO); break;
177  case ITEM_CLASS_WEAPON:
178  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_WEAPON_ALLOW_ZERO); break;
179  case ITEM_CLASS_GEM:
180  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GEM_ALLOW_ZERO); break;
181  case ITEM_CLASS_ARMOR:
182  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_ARMOR_ALLOW_ZERO); break;
183  case ITEM_CLASS_REAGENT:
184  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_REAGENT_ALLOW_ZERO); break;
186  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_PROJECTILE_ALLOW_ZERO); break;
188  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_TRADEGOOD_ALLOW_ZERO); break;
189  case ITEM_CLASS_RECIPE:
190  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_RECIPE_ALLOW_ZERO); break;
191  case ITEM_CLASS_QUIVER:
192  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUIVER_ALLOW_ZERO); break;
193  case ITEM_CLASS_QUEST:
194  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_QUEST_ALLOW_ZERO); break;
195  case ITEM_CLASS_KEY:
196  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_KEY_ALLOW_ZERO); break;
198  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_MISC_ALLOW_ZERO); break;
199  case ITEM_CLASS_GLYPH:
200  allowZero = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_CLASS_GLYPH_ALLOW_ZERO); break;
201  default:
202  allowZero = false;
203  }
204 
205  // Filter out items with no buy/sell price unless otherwise flagged in the config.
206  if (!allowZero)
207  {
209  {
210  if (prototype->GetSellPrice() == 0)
211  continue;
212  }
213  else
214  {
215  if (prototype->GetBuyPrice() == 0)
216  continue;
217  }
218  }
219 
220  // vendor filter
222  {
223  bool isVendorItem = false;
224  for (size_t i = 0; i < npcItems.size() && !isVendorItem; ++i)
225  if (itemId == npcItems[i])
226  isVendorItem = true;
227 
228  if (isVendorItem)
229  continue;
230  }
231 
232  // loot filter
234  {
235  bool isLootItem = false;
236  for (size_t i = 0; i < lootItems.size() && !isLootItem; ++i)
237  if (itemId == lootItems[i])
238  isLootItem = true;
239 
240  if (isLootItem)
241  continue;
242  }
243 
244  // not vendor/loot filter
246  {
247  bool isVendorItem = false;
248  bool isLootItem = false;
249 
250  for (size_t i = 0; i < npcItems.size() && !isVendorItem; ++i)
251  if (itemId == npcItems[i])
252  isVendorItem = true;
253 
254  for (size_t i = 0; i < lootItems.size() && !isLootItem; ++i)
255  if (itemId == lootItems[i])
256  isLootItem = true;
257 
258  if (!isLootItem && !isVendorItem)
259  continue;
260  }
261 
262  // item class/subclass specific filters
263  switch (prototype->GetClass())
264  {
265  case ITEM_CLASS_ARMOR:
266  case ITEM_CLASS_WEAPON:
267  {
269  if (prototype->GetBaseItemLevel() < value)
270  continue;
272  if (prototype->GetBaseItemLevel() > value)
273  continue;
275  if (prototype->GetBaseRequiredLevel() < static_cast<int32>(value))
276  continue;
278  if (prototype->GetBaseRequiredLevel() > static_cast<int32>(value))
279  continue;
281  if (prototype->GetRequiredSkillRank() < value)
282  continue;
284  if (prototype->GetRequiredSkillRank() > value)
285  continue;
286  break;
287  }
288  case ITEM_CLASS_RECIPE:
291  {
293  if (prototype->GetBaseRequiredLevel() < static_cast<int32>(value))
294  continue;
296  if (prototype->GetBaseRequiredLevel() > static_cast<int32>(value))
297  continue;
299  if (prototype->GetRequiredSkillRank() < value)
300  continue;
302  if (prototype->GetRequiredSkillRank() > value)
303  continue;
304  break;
305  }
307  if (prototype->GetSubClass() == ITEM_SUBCLASS_JUNK_MOUNT)
308  {
310  if (prototype->GetBaseRequiredLevel() < static_cast<int32>(value))
311  continue;
313  if (prototype->GetBaseRequiredLevel() > static_cast<int32>(value))
314  continue;
316  if (prototype->GetRequiredSkillRank() < value)
317  continue;
319  if (prototype->GetRequiredSkillRank() > value)
320  continue;
321  }
322 
323  if (prototype->GetFlags() & ITEM_FIELD_FLAG_UNLOCKED)
324  {
325  // skip any not locked lootable items (mostly quest specific or reward cases)
326  if (!prototype->GetLockID())
327  continue;
328 
330  continue;
331  }
332 
333  break;
334  case ITEM_CLASS_GLYPH:
335  {
337  if (prototype->GetBaseRequiredLevel() < static_cast<int32>(value))
338  continue;
340  if (prototype->GetBaseRequiredLevel() > static_cast<int32>(value))
341  continue;
343  if (prototype->GetBaseRequiredLevel() < static_cast<int32>(value))
344  continue;
346  if (prototype->GetBaseRequiredLevel() > static_cast<int32>(value))
347  continue;
348  break;
349  }
351  {
353  if (prototype->GetBaseItemLevel() < value)
354  continue;
356  if (prototype->GetBaseItemLevel() > value)
357  continue;
358  break;
359  }
361  case ITEM_CLASS_QUIVER:
362  {
364  if (prototype->GetBaseItemLevel() < value)
365  continue;
367  if (prototype->GetBaseItemLevel() > value)
368  continue;
369  break;
370  }
371  }
372 
373  _itemPool[prototype->GetQuality()][prototype->GetClass()].push_back(itemId);
374  ++itemsAdded;
375  }
376 
377  if (!itemsAdded)
378  {
379  TC_LOG_ERROR("ahbot", "AuctionHouseBot seller not have items, disabled.");
383  return false;
384  }
385 
386  TC_LOG_DEBUG("ahbot", "AuctionHouseBot seller will use %u items to fill auction house (according your config choices)", itemsAdded);
387 
388  LoadConfig();
389 
390  TC_LOG_DEBUG("ahbot", "Items loaded \tGray\tWhite\tGreen\tBlue\tPurple\tOrange\tYellow");
391  for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i)
392  TC_LOG_DEBUG("ahbot", "\t\t%u\t%u\t%u\t%u\t%u\t%u\t%u",
393  (uint32)_itemPool[0][i].size(), (uint32)_itemPool[1][i].size(), (uint32)_itemPool[2][i].size(),
394  (uint32)_itemPool[3][i].size(), (uint32)_itemPool[4][i].size(), (uint32)_itemPool[5][i].size(),
395  (uint32)_itemPool[6][i].size());
396 
397  TC_LOG_DEBUG("ahbot", "AHBot seller configuration data loaded and initialized");
398  return true;
399 }
uint32 GetBaseItemLevel() const
Definition: ItemTemplate.h:667
uint32 GetLockID() const
Definition: ItemTemplate.h:687
Definition: ItemTemplate.h:373
Definition: AuctionHouseBot.h:129
Definition: ItemTemplate.h:599
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
QueryResult PQuery(Format &&sql, T *conn, Args &&...args)
Definition: DatabaseWorkerPool.h:165
Definition: AuctionHouseBot.h:184
Definition: AuctionHouseBot.h:139
Definition: ItemTemplate.h:382
#define MAX_AUCTION_QUALITY
Definition: AuctionHouseBot.h:38
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: ItemTemplate.h:123
Definition: ItemTemplate.h:376
Definition: AuctionHouseBot.h:59
Definition: AuctionHouseBot.h:171
uint32 GetClass() const
Definition: ItemTemplate.h:653
#define MAX_ITEM_CLASS
Definition: ItemTemplate.h:386
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
uint32 GetRequiredSkillRank() const
Definition: ItemTemplate.h:670
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: AuctionHouseBot.h:55
Definition: AuctionHouseBot.h:176
Definition: AuctionHouseBot.h:177
Definition: AuctionHouseBot.h:168
Definition: ItemTemplate.h:120
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: AuctionHouseBot.h:131
Definition: AuctionHouseBot.h:183
Definition: ItemTemplate.h:119
Definition: AuctionHouseBot.h:133
Definition: AuctionHouseBot.h:130
Definition: AuctionHouseBot.h:169
Definition: AuctionHouseBot.h:136
Definition: ItemTemplate.h:380
Definition: AuctionHouseBot.h:138
Definition: AuctionHouseBot.h:186
Definition: AuctionHouseBot.h:187
Definition: AuctionHouseBot.h:179
Definition: AuctionHouseBot.h:128
Definition: ItemTemplate.h:121
Definition: AuctionHouseBot.h:63
ItemPool _itemPool[MAX_AUCTION_QUALITY][MAX_ITEM_CLASS]
Definition: AuctionHouseBotSeller.h:139
Definition: ItemTemplate.h:122
Definition: ItemTemplate.h:368
Definition: AuctionHouseBot.h:170
uint32 GetSellPrice() const
Definition: ItemTemplate.h:663
DB2Storage< ItemEntry > sItemStore("Item.db2", ItemFormat, HOTFIX_SEL_ITEM)
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
Definition: AuctionHouseBot.h:185
Definition: AuctionHouseBot.h:56
Definition: AuctionHouseBot.h:61
Definition: AuctionHouseBot.h:163
Definition: AuctionHouseBot.h:167
Definition: AuctionHouseBot.h:165
Definition: ItemTemplate.h:378
Definition: AuctionHouseBot.h:135
Definition: AuctionHouseBot.h:188
Definition: AuctionHouseBot.h:62
ItemBondingType GetBonding() const
Definition: ItemTemplate.h:683
Definition: AuctionHouseBot.h:178
Definition: ItemTemplate.h:383
Definition: ItemTemplate.h:369
Definition: ItemTemplate.h:647
Definition: ItemTemplate.h:370
uint32 GetSubClass() const
Definition: ItemTemplate.h:654
Definition: AuctionHouseBot.h:175
Definition: ItemTemplate.h:367
Definition: AuctionHouseBot.h:174
uint32 GetUInt32() const
Definition: Field.h:146
int32 GetBaseRequiredLevel() const
Definition: ItemTemplate.h:668
uint32 GetFlags() const
Definition: ItemTemplate.h:656
void LoadConfig()
Definition: AuctionHouseBotSeller.cpp:401
Definition: AuctionHouseBot.h:58
const FieldDescriptor value
Definition: descriptor.h:1522
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: AuctionHouseBot.h:137
Definition: AuctionHouseBot.h:182
Definition: ItemTemplate.h:372
Definition: AuctionHouseBot.h:166
Definition: Creature.h:383
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
Definition: Creature.h:213
Definition: AuctionHouseBot.h:181
Definition: ItemTemplate.h:379
Definition: AuctionHouseBot.h:164
Definition: AuctionHouseBot.h:134
Definition: ItemTemplate.h:371
Definition: AuctionHouseBot.h:180
Definition: AuctionHouseBot.h:57
Definition: ItemTemplate.h:137
Definition: ItemTemplate.h:374
uint32 GetBuyPrice() const
Definition: ItemTemplate.h:662
Definition: AuctionHouseBot.h:132
Definition: AuctionHouseBot.h:60
uint32 GetQuality() const
Definition: ItemTemplate.h:655

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AuctionBotSeller::LoadConfig ( )
402 {
403  for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i)
404  if (sAuctionBotConfig->GetConfigItemAmountRatio(AuctionHouseType(i)))
406 }
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
AuctionHouseType
Definition: AuctionHouseBot.h:40
#define MAX_AUCTION_HOUSE_TYPE
Definition: AuctionHouseBot.h:47
void LoadSellerValues(SellerConfiguration &config)
Definition: AuctionHouseBotSeller.cpp:568
SellerConfiguration _houseConfig[MAX_AUCTION_HOUSE_TYPE]
Definition: AuctionHouseBotSeller.h:137

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AuctionBotSeller::LoadItemsQuantity ( SellerConfiguration config)
private
409 {
410  uint32 ratio = sAuctionBotConfig->GetConfigItemAmountRatio(config.GetHouseType());
411 
419 
420  // Set quantity wanted but only on possible item color
421  // This avoid any no-exist class-color items selection by random items create function
422  // ============================================================================================
438 
454 
470 
486 
502 
518 
534  // ============================================================================================
535 
536  // Set Stack Quantities
552 
553  // Set the best value to get nearest amount of items wanted
554  for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j)
555  {
556  uint32 index = config.GetItemsAmountPerQuality(AuctionQuality(j)) /
562 
563  for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i)
564  config.SetItemsAmountPerClass(AuctionQuality(j), ItemClass(i), index);
565  }
566 }
AuctionQuality
Definition: AuctionHouseBot.h:27
Definition: AuctionHouseBot.h:143
Definition: ItemTemplate.h:373
Definition: AuctionHouseBot.h:74
Definition: AuctionHouseBot.h:151
Definition: AuctionHouseBot.h:80
Definition: ItemTemplate.h:375
Definition: AuctionHouseBot.h:75
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
Definition: AuctionHouseBot.h:78
Definition: AuctionHouseBot.h:144
AuctionHouseType GetHouseType() const
Definition: AuctionHouseBotSeller.h:70
Definition: AuctionHouseBot.h:34
uint32 GetItemsAmountPerQuality(AuctionQuality quality) const
Definition: AuctionHouseBotSeller.h:101
Definition: AuctionHouseBot.h:32
Definition: AuctionHouseBot.h:67
Definition: ItemTemplate.h:382
#define MAX_AUCTION_QUALITY
Definition: AuctionHouseBot.h:38
Definition: ItemTemplate.h:376
Definition: AuctionHouseBot.h:149
Definition: AuctionHouseBot.h:140
#define MAX_ITEM_CLASS
Definition: ItemTemplate.h:386
Definition: AuctionHouseBot.h:33
Definition: AuctionHouseBot.h:76
Definition: AuctionHouseBot.h:72
Definition: AuctionHouseBot.h:83
Definition: AuctionHouseBot.h:145
Definition: AuctionHouseBot.h:69
Definition: AuctionHouseBot.h:77
Definition: AuctionHouseBot.h:71
Definition: ItemTemplate.h:380
Definition: AuctionHouseBot.h:82
Definition: AuctionHouseBot.h:73
Definition: AuctionHouseBot.h:146
Definition: AuctionHouseBot.h:152
Definition: AuctionHouseBot.h:79
Definition: ItemTemplate.h:368
Definition: AuctionHouseBot.h:154
uint32_t uint32
Definition: Define.h:150
Definition: AuctionHouseBot.h:153
Definition: AuctionHouseBot.h:29
void SetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass, uint32 amount)
Definition: AuctionHouseBotSeller.h:86
Definition: AuctionHouseBot.h:64
Definition: AuctionHouseBot.h:68
ItemClass
Definition: ItemTemplate.h:365
Definition: AuctionHouseBot.h:30
Definition: AuctionHouseBot.h:66
Definition: ItemTemplate.h:378
void SetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass, uint32 qty)
Definition: AuctionHouseBotSeller.h:88
Definition: AuctionHouseBot.h:31
Definition: AuctionHouseBot.h:147
Definition: ItemTemplate.h:383
Definition: ItemTemplate.h:369
Definition: ItemTemplate.h:370
Definition: ItemTemplate.h:367
Definition: AuctionHouseBot.h:148
void SetRandomStackRatioPerClass(ItemClass item, uint32 value)
Definition: AuctionHouseBotSeller.h:106
Definition: AuctionHouseBot.h:35
Definition: AuctionHouseBot.h:150
Definition: AuctionHouseBot.h:84
Definition: AuctionHouseBot.h:70
Definition: AuctionHouseBot.h:81
Definition: ItemTemplate.h:372
Definition: AuctionHouseBot.h:141
Definition: AuctionHouseBot.h:65
Definition: ItemTemplate.h:379
void SetItemsAmountPerQuality(AuctionQuality quality, uint32 cnt)
Definition: AuctionHouseBotSeller.h:100
Definition: ItemTemplate.h:371
Definition: AuctionHouseBot.h:142
Definition: AuctionHouseBot.h:85
Definition: ItemTemplate.h:374

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AuctionBotSeller::LoadSellerValues ( SellerConfiguration config)
private
569 {
570  LoadItemsQuantity(config);
571  uint32 PriceRatio;
572  switch (config.GetHouseType())
573  {
575  PriceRatio = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_ALLIANCE_PRICE_RATIO);
576  break;
577  case AUCTION_HOUSE_HORDE:
578  PriceRatio = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_HORDE_PRICE_RATIO);
579  break;
580  default:
581  PriceRatio = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_NEUTRAL_PRICE_RATIO);
582  break;
583  }
584 
592 
610 
611  //load min and max auction times
614 
615  TC_LOG_DEBUG("ahbot", "AHBot: minTime = %u", config.GetMinTime());
616  TC_LOG_DEBUG("ahbot", "AHBot: maxTime = %u", config.GetMaxTime());
617 
618  TC_LOG_DEBUG("ahbot", "AHBot: For AH type %u", config.GetHouseType());
619  TC_LOG_DEBUG("ahbot", "AHBot: GrayItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_GRAY));
620  TC_LOG_DEBUG("ahbot", "AHBot: WhiteItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_WHITE));
621  TC_LOG_DEBUG("ahbot", "AHBot: GreenItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_GREEN));
622  TC_LOG_DEBUG("ahbot", "AHBot: BlueItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_BLUE));
623  TC_LOG_DEBUG("ahbot", "AHBot: PurpleItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_PURPLE));
624  TC_LOG_DEBUG("ahbot", "AHBot: OrangeItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_ORANGE));
625  TC_LOG_DEBUG("ahbot", "AHBot: YellowItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_YELLOW));
626 }
Definition: ItemTemplate.h:381
Definition: ItemTemplate.h:373
Definition: AuctionHouseBot.h:107
Definition: AuctionHouseBot.h:95
Definition: ItemTemplate.h:375
Definition: AuctionHouseBot.h:52
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
Definition: AuctionHouseBot.h:89
AuctionHouseType GetHouseType() const
Definition: AuctionHouseBotSeller.h:70
Definition: AuctionHouseBot.h:103
Definition: AuctionHouseBot.h:90
Definition: AuctionHouseBot.h:34
Definition: AuctionHouseBot.h:101
uint32 GetItemsAmountPerQuality(AuctionQuality quality) const
Definition: AuctionHouseBotSeller.h:101
Definition: AuctionHouseBot.h:32
Definition: AuctionHouseBot.h:97
Definition: ItemTemplate.h:382
Definition: AuctionHouseBot.h:86
Definition: AuctionHouseBot.h:110
void SetMinTime(uint32 value)
Definition: AuctionHouseBotSeller.h:74
Definition: AuctionHouseBot.h:98
Definition: ItemTemplate.h:376
Definition: AuctionHouseBot.h:99
void LoadItemsQuantity(SellerConfiguration &config)
Definition: AuctionHouseBotSeller.cpp:408
Definition: AuctionHouseBot.h:33
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: AuctionHouseBot.h:88
Definition: ItemTemplate.h:377
Definition: AuctionHouseBot.h:44
void SetPriceRatioPerQuality(AuctionQuality quality, uint32 value)
Definition: AuctionHouseBotSeller.h:102
Definition: AuctionHouseBot.h:102
Definition: ItemTemplate.h:380
uint32 GetMinTime() const
Definition: AuctionHouseBotSeller.h:78
void SetPriceRatioPerClass(ItemClass item, uint32 value)
Definition: AuctionHouseBotSeller.h:104
Definition: ItemTemplate.h:368
Definition: AuctionHouseBot.h:112
uint32_t uint32
Definition: Define.h:150
Definition: AuctionHouseBot.h:96
Definition: AuctionHouseBot.h:29
Definition: AuctionHouseBot.h:51
Definition: AuctionHouseBot.h:94
Definition: AuctionHouseBot.h:91
Definition: AuctionHouseBot.h:30
Definition: ItemTemplate.h:378
Definition: AuctionHouseBot.h:104
Definition: AuctionHouseBot.h:31
Definition: AuctionHouseBot.h:105
Definition: ItemTemplate.h:383
Definition: ItemTemplate.h:369
Definition: ItemTemplate.h:370
Definition: AuctionHouseBot.h:93
Definition: ItemTemplate.h:367
Definition: AuctionHouseBot.h:35
Definition: AuctionHouseBot.h:87
Definition: AuctionHouseBot.h:106
Definition: AuctionHouseBot.h:109
Definition: AuctionHouseBot.h:111
Definition: AuctionHouseBot.h:100
uint32 GetMaxTime() const
Definition: AuctionHouseBotSeller.h:84
Definition: ItemTemplate.h:372
Definition: AuctionHouseBot.h:92
Definition: ItemTemplate.h:379
Definition: ItemTemplate.h:371
Definition: AuctionHouseBot.h:43
void SetMaxTime(uint32 value)
Definition: AuctionHouseBotSeller.h:83
Definition: ItemTemplate.h:374
Definition: AuctionHouseBot.h:108

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AuctionBotSeller::SetItemsAmount ( uint32(&)  vals[MAX_AUCTION_QUALITY])
881 {
889 
890  for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i)
892 }
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
Definition: AuctionHouseBot.h:34
Definition: AuctionHouseBot.h:32
Definition: AuctionHouseBot.h:67
void LoadItemsQuantity(SellerConfiguration &config)
Definition: AuctionHouseBotSeller.cpp:408
Definition: AuctionHouseBot.h:33
Definition: AuctionHouseBot.h:69
#define MAX_AUCTION_HOUSE_TYPE
Definition: AuctionHouseBot.h:47
Definition: AuctionHouseBot.h:29
Definition: AuctionHouseBot.h:64
Definition: AuctionHouseBot.h:68
Definition: AuctionHouseBot.h:30
Definition: AuctionHouseBot.h:66
Definition: AuctionHouseBot.h:31
Definition: AuctionHouseBot.h:35
SellerConfiguration _houseConfig[MAX_AUCTION_HOUSE_TYPE]
Definition: AuctionHouseBotSeller.h:137
Definition: AuctionHouseBot.h:70
Definition: AuctionHouseBot.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AuctionBotSeller::SetItemsAmountForQuality ( AuctionQuality  quality,
uint32  val 
)
895 {
896  switch (quality)
897  {
899  sAuctionBotConfig->SetConfig(CONFIG_AHBOT_ITEM_GRAY_AMOUNT, val); break;
901  sAuctionBotConfig->SetConfig(CONFIG_AHBOT_ITEM_WHITE_AMOUNT, val); break;
903  sAuctionBotConfig->SetConfig(CONFIG_AHBOT_ITEM_GREEN_AMOUNT, val); break;
905  sAuctionBotConfig->SetConfig(CONFIG_AHBOT_ITEM_BLUE_AMOUNT, val); break;
907  sAuctionBotConfig->SetConfig(CONFIG_AHBOT_ITEM_PURPLE_AMOUNT, val); break;
909  sAuctionBotConfig->SetConfig(CONFIG_AHBOT_ITEM_ORANGE_AMOUNT, val); break;
910  default:
911  sAuctionBotConfig->SetConfig(CONFIG_AHBOT_ITEM_YELLOW_AMOUNT, val); break;
912  }
913 
914  for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i)
916 }
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
Definition: AuctionHouseBot.h:34
Definition: AuctionHouseBot.h:32
Definition: AuctionHouseBot.h:67
void LoadItemsQuantity(SellerConfiguration &config)
Definition: AuctionHouseBotSeller.cpp:408
Definition: AuctionHouseBot.h:33
Definition: AuctionHouseBot.h:69
#define MAX_AUCTION_HOUSE_TYPE
Definition: AuctionHouseBot.h:47
Definition: AuctionHouseBot.h:29
Definition: AuctionHouseBot.h:64
Definition: AuctionHouseBot.h:68
Definition: AuctionHouseBot.h:30
Definition: AuctionHouseBot.h:66
Definition: AuctionHouseBot.h:31
SellerConfiguration _houseConfig[MAX_AUCTION_HOUSE_TYPE]
Definition: AuctionHouseBotSeller.h:137
Definition: AuctionHouseBot.h:70
Definition: AuctionHouseBot.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AuctionBotSeller::SetItemsRatio ( uint32  al,
uint32  ho,
uint32  ne 
)
857 {
861 
862  for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i)
864 }
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
void LoadItemsQuantity(SellerConfiguration &config)
Definition: AuctionHouseBotSeller.cpp:408
Definition: AuctionHouseBot.h:55
T max(const T &x, const T &y)
Definition: g3dmath.h:320
#define MAX_AUCTION_HOUSE_TYPE
Definition: AuctionHouseBot.h:47
Definition: AuctionHouseBot.h:56
SellerConfiguration _houseConfig[MAX_AUCTION_HOUSE_TYPE]
Definition: AuctionHouseBotSeller.h:137
Definition: AuctionHouseBot.h:57

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AuctionBotSeller::SetItemsRatioForHouse ( AuctionHouseType  house,
uint32  val 
)
867 {
868  val = std::max(val, 10000u); // apply same upper limit as used for config load
869 
870  switch (house)
871  {
874  default: sAuctionBotConfig->SetConfig(CONFIG_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO, val); break;
875  }
876 
878 }
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
void LoadItemsQuantity(SellerConfiguration &config)
Definition: AuctionHouseBotSeller.cpp:408
Definition: AuctionHouseBot.h:55
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Definition: AuctionHouseBot.h:44
Definition: AuctionHouseBot.h:56
SellerConfiguration _houseConfig[MAX_AUCTION_HOUSE_TYPE]
Definition: AuctionHouseBotSeller.h:137
Definition: AuctionHouseBot.h:43
Definition: AuctionHouseBot.h:57

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AuctionBotSeller::SetPricesOfItem ( ItemTemplate const itemProto,
SellerConfiguration config,
uint32 buyp,
uint32 bidp,
uint32  stackcnt 
)
private
701 {
702  uint32 classRatio = config.GetPriceRatioPerClass(ItemClass(itemProto->GetClass()));
703  uint32 qualityRatio = config.GetPriceRatioPerQuality(AuctionQuality(itemProto->GetQuality()));
704  uint32 priceRatio = (classRatio * qualityRatio) / 100;
705 
706  uint32 buyPrice = itemProto->GetBuyPrice();
707  uint32 sellPrice = itemProto->GetSellPrice();
708 
709  if (buyPrice == 0)
710  {
711  if (sellPrice > 0)
712  buyPrice = sellPrice * GetSellModifier(itemProto);
713  else
714  {
715  uint32 divisor = ((itemProto->GetClass() == ITEM_CLASS_WEAPON || itemProto->GetClass() == ITEM_CLASS_ARMOR) ? 284 : 80);
716  uint32 tempLevel = (itemProto->GetBaseItemLevel() == 0 ? 1 : itemProto->GetBaseItemLevel());
717  uint32 tempQuality = (itemProto->GetQuality() == 0 ? 1 : itemProto->GetQuality());
718 
719  buyPrice = tempLevel * tempQuality * GetBuyModifier(itemProto)* tempLevel / divisor;
720  }
721  }
722 
723  if (sellPrice == 0)
724  sellPrice = (buyPrice > 10 ? buyPrice / GetSellModifier(itemProto) : buyPrice);
725 
727  buyPrice = sellPrice;
728 
729  uint32 basePrice = (buyPrice * stackCount * priceRatio) / (itemProto->GetClass() == 6 ? 200 : itemProto->GetBuyCount()) / 100;
730  uint32 range = basePrice * 0.04;
731 
732  buyp = urand(basePrice - range, basePrice + range) + 1;
733 
734  basePrice = buyp * .5;
735  range = buyp * .4;
736  bidp = urand(basePrice - range, basePrice + range) + 1;
737 }
AuctionQuality
Definition: AuctionHouseBot.h:27
static uint32 GetBuyModifier(ItemTemplate const *prototype)
Definition: AuctionHouseBotSeller.cpp:764
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
Definition: AuctionHouseBot.h:171
uint32 GetPriceRatioPerClass(ItemClass item) const
Definition: AuctionHouseBotSeller.h:105
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
uint32_t uint32
Definition: Define.h:150
ItemClass
Definition: ItemTemplate.h:365
static uint32 GetSellModifier(ItemTemplate const *itemProto)
Definition: AuctionHouseBotSeller.cpp:749
Definition: ItemTemplate.h:369
uint32 GetPriceRatioPerQuality(AuctionQuality quality) const
Definition: AuctionHouseBotSeller.h:103
Definition: ItemTemplate.h:371

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 AuctionBotSeller::SetStat ( SellerConfiguration config)
private
631 {
632  AllItemsArray itemsSaved(MAX_AUCTION_QUALITY, std::vector<uint32>(MAX_ITEM_CLASS));
633 
634  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
635  for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr)
636  {
637  AuctionEntry* auctionEntry = itr->second;
638  Item* item = sAuctionMgr->GetAItem(auctionEntry->itemGUIDLow);
639  if (item)
640  {
641  ItemTemplate const* prototype = item->GetTemplate();
642  if (prototype)
643  if (!auctionEntry->owner) // Add only ahbot items
644  ++itemsSaved[prototype->GetQuality()][prototype->GetClass()];
645  }
646  }
647 
648  uint32 count = 0;
649  for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j)
650  {
651  for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i)
652  {
653  config.SetMissedItemsPerClass((AuctionQuality)j, (ItemClass)i, itemsSaved[j][i]);
654  count += config.GetMissedItemsPerClass((AuctionQuality)j, (ItemClass)i);
655  }
656  }
657 
658  TC_LOG_DEBUG("ahbot", "AHBot: Missed Item \tGray\tWhite\tGreen\tBlue\tPurple\tOrange\tYellow");
659  for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i)
660  {
661  TC_LOG_DEBUG("ahbot", "AHBot: \t\t%u\t%u\t%u\t%u\t%u\t%u\t%u",
669  }
670  config.LastMissedItem = count;
671 
672  return count;
673 }
uint32 LastMissedItem
Definition: AuctionHouseBotSeller.h:72
AuctionQuality
Definition: AuctionHouseBot.h:27
AuctionEntryMap::iterator GetAuctionsEnd()
Definition: AuctionHouseMgr.h:114
AuctionHouseType GetHouseType() const
Definition: AuctionHouseBotSeller.h:70
Definition: AuctionHouseBot.h:34
Definition: AuctionHouseBot.h:32
ObjectGuid::LowType itemGUIDLow
Definition: AuctionHouseMgr.h:71
#define MAX_AUCTION_QUALITY
Definition: AuctionHouseBot.h:38
Definition: AuctionHouseMgr.h:67
uint32 GetClass() const
Definition: ItemTemplate.h:653
#define MAX_ITEM_CLASS
Definition: ItemTemplate.h:386
Definition: AuctionHouseBot.h:33
AuctionEntryMap::iterator GetAuctionsBegin()
Definition: AuctionHouseMgr.h:113
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass, uint32 found)
Definition: AuctionHouseBotSeller.h:90
std::vector< std::vector< uint32 > > AllItemsArray
Definition: AuctionHouseBotSeller.h:32
uint32 GetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass) const
Definition: AuctionHouseBotSeller.h:97
ObjectGuid::LowType owner
Definition: AuctionHouseMgr.h:74
Definition: Item.h:259
uint32_t uint32
Definition: Define.h:150
Definition: AuctionHouseBot.h:29
ItemClass
Definition: ItemTemplate.h:365
Definition: AuctionHouseBot.h:30
Definition: AuctionHouseBot.h:31
Definition: ItemTemplate.h:647
Definition: AuctionHouseBot.h:35
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
Definition: AuctionHouseMgr.h:100
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
uint32 GetQuality() const
Definition: ItemTemplate.h:655

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AuctionBotSeller::Update ( AuctionHouseType  houseType)
overridevirtual

Implements AuctionBotAgent.

1046 {
1047  if (sAuctionBotConfig->GetConfigItemAmountRatio(houseType) > 0)
1048  {
1049  TC_LOG_DEBUG("ahbot", "AHBot: %s selling ...", AuctionBotConfig::GetHouseTypeName(houseType));
1050  if (SetStat(_houseConfig[houseType]))
1051  AddNewAuctions(_houseConfig[houseType]);
1052  return true;
1053  }
1054  else
1055  return false;
1056 }
#define sAuctionBotConfig
Definition: AuctionHouseBot.h:252
void AddNewAuctions(SellerConfiguration &config)
Definition: AuctionHouseBotSeller.cpp:920
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
static char const * GetHouseTypeName(AuctionHouseType houseType)
Definition: AuctionHouseBot.cpp:269
uint32 SetStat(SellerConfiguration &config)
Definition: AuctionHouseBotSeller.cpp:630
SellerConfiguration _houseConfig[MAX_AUCTION_HOUSE_TYPE]
Definition: AuctionHouseBotSeller.h:137

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

SellerConfiguration AuctionBotSeller::_houseConfig[MAX_AUCTION_HOUSE_TYPE]
private
ItemPool AuctionBotSeller::_itemPool[MAX_AUCTION_QUALITY][MAX_ITEM_CLASS]
private

The documentation for this class was generated from the following files: