├── .editorconfig ├── .gitattributes ├── .gitignore ├── CMakeLists.txt ├── README.md ├── ahbot.patch ├── cmake ├── after_game_lib.cmake ├── after_load_conf.cmake ├── after_ws_install.cmake ├── before_game_lib.cmake └── before_scripts_lib.cmake ├── conf └── mod_ahbot.conf.dist ├── include.sh ├── sql ├── auth │ └── .gitkeep ├── characters │ └── .gitkeep └── world │ ├── .gitkeep │ └── auctionhousebot.sql └── src ├── AuctionHouseBot.cpp ├── AuctionHouseBot.h ├── cs_ah_bot.cpp └── loader_cs_ah_bot.h /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | charset = utf-8 3 | indent_style = space 4 | indent_size = 4 5 | tab_width = 4 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | max_line_length = 80 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ## AUTO-DETECT 2 | ## Handle line endings automatically for files detected as 3 | ## text and leave all files detected as binary untouched. 4 | ## This will handle all files NOT defined below. 5 | * text=auto eol=lf 6 | 7 | # Text 8 | *.conf 9 | *.conf.dist 10 | *.txt 11 | *.md 12 | *.cmake 13 | 14 | # Bash 15 | *.sh text 16 | 17 | # Lua if lua module? 18 | *.lua 19 | 20 | # SQL 21 | *.sql 22 | 23 | # C++ 24 | *.c text 25 | *.cc text 26 | *.cxx text 27 | *.cpp text 28 | *.c++ text 29 | *.hpp text 30 | *.h text 31 | *.h++ text 32 | *.hh text 33 | 34 | 35 | ## For documentation 36 | 37 | # Documents 38 | *.doc diff=astextplain 39 | *.DOC diff=astextplain 40 | *.docx diff=astextplain 41 | *.DOCX diff=astextplain 42 | *.dot diff=astextplain 43 | *.DOT diff=astextplain 44 | *.pdf diff=astextplain 45 | *.PDF diff=astextplain 46 | *.rtf diff=astextplain 47 | *.RTF diff=astextplain 48 | 49 | 50 | # Graphics 51 | *.png binary 52 | *.jpg binary 53 | *.jpeg binary 54 | *.gif binary 55 | *.tif binary 56 | *.tiff binary 57 | *.ico binary 58 | # SVG treated as an asset (binary) by default. If you want to treat it as text, 59 | # comment-out the following line and uncomment the line after. 60 | *.svg binary 61 | #*.svg text 62 | *.eps binary 63 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore 2 | 3 | # 4 | #Generic 5 | # 6 | 7 | .directory 8 | .mailmap 9 | *.orig 10 | *.rej 11 | *~ 12 | .hg/ 13 | *.kdev* 14 | .DS_Store 15 | CMakeLists.txt.user 16 | *.bak 17 | *.patch 18 | *.diff 19 | *.REMOTE.* 20 | *.BACKUP.* 21 | *.BASE.* 22 | *.LOCAL.* 23 | 24 | # 25 | # IDE & other softwares 26 | # 27 | /.settings/ 28 | /.externalToolBuilders/* 29 | # exclude in all levels 30 | nbproject/ 31 | .sync.ffs_db 32 | *.kate-swp 33 | 34 | # 35 | # Eclipse 36 | # 37 | *.pydevproject 38 | .metadata 39 | .gradle 40 | tmp/ 41 | *.tmp 42 | *.swp 43 | *~.nib 44 | local.properties 45 | .settings/ 46 | .loadpath 47 | .project 48 | .cproject 49 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CU_SET_PATH("CMAKE_MOD_AHBOT_DIR" "${CMAKE_CURRENT_LIST_DIR}") 2 | CU_ADD_HOOK(AFTER_LOAD_CONF "${CMAKE_CURRENT_LIST_DIR}/cmake/after_load_conf.cmake") 3 | CU_ADD_HOOK(BEFORE_GAME_LIBRARY "${CMAKE_CURRENT_LIST_DIR}/cmake/before_game_lib.cmake") 4 | CU_ADD_HOOK(BEFORE_SCRIPTS_LIBRARY "${CMAKE_CURRENT_LIST_DIR}/cmake/before_scripts_lib.cmake") 5 | CU_ADD_HOOK(AFTER_GAME_LIBRARY "${CMAKE_CURRENT_LIST_DIR}/cmake/after_game_lib.cmake") 6 | AC_ADD_SCRIPT("${CMAKE_CURRENT_LIST_DIR}/src/cs_ah_bot.cpp") 7 | AC_ADD_SCRIPT_LOADER("AHBotCommand" "${CMAKE_CURRENT_LIST_DIR}/src/loader_cs_ah_bot.h") 8 | CU_ADD_HOOK(AFTER_WORLDSERVER_CMAKE "${CMAKE_CURRENT_LIST_DIR}/cmake/after_ws_install.cmake") -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mod-AHBOT 2 | 3 | 4 | ## Description 5 | 6 | A ahbot module for azerothcore. 7 | 8 | 9 | ## Installation 10 | 11 | ``` 12 | 1. Apply ahbot.patch to your core. 13 | 2. Simply place the module under the `modules` directory of your AzerothCore source. 14 | 3. Import the SQL manually to the right Database (auth, world or characters) or with the `db_assembler.sh` (if `include.sh` provided). 15 | 4. Re-run cmake and launch a clean build of AzerothCore. 16 | ``` 17 | 18 | ## Edit module configuration (optional) 19 | 20 | If you need to change the module configuration, go to your server configuration folder (where your `worldserver` or `worldserver.exe` is) 21 | rename the file mod_ahbot.conf.dist to mod_ahbot.conf and edit it. 22 | 23 | 24 | ## Credits 25 | ayase 26 | 27 | -------------------------------------------------------------------------------- /ahbot.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index 32edeb3458..35385f2271 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -46,6 +46,27 @@ if(EXISTS "conf/config.cmake") 6 | include(conf/config.cmake) 7 | endif() 8 | 9 | +# 10 | +# Loading dyn modules 11 | +# 12 | + 13 | +# add modules and dependencies 14 | +CU_SUBDIRLIST(sub_DIRS "${CMAKE_SOURCE_DIR}/modules" FALSE FALSE) 15 | +FOREACH(subdir ${sub_DIRS}) 16 | + 17 | + get_filename_component(MODULENAME ${subdir} NAME) 18 | + 19 | + if (";${DISABLED_AC_MODULES};" MATCHES ";${MODULENAME};") 20 | + continue() 21 | + endif() 22 | + 23 | + STRING(REGEX REPLACE "^${CMAKE_SOURCE_DIR}/" "" subdir_rel ${subdir}) 24 | + if(EXISTS "${subdir}/CMakeLists.txt") 25 | + message("Loading module: ${subdir_rel}") 26 | + add_subdirectory("${subdir_rel}") 27 | + endif() 28 | +ENDFOREACH() 29 | + 30 | CU_RUN_HOOK("AFTER_LOAD_CONF") 31 | 32 | # build in Release-mode by default if not explicitly set 33 | @@ -107,26 +128,6 @@ if( TOOLS ) 34 | add_subdirectory(src/tools) 35 | endif() 36 | 37 | -# 38 | -# Loading dyn modules 39 | -# 40 | - 41 | -# add modules and dependencies 42 | -CU_SUBDIRLIST(sub_DIRS "${CMAKE_SOURCE_DIR}/modules" FALSE FALSE) 43 | -FOREACH(subdir ${sub_DIRS}) 44 | - 45 | - get_filename_component(MODULENAME ${subdir} NAME) 46 | - 47 | - if (";${DISABLED_AC_MODULES};" MATCHES ";${MODULENAME};") 48 | - continue() 49 | - endif() 50 | - 51 | - STRING(REGEX REPLACE "^${CMAKE_SOURCE_DIR}/" "" subdir_rel ${subdir}) 52 | - if(EXISTS "${subdir}/CMakeLists.txt") 53 | - message("Loading module: ${subdir_rel}") 54 | - add_subdirectory("${subdir_rel}") 55 | - endif() 56 | -ENDFOREACH() 57 | 58 | # 59 | # Loading application sources 60 | diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp 61 | index 4aba5703b2..5c9a332016 100644 62 | --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp 63 | +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp 64 | @@ -21,6 +21,9 @@ 65 | #include 66 | #include "AvgDiffTracker.h" 67 | #include "AsyncAuctionListing.h" 68 | +#ifdef MOD_AH_BOT 69 | +#include "AuctionHouseBot.h" 70 | +#endif 71 | 72 | enum eAuctionHouse 73 | { 74 | @@ -139,8 +142,11 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, SQLTransa 75 | if (owner || owner_accId) 76 | { 77 | uint32 profit = auction->bid + auction->deposit - auction->GetAuctionCut(); 78 | - 79 | +#ifdef MOD_AH_BOT 80 | + if (owner && owner->GetGUIDLow() != auctionbot->GetAHBplayerGUID()) 81 | +#else 82 | if (owner) 83 | +#endif 84 | { 85 | owner->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS, profit); 86 | owner->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD, auction->bid); 87 | @@ -183,7 +189,11 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti 88 | // owner exist 89 | if (owner || owner_accId) 90 | { 91 | +#ifdef MOD_AH_BOT 92 | + if (owner && owner->GetGUIDLow() != auctionbot->GetAHBplayerGUID()) 93 | +#else 94 | if (owner) 95 | +#endif 96 | owner->GetSession()->SendAuctionOwnerNotification(auction); 97 | 98 | MailDraft(auction->BuildAuctionMailSubject(AUCTION_EXPIRED), AuctionEntry::BuildAuctionMailBody(0, 0, auction->buyout, auction->deposit, 0)) 99 | @@ -207,6 +217,11 @@ void AuctionHouseMgr::SendAuctionOutbiddedMail(AuctionEntry* auction, uint32 new 100 | // old bidder exist 101 | if (oldBidder || oldBidder_accId) 102 | { 103 | +#ifdef MOD_AH_BOT 104 | + if (oldBidder && !newBidder) 105 | + oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, auctionbot->GetAHBplayerGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template); 106 | +#endif // MOD_AH_BOT 107 | + 108 | if (oldBidder && newBidder) 109 | oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, newBidder->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template); 110 | 111 | @@ -407,10 +422,16 @@ void AuctionHouseObject::AddAuction(AuctionEntry* auction) 112 | 113 | AuctionsMap[auction->Id] = auction; 114 | sScriptMgr->OnAuctionAdd(this, auction); 115 | +#ifdef MOD_AH_BOT 116 | + auctionbot->IncrementItemCounts(auction); 117 | +#endif 118 | } 119 | 120 | bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction) 121 | { 122 | +#ifdef MOD_AH_BOT 123 | + auctionbot->DecrementItemCounts(auction, auction->item_template); 124 | +#endif 125 | bool wasInMap = AuctionsMap.erase(auction->Id) ? true : false; 126 | 127 | sScriptMgr->OnAuctionRemove(this, auction); 128 | diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp 129 | index ef72cbfe2c..2f57ac9687 100644 130 | --- a/src/server/game/Mails/Mail.cpp 131 | +++ b/src/server/game/Mails/Mail.cpp 132 | @@ -15,6 +15,9 @@ 133 | #include "Item.h" 134 | #include "AuctionHouseMgr.h" 135 | #include "CalendarMgr.h" 136 | +#ifdef MOD_AH_BOT 137 | +#include "AuctionHouseBot.h" 138 | +#endif 139 | 140 | MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery(stationery) 141 | { 142 | @@ -168,6 +171,15 @@ void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, 143 | 144 | uint32 mailId = sObjectMgr->GenerateMailID(); 145 | 146 | +#ifdef MOD_AH_BOT 147 | + if (receiver.GetPlayerGUIDLow() == auctionbot->GetAHBplayerGUID()) 148 | + { 149 | + if (sender.GetMailMessageType() == MAIL_AUCTION) // auction mail with items 150 | + deleteIncludedItems(trans, true); 151 | + return; 152 | + } 153 | +#endif 154 | + 155 | time_t deliver_time = time(NULL) + deliver_delay; 156 | 157 | //expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour 158 | diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp 159 | index 01b1fe0acb..38b0e5fc90 100644 160 | --- a/src/server/game/World/World.cpp 161 | +++ b/src/server/game/World/World.cpp 162 | @@ -76,6 +76,9 @@ 163 | #include "AsyncAuctionListing.h" 164 | #include "SavingSystem.h" 165 | #include 166 | +#ifdef MOD_AH_BOT 167 | +#include "AuctionHouseBot.h" 168 | +#endif 169 | 170 | ACE_Atomic_Op World::m_stopEvent = false; 171 | uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; 172 | @@ -1635,6 +1638,20 @@ void World::SetInitialWorldSettings() 173 | sLog->outString("Loading Completed Achievements..."); 174 | sAchievementMgr->LoadCompletedAchievements(); 175 | 176 | +#ifdef MOD_AH_BOT 177 | + std::string conf_path = _CONF_DIR; 178 | + std::string cfg_file = conf_path + "/mod_ahbot.conf"; 179 | +#ifdef WIN32 180 | + cfg_file = "mod_ahbot.conf"; 181 | +#endif 182 | + std::string cfg_def_file = cfg_file + ".dist"; 183 | + sConfigMgr->LoadMore(cfg_def_file.c_str()); 184 | + sConfigMgr->LoadMore(cfg_file.c_str()); 185 | + 186 | + // Initialize AHBot settings before deleting expired auctions due to AHBot hooks 187 | + auctionbot->InitializeConfiguration(); 188 | +#endif 189 | + 190 | ///- Load dynamic data tables from the database 191 | sLog->outString("Loading Item Auctions..."); 192 | sAuctionMgr->LoadAuctionItems(); 193 | @@ -1871,6 +1888,11 @@ void World::SetInitialWorldSettings() 194 | mgr = ChannelMgr::forTeam(TEAM_HORDE); 195 | mgr->LoadChannels(); 196 | 197 | +#ifdef MOD_AH_BOT 198 | + sLog->outString("Initialize AuctionHouseBot..."); 199 | + auctionbot->Initialize(); 200 | +#endif 201 | + 202 | uint32 startupDuration = GetMSTimeDiffToNow(startupBegin); 203 | sLog->outString(); 204 | sLog->outError("WORLD: World initialized in %u minutes %u seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000)); 205 | @@ -2031,6 +2053,9 @@ void World::Update(uint32 diff) 206 | // pussywizard: handle auctions when the timer has passed 207 | if (m_timers[WUPDATE_AUCTIONS].Passed()) 208 | { 209 | +#ifdef MOD_AH_BOT 210 | + auctionbot->Update(); 211 | +#endif 212 | m_timers[WUPDATE_AUCTIONS].Reset(); 213 | 214 | // pussywizard: handle expired auctions, auctions expired when realm was offline are also handled here (not during loading when many required things aren't loaded yet) 215 | -------------------------------------------------------------------------------- /cmake/after_game_lib.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_MOD_AHBOT_DIR}/src) -------------------------------------------------------------------------------- /cmake/after_load_conf.cmake: -------------------------------------------------------------------------------- 1 | add_definitions(-DMOD_AH_BOT) -------------------------------------------------------------------------------- /cmake/after_ws_install.cmake: -------------------------------------------------------------------------------- 1 | if( WIN32 ) 2 | if ( MSVC ) 3 | add_custom_command(TARGET worldserver 4 | POST_BUILD 5 | COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_MOD_AHBOT_DIR}/conf/mod_ahbot.conf.dist" ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/ 6 | ) 7 | elseif ( MINGW ) 8 | add_custom_command(TARGET worldserver 9 | POST_BUILD 10 | COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_MOD_AHBOT_DIR}/conf/mod_ahbot.conf.dist" ${CMAKE_BINARY_DIR}/bin/ 11 | ) 12 | endif() 13 | endif() 14 | 15 | install(FILES "${CMAKE_MOD_AHBOT_DIR}/conf/mod_ahbot.conf.dist" DESTINATION ${CONF_DIR}) -------------------------------------------------------------------------------- /cmake/before_game_lib.cmake: -------------------------------------------------------------------------------- 1 | set(game_STAT_SRCS 2 | ${game_STAT_SRCS} 3 | ${CMAKE_MOD_AHBOT_DIR}/src/AuctionHouseBot.cpp 4 | ${CMAKE_MOD_AHBOT_DIR}/src/AuctionHouseBot.h 5 | ) 6 | -------------------------------------------------------------------------------- /cmake/before_scripts_lib.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_MOD_AHBOT_DIR}/src) -------------------------------------------------------------------------------- /conf/mod_ahbot.conf.dist: -------------------------------------------------------------------------------- 1 | 2 | ############################################################################### 3 | # AUCTION HOUSE BOT SETTINGS 4 | # 5 | # AuctionHouseBot.DEBUG 6 | # Enable/Disable Debugging output 7 | # Default 0 (disabled) 8 | # 9 | # AuctionHouseBot.DEBUG_FILTERS 10 | # Enable/Disable Debugging output from Filters 11 | # Default 0 (disabled) 12 | # 13 | # AuctionHouseBot.EnableSeller 14 | # Enable/Disable the part of AHBot that puts items up for auction 15 | # Default 0 (disabled) 16 | # 17 | # AuctionHouseBot.EnableBuyer 18 | # Enable/Disable the part of AHBot that buys items from players 19 | # Default 0 (disabled) 20 | # 21 | # AuctionHouseBot.UseBuyPriceForSeller 22 | # Should the Seller use BuyPrice or SellPrice to determine Bid Prices 23 | # Default 0 (use SellPrice) 24 | # 25 | # AuctionHouseBot.UseBuyPriceForBuyer 26 | # Should the Buyer use BuyPrice or SellPrice to determine Bid Prices 27 | # Default 0 (use SellPrice) 28 | # 29 | # Auction House Bot character data 30 | # AuctionHouseBot.Account is the account number 31 | # (in realmd->account table) of the player you want to run 32 | # as the auction bot. 33 | # AuctionHouseBot.GUID is the GUID (in characters->characters table) 34 | # of the player you want to run as the auction bot. 35 | # Default: 0 (Auction House Bot disabled) 36 | # 37 | # AuctionHouseBot.ItemsPerCycle 38 | # Number of Items to Add/Remove from the AH during mass operations 39 | # Default 200 40 | # 41 | ############################################################################### 42 | 43 | AuctionHouseBot.DEBUG = 0 44 | AuctionHouseBot.DEBUG_FILTERS = 0 45 | AuctionHouseBot.EnableSeller = 0 46 | AuctionHouseBot.EnableBuyer = 0 47 | AuctionHouseBot.UseBuyPriceForSeller = 0 48 | AuctionHouseBot.UseBuyPriceForBuyer = 0 49 | AuctionHouseBot.Account = 0 50 | AuctionHouseBot.GUID = 0 51 | AuctionHouseBot.ItemsPerCycle = 200 52 | 53 | ############################################################################### 54 | # AUCTION HOUSE BOT FILTERS PART 1 55 | # 56 | # AuctionHouseBot.VendorItems 57 | # Include items that can be bought from vendors. 58 | # Default 0 (False) 59 | # 60 | # AuctionHouseBot.VendorTradeGoods 61 | # Include Trade Goods that can be bought from vendors. 62 | # Default 0 (False) 63 | # 64 | # AuctionHouseBot.LootItems 65 | # Include items that can be looted or fished for. 66 | # Default 1 (True) 67 | # 68 | # AuctionHouseBot.LootTradeGoods 69 | # Include Trade Goods that can be looted or fished for. 70 | # Default 1 (True) 71 | # 72 | # AuctionHouseBot.OtherItems 73 | # Include misc. items. 74 | # Default 0 (False) 75 | # 76 | # AuctionHouseBot.OtherTradeGoods 77 | # Include misc. Trade Goods. 78 | # Default 0 (False) 79 | # 80 | # AuctionHouseBot.Bonding_types 81 | # Indicates which bonding types to allow seller to put up for auction 82 | # No_Bind 83 | # Default 1 (True) 84 | # Bind_When_Picked_Up 85 | # Default 0 (False) 86 | # Bind_When_Equipped 87 | # Default 1 (True) 88 | # Bind_When_Use 89 | # Default 1 (True) 90 | # Bind_Quest_Item 91 | # Default 0 (False) 92 | # 93 | # AuctionHouseBot.DisableBeta_PTR_Unused 94 | # Disable certain items that are usually unavailable to Players 95 | # Default 0 (False) 96 | # 97 | # AuctionHouseBot.DisablePermEnchant 98 | # Disable Items with a Permanent Enchantment 99 | # Default 0 (False) 100 | # 101 | # AuctionHouseBot.DisableConjured 102 | # Disable Conjured Items 103 | # Default 0 (False) 104 | # 105 | # AuctionHouseBot.DisableGems 106 | # Disable Gems 107 | # Default 0 (False) 108 | # 109 | # AuctionHouseBot.DisableMoney 110 | # Disable Items that are used as money 111 | # Default 0 (False) 112 | # 113 | # AuctionHouseBot.DisableMoneyLoot 114 | # Disable Items that have Money as a loot 115 | # Default 0 (False) 116 | # 117 | # AuctionHouseBot.DisableLootable 118 | # Disable Items that have other items as loot 119 | # Default 0 (False) 120 | # 121 | # AuctionHouseBot.DisableKeys 122 | # Disable Items that are keys 123 | # Default 0 (False) 124 | # 125 | # AuctionHouseBot.DisableDuration 126 | # Disable Items with a duration 127 | # Default 0 (False) 128 | # 129 | # AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel 130 | # Disable items that are BOP or Quest Item 131 | # with a Required level that is less than the Item Level 132 | # (This prevents a level 10 with a level 60 weapon or armor) 133 | # (May need further refinement) 134 | # Default 0 (False) 135 | # 136 | ############################################################################### 137 | 138 | AuctionHouseBot.VendorItems = 0 139 | AuctionHouseBot.VendorTradeGoods = 0 140 | AuctionHouseBot.LootItems = 1 141 | AuctionHouseBot.LootTradeGoods = 1 142 | AuctionHouseBot.OtherItems = 0 143 | AuctionHouseBot.OtherTradeGoods = 0 144 | AuctionHouseBot.No_Bind = 1 145 | AuctionHouseBot.Bind_When_Picked_Up = 0 146 | AuctionHouseBot.Bind_When_Equipped = 1 147 | AuctionHouseBot.Bind_When_Use = 1 148 | AuctionHouseBot.Bind_Quest_Item = 0 149 | AuctionHouseBot.DisableBeta_PTR_Unused = 0 150 | AuctionHouseBot.DisablePermEnchant = 0 151 | AuctionHouseBot.DisableConjured = 0 152 | AuctionHouseBot.DisableGems = 0 153 | AuctionHouseBot.DisableMoney = 0 154 | AuctionHouseBot.DisableMoneyLoot = 0 155 | AuctionHouseBot.DisableLootable = 0 156 | AuctionHouseBot.DisableKeys = 0 157 | AuctionHouseBot.DisableDuration = 0 158 | AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel = 0 159 | 160 | ############################################################################### 161 | # AUCTION HOUSE BOT FILTERS PART 2 162 | # 163 | # These Filters are boolean (0 or 1) and will disable items that are 164 | # specifically meant for the Class named. 165 | # (UnusedClass is Class 10, which was skipped for some reason) 166 | # Default 0 (allowed) 167 | # 168 | ############################################################################### 169 | 170 | AuctionHouseBot.DisableWarriorItems = 0 171 | AuctionHouseBot.DisablePaladinItems = 0 172 | AuctionHouseBot.DisableHunterItems = 0 173 | AuctionHouseBot.DisableRogueItems = 0 174 | AuctionHouseBot.DisablePriestItems = 0 175 | AuctionHouseBot.DisableDKItems = 0 176 | AuctionHouseBot.DisableShamanItems = 0 177 | AuctionHouseBot.DisableMageItems = 0 178 | AuctionHouseBot.DisableWarlockItems = 0 179 | AuctionHouseBot.DisableUnusedClassItems = 0 180 | AuctionHouseBot.DisableDruidItems = 0 181 | 182 | ############################################################################### 183 | # AUCTION HOUSE BOT FILTERS PART 3 184 | # 185 | # AuctionHouseBot.DisableItemsBelowLevel 186 | # Prevent Seller from listing Items below this Level 187 | # Default 0 (Off) 188 | # 189 | # AuctionHouseBot.DisableItemsAboveLevel 190 | # Prevent Seller from listing Items above this Level 191 | # Default 0 (Off) 192 | # 193 | # AuctionHouseBot.DisableTGsBelowLevel 194 | # Prevent Seller from listing Trade Goods below this Level 195 | # Default 0 (Off) 196 | # 197 | # AuctionHouseBot.DisableTGsAboveLevel 198 | # Prevent Seller from listing Trade Goods above this Level 199 | # Default 0 (Off) 200 | # 201 | # AuctionHouseBot.DisableItemsBelowGUID 202 | # Prevent Seller from listing Items below this GUID 203 | # Default 0 (Off) 204 | # 205 | # AuctionHouseBot.DisableItemsAboveGUID 206 | # Prevent Seller from listing Items above this GUID 207 | # Default 0 (Off) 208 | # 209 | # AuctionHouseBot.DisableTGsBelowGUID 210 | # Prevent Seller from listing Trade Goods below this GUID 211 | # Default 0 (Off) 212 | # 213 | # AuctionHouseBot.DisableTGsAboveGUID 214 | # Prevent Seller from listing Trade Goods above this GUID 215 | # Default 0 (Off) 216 | # 217 | # AuctionHouseBot.DisableItemsBelowReqLevel 218 | # Prevent Seller from listing Items below this Required Level 219 | # Default 0 (Off) 220 | # 221 | # AuctionHouseBot.DisableItemsAboveReqLevel 222 | # Prevent Seller from listing Items above this Required Level 223 | # Default 0 (Off) 224 | # 225 | # AuctionHouseBot.DisableTGsBelowReqLevel 226 | # Prevent Seller from listing Trade Goods below this Required Level 227 | # Default 0 (Off) 228 | # 229 | # AuctionHouseBot.DisableTGsAboveReqLevel 230 | # Prevent Seller from listing Trade Goods above this Required Level 231 | # Default 0 (Off) 232 | # 233 | # AuctionHouseBot.DisableItemsBelowReqSkillRank 234 | # Prevent Seller from listing Items below this Required Skill Rank 235 | # Default 0 (Off) 236 | # 237 | # AuctionHouseBot.DisableItemsAboveReqSkillRank 238 | # Prevent Seller from listing Items above this Required Skill Rank 239 | # Default 0 (Off) 240 | # 241 | # AuctionHouseBot.DisableTGsBelowReqSkillRank 242 | # Prevent Seller from listing Trade Goods below this Required Skill Rank 243 | # Default 0 (Off) 244 | # 245 | # AuctionHouseBot.DisableTGsAboveReqSkillRank 246 | # Prevent Seller from listing Trade Goods above this Required Skill Rank 247 | # Default 0 (Off) 248 | # 249 | ############################################################################### 250 | 251 | AuctionHouseBot.DisableItemsBelowLevel = 0 252 | AuctionHouseBot.DisableItemsAboveLevel = 0 253 | AuctionHouseBot.DisableTGsBelowLevel = 0 254 | AuctionHouseBot.DisableTGsAboveLevel = 0 255 | AuctionHouseBot.DisableItemsBelowGUID = 0 256 | AuctionHouseBot.DisableItemsAboveGUID = 0 257 | AuctionHouseBot.DisableTGsBelowGUID = 0 258 | AuctionHouseBot.DisableTGsAboveGUID = 0 259 | AuctionHouseBot.DisableItemsBelowReqLevel = 0 260 | AuctionHouseBot.DisableItemsAboveReqLevel = 0 261 | AuctionHouseBot.DisableTGsBelowReqLevel = 0 262 | AuctionHouseBot.DisableTGsAboveReqLevel = 0 263 | AuctionHouseBot.DisableItemsBelowReqSkillRank = 0 264 | AuctionHouseBot.DisableItemsAboveReqSkillRank = 0 265 | AuctionHouseBot.DisableTGsBelowReqSkillRank = 0 266 | AuctionHouseBot.DisableTGsAboveReqSkillRank = 0 267 | -------------------------------------------------------------------------------- /include.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyaseCore/mod-ahbot/e3f21b42a78e6e5a55d25a31e6fe82ce7c8a822b/include.sh -------------------------------------------------------------------------------- /sql/auth/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyaseCore/mod-ahbot/e3f21b42a78e6e5a55d25a31e6fe82ce7c8a822b/sql/auth/.gitkeep -------------------------------------------------------------------------------- /sql/characters/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyaseCore/mod-ahbot/e3f21b42a78e6e5a55d25a31e6fe82ce7c8a822b/sql/characters/.gitkeep -------------------------------------------------------------------------------- /sql/world/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyaseCore/mod-ahbot/e3f21b42a78e6e5a55d25a31e6fe82ce7c8a822b/sql/world/.gitkeep -------------------------------------------------------------------------------- /sql/world/auctionhousebot.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost_3306 5 | Source Server Version : 50509 6 | Source Host : 127.0.0.1:3306 7 | Source Database : _test_world 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50509 11 | File Encoding : 65001 12 | 13 | Date: 2018-05-13 21:34:11 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for auctionhousebot 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `auctionhousebot`; 22 | CREATE TABLE `auctionhousebot` ( 23 | `auctionhouse` int(11) NOT NULL DEFAULT '0' COMMENT 'mapID of the auctionhouse.', 24 | `name` char(25) DEFAULT NULL COMMENT 'Text name of the auctionhouse.', 25 | `minitems` int(11) DEFAULT '0' COMMENT 'This is the minimum number of items you want to keep in the auction house. a 0 here will make it the same as the maximum.', 26 | `maxitems` int(11) DEFAULT '0' COMMENT 'This is the number of items you want to keep in the auction house.', 27 | `percentgreytradegoods` int(11) DEFAULT '0' COMMENT 'Sets the percentage of the Grey Trade Goods auction items', 28 | `percentwhitetradegoods` int(11) DEFAULT '27' COMMENT 'Sets the percentage of the White Trade Goods auction items', 29 | `percentgreentradegoods` int(11) DEFAULT '12' COMMENT 'Sets the percentage of the Green Trade Goods auction items', 30 | `percentbluetradegoods` int(11) DEFAULT '10' COMMENT 'Sets the percentage of the Blue Trade Goods auction items', 31 | `percentpurpletradegoods` int(11) DEFAULT '1' COMMENT 'Sets the percentage of the Purple Trade Goods auction items', 32 | `percentorangetradegoods` int(11) DEFAULT '0' COMMENT 'Sets the percentage of the Orange Trade Goods auction items', 33 | `percentyellowtradegoods` int(11) DEFAULT '0' COMMENT 'Sets the percentage of the Yellow Trade Goods auction items', 34 | `percentgreyitems` int(11) DEFAULT '0' COMMENT 'Sets the percentage of the non trade Grey auction items', 35 | `percentwhiteitems` int(11) DEFAULT '10' COMMENT 'Sets the percentage of the non trade White auction items', 36 | `percentgreenitems` int(11) DEFAULT '30' COMMENT 'Sets the percentage of the non trade Green auction items', 37 | `percentblueitems` int(11) DEFAULT '8' COMMENT 'Sets the percentage of the non trade Blue auction items', 38 | `percentpurpleitems` int(11) DEFAULT '2' COMMENT 'Sets the percentage of the non trade Purple auction items', 39 | `percentorangeitems` int(11) DEFAULT '0' COMMENT 'Sets the percentage of the non trade Orange auction items', 40 | `percentyellowitems` int(11) DEFAULT '0' COMMENT 'Sets the percentage of the non trade Yellow auction items', 41 | `minpricegrey` int(11) DEFAULT '100' COMMENT 'Minimum price of Grey items (percentage).', 42 | `maxpricegrey` int(11) DEFAULT '150' COMMENT 'Maximum price of Grey items (percentage).', 43 | `minpricewhite` int(11) DEFAULT '150' COMMENT 'Minimum price of White items (percentage).', 44 | `maxpricewhite` int(11) DEFAULT '250' COMMENT 'Maximum price of White items (percentage).', 45 | `minpricegreen` int(11) DEFAULT '800' COMMENT 'Minimum price of Green items (percentage).', 46 | `maxpricegreen` int(11) DEFAULT '1400' COMMENT 'Maximum price of Green items (percentage).', 47 | `minpriceblue` int(11) DEFAULT '1250' COMMENT 'Minimum price of Blue items (percentage).', 48 | `maxpriceblue` int(11) DEFAULT '1750' COMMENT 'Maximum price of Blue items (percentage).', 49 | `minpricepurple` int(11) DEFAULT '2250' COMMENT 'Minimum price of Purple items (percentage).', 50 | `maxpricepurple` int(11) DEFAULT '4550' COMMENT 'Maximum price of Purple items (percentage).', 51 | `minpriceorange` int(11) DEFAULT '3250' COMMENT 'Minimum price of Orange items (percentage).', 52 | `maxpriceorange` int(11) DEFAULT '5550' COMMENT 'Maximum price of Orange items (percentage).', 53 | `minpriceyellow` int(11) DEFAULT '5250' COMMENT 'Minimum price of Yellow items (percentage).', 54 | `maxpriceyellow` int(11) DEFAULT '6550' COMMENT 'Maximum price of Yellow items (percentage).', 55 | `minbidpricegrey` int(11) DEFAULT '70' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 70', 56 | `maxbidpricegrey` int(11) DEFAULT '100' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 100', 57 | `minbidpricewhite` int(11) DEFAULT '70' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 70', 58 | `maxbidpricewhite` int(11) DEFAULT '100' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100', 59 | `minbidpricegreen` int(11) DEFAULT '80' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 80', 60 | `maxbidpricegreen` int(11) DEFAULT '100' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100', 61 | `minbidpriceblue` int(11) DEFAULT '75' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 75', 62 | `maxbidpriceblue` int(11) DEFAULT '100' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100', 63 | `minbidpricepurple` int(11) DEFAULT '80' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 80', 64 | `maxbidpricepurple` int(11) DEFAULT '100' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100', 65 | `minbidpriceorange` int(11) DEFAULT '80' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 80', 66 | `maxbidpriceorange` int(11) DEFAULT '100' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 100', 67 | `minbidpriceyellow` int(11) DEFAULT '80' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 80', 68 | `maxbidpriceyellow` int(11) DEFAULT '100' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 100', 69 | `maxstackgrey` int(11) DEFAULT '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.', 70 | `maxstackwhite` int(11) DEFAULT '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.', 71 | `maxstackgreen` int(11) DEFAULT '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.', 72 | `maxstackblue` int(11) DEFAULT '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.', 73 | `maxstackpurple` int(11) DEFAULT '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.', 74 | `maxstackorange` int(11) DEFAULT '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.', 75 | `maxstackyellow` int(11) DEFAULT '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.', 76 | `buyerpricegrey` int(11) DEFAULT '1' COMMENT 'Multiplier to vendorprice when buying grey items from auctionhouse', 77 | `buyerpricewhite` int(11) DEFAULT '3' COMMENT 'Multiplier to vendorprice when buying white items from auctionhouse', 78 | `buyerpricegreen` int(11) DEFAULT '5' COMMENT 'Multiplier to vendorprice when buying green items from auctionhouse', 79 | `buyerpriceblue` int(11) DEFAULT '12' COMMENT 'Multiplier to vendorprice when buying blue items from auctionhouse', 80 | `buyerpricepurple` int(11) DEFAULT '15' COMMENT 'Multiplier to vendorprice when buying purple items from auctionhouse', 81 | `buyerpriceorange` int(11) DEFAULT '20' COMMENT 'Multiplier to vendorprice when buying orange items from auctionhouse', 82 | `buyerpriceyellow` int(11) DEFAULT '22' COMMENT 'Multiplier to vendorprice when buying yellow items from auctionhouse', 83 | `buyerbiddinginterval` int(11) DEFAULT '1' COMMENT 'Interval how frequently AHB bids on each AH. Time in minutes', 84 | `buyerbidsperinterval` int(11) DEFAULT '1' COMMENT 'number of bids to put in per bidding interval', 85 | PRIMARY KEY (`auctionhouse`) 86 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 87 | 88 | -- ---------------------------- 89 | -- Records of auctionhousebot 90 | -- ---------------------------- 91 | INSERT INTO `auctionhousebot` VALUES ('2', 'Alliance', '250', '250', '0', '27', '12', '10', '1', '0', '0', '0', '10', '30', '8', '2', '0', '0', '100', '150', '150', '250', '800', '1400', '1250', '1750', '2250', '4550', '3250', '5550', '5250', '6550', '70', '100', '70', '100', '80', '100', '75', '100', '80', '100', '80', '100', '80', '100', '0', '0', '3', '2', '1', '1', '1', '1', '3', '5', '12', '15', '20', '22', '1', '1'); 92 | INSERT INTO `auctionhousebot` VALUES ('6', 'Horde', '250', '250', '0', '27', '12', '10', '1', '0', '0', '0', '10', '30', '8', '2', '0', '0', '100', '150', '150', '250', '800', '1400', '1250', '1750', '2250', '4550', '3250', '5550', '5250', '6550', '70', '100', '70', '100', '80', '100', '75', '100', '80', '100', '80', '100', '80', '100', '0', '0', '3', '2', '1', '1', '1', '1', '3', '5', '12', '15', '20', '22', '1', '1'); 93 | INSERT INTO `auctionhousebot` VALUES ('7', 'Neutral', '250', '250', '0', '27', '12', '10', '1', '0', '0', '0', '10', '30', '8', '2', '0', '0', '100', '150', '150', '250', '800', '1400', '1250', '1750', '2250', '4550', '3250', '5550', '5250', '6550', '70', '100', '70', '100', '80', '100', '75', '100', '80', '100', '80', '100', '80', '100', '0', '0', '3', '2', '1', '1', '1', '1', '3', '5', '12', '15', '20', '22', '1', '1'); 94 | -------------------------------------------------------------------------------- /src/AuctionHouseBot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2010 Trinity 3 | * Copyright (C) 2005-2009 MaNGOS 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include "ObjectMgr.h" 21 | #include "AuctionHouseMgr.h" 22 | #include "AuctionHouseBot.h" 23 | #include "Config.h" 24 | #include "Player.h" 25 | #include "WorldSession.h" 26 | #include 27 | 28 | using namespace std; 29 | vector npcItems; 30 | vector lootItems; 31 | vector greyTradeGoodsBin; 32 | vector whiteTradeGoodsBin; 33 | vector greenTradeGoodsBin; 34 | vector blueTradeGoodsBin; 35 | vector purpleTradeGoodsBin; 36 | vector orangeTradeGoodsBin; 37 | vector yellowTradeGoodsBin; 38 | vector greyItemsBin; 39 | vector whiteItemsBin; 40 | vector greenItemsBin; 41 | vector blueItemsBin; 42 | vector purpleItemsBin; 43 | vector orangeItemsBin; 44 | vector yellowItemsBin; 45 | 46 | AuctionHouseBot::AuctionHouseBot() 47 | { 48 | debug_Out = false; 49 | debug_Out_Filters = false; 50 | AHBSeller = false; 51 | AHBBuyer = false; 52 | 53 | //Begin Filters 54 | 55 | Vendor_Items = false; 56 | Loot_Items = false; 57 | Other_Items = false; 58 | Vendor_TGs = false; 59 | Loot_TGs = false; 60 | Other_TGs = false; 61 | 62 | No_Bind = false; 63 | Bind_When_Picked_Up = false; 64 | Bind_When_Equipped = false; 65 | Bind_When_Use = false; 66 | Bind_Quest_Item = false; 67 | 68 | DisablePermEnchant = false; 69 | DisableConjured = false; 70 | DisableGems = false; 71 | DisableMoney = false; 72 | DisableMoneyLoot = false; 73 | DisableLootable = false; 74 | DisableKeys = false; 75 | DisableDuration = false; 76 | DisableBOP_Or_Quest_NoReqLevel = false; 77 | 78 | DisableWarriorItems = false; 79 | DisablePaladinItems = false; 80 | DisableHunterItems = false; 81 | DisableRogueItems = false; 82 | DisablePriestItems = false; 83 | DisableDKItems = false; 84 | DisableShamanItems = false; 85 | DisableMageItems = false; 86 | DisableWarlockItems = false; 87 | DisableUnusedClassItems = false; 88 | DisableDruidItems = false; 89 | 90 | DisableItemsBelowLevel = 0; 91 | DisableItemsAboveLevel = 0; 92 | DisableTGsBelowLevel = 0; 93 | DisableTGsAboveLevel = 0; 94 | DisableItemsBelowGUID = 0; 95 | DisableItemsAboveGUID = 0; 96 | DisableTGsBelowGUID = 0; 97 | DisableTGsAboveGUID = 0; 98 | DisableItemsBelowReqLevel = 0; 99 | DisableItemsAboveReqLevel = 0; 100 | DisableTGsBelowReqLevel = 0; 101 | DisableTGsAboveReqLevel = 0; 102 | DisableItemsBelowReqSkillRank = 0; 103 | DisableItemsAboveReqSkillRank = 0; 104 | DisableTGsBelowReqSkillRank = 0; 105 | DisableTGsAboveReqSkillRank = 0; 106 | 107 | //End Filters 108 | 109 | _lastrun_a = time(NULL); 110 | _lastrun_h = time(NULL); 111 | _lastrun_n = time(NULL); 112 | 113 | AllianceConfig = AHBConfig(2); 114 | HordeConfig = AHBConfig(6); 115 | NeutralConfig = AHBConfig(7); 116 | } 117 | 118 | AuctionHouseBot::~AuctionHouseBot() 119 | { 120 | } 121 | 122 | void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config) 123 | { 124 | if (!AHBSeller) 125 | { 126 | if (debug_Out) sLog->outString("AHSeller: Disabled"); 127 | return; 128 | } 129 | 130 | uint32 minItems = config->GetMinItems(); 131 | uint32 maxItems = config->GetMaxItems(); 132 | 133 | if (maxItems == 0) 134 | { 135 | //if (debug_Out) sLog->outString( "AHSeller: Auctions disabled"); 136 | return; 137 | } 138 | 139 | AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntry(config->GetAHFID()); 140 | if (!ahEntry) 141 | { 142 | return; 143 | } 144 | AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID()); 145 | if (!auctionHouse) 146 | { 147 | return; 148 | } 149 | 150 | uint32 auctions = auctionHouse->Getcount(); 151 | 152 | uint32 items = 0; 153 | 154 | if (auctions >= minItems) 155 | { 156 | //if (debug_Out) sLog->outError( "AHSeller: Auctions above minimum"); 157 | return; 158 | } 159 | 160 | if (auctions >= maxItems) 161 | { 162 | //if (debug_Out) sLog->outError( "AHSeller: Auctions at or above maximum"); 163 | return; 164 | } 165 | 166 | if ((maxItems - auctions) >= ItemsPerCycle) 167 | items = ItemsPerCycle; 168 | else 169 | items = (maxItems - auctions); 170 | 171 | if (debug_Out) sLog->outString("AHSeller: Adding %u Auctions", items); 172 | 173 | uint32 AuctioneerGUID = 0; 174 | 175 | switch (config->GetAHID()) 176 | { 177 | case 2: 178 | AuctioneerGUID = 79707; //Human in stormwind. 179 | break; 180 | case 6: 181 | AuctioneerGUID = 4656; //orc in Orgrimmar 182 | break; 183 | case 7: 184 | AuctioneerGUID = 23442; //goblin in GZ 185 | break; 186 | default: 187 | if (debug_Out) sLog->outError( "AHSeller: GetAHID() - Default switch reached"); 188 | AuctioneerGUID = 23442; //default to neutral 7 189 | break; 190 | } 191 | 192 | if (debug_Out) sLog->outError( "AHSeller: Current Auctineer GUID is %u", AuctioneerGUID); 193 | 194 | uint32 greyTGcount = config->GetPercents(AHB_GREY_TG); 195 | uint32 whiteTGcount = config->GetPercents(AHB_WHITE_TG); 196 | uint32 greenTGcount = config->GetPercents(AHB_GREEN_TG); 197 | uint32 blueTGcount = config->GetPercents(AHB_BLUE_TG); 198 | uint32 purpleTGcount = config->GetPercents(AHB_PURPLE_TG); 199 | uint32 orangeTGcount = config->GetPercents(AHB_ORANGE_TG); 200 | uint32 yellowTGcount = config->GetPercents(AHB_YELLOW_TG); 201 | uint32 greyIcount = config->GetPercents(AHB_GREY_I); 202 | uint32 whiteIcount = config->GetPercents(AHB_WHITE_I); 203 | uint32 greenIcount = config->GetPercents(AHB_GREEN_I); 204 | uint32 blueIcount = config->GetPercents(AHB_BLUE_I); 205 | uint32 purpleIcount = config->GetPercents(AHB_PURPLE_I); 206 | uint32 orangeIcount = config->GetPercents(AHB_ORANGE_I); 207 | uint32 yellowIcount = config->GetPercents(AHB_YELLOW_I); 208 | /* uint32 total = greyTGcount + whiteTGcount + greenTGcount + blueTGcount 209 | + purpleTGcount + orangeTGcount + yellowTGcount 210 | + whiteIcount + greenIcount + blueIcount + purpleIcount 211 | + orangeIcount + yellowIcount; 212 | */ 213 | uint32 greyTGoods = config->GetItemCounts(AHB_GREY_TG); 214 | uint32 whiteTGoods = config->GetItemCounts(AHB_WHITE_TG); 215 | uint32 greenTGoods = config->GetItemCounts(AHB_GREEN_TG); 216 | uint32 blueTGoods = config->GetItemCounts(AHB_BLUE_TG); 217 | uint32 purpleTGoods = config->GetItemCounts(AHB_PURPLE_TG); 218 | uint32 orangeTGoods = config->GetItemCounts(AHB_ORANGE_TG); 219 | uint32 yellowTGoods = config->GetItemCounts(AHB_YELLOW_TG); 220 | 221 | uint32 greyItems = config->GetItemCounts(AHB_GREY_I); 222 | uint32 whiteItems = config->GetItemCounts(AHB_WHITE_I); 223 | uint32 greenItems = config->GetItemCounts(AHB_GREEN_I); 224 | uint32 blueItems = config->GetItemCounts(AHB_BLUE_I); 225 | uint32 purpleItems = config->GetItemCounts(AHB_PURPLE_I); 226 | uint32 orangeItems = config->GetItemCounts(AHB_ORANGE_I); 227 | uint32 yellowItems = config->GetItemCounts(AHB_YELLOW_I); 228 | if (debug_Out) sLog->outError( "AHSeller: %u items", items); 229 | 230 | // only insert a few at a time, so as not to peg the processor 231 | for (uint32 cnt = 1; cnt <= items; cnt++) 232 | { 233 | if (debug_Out) sLog->outError( "AHSeller: %u count", cnt); 234 | uint32 itemID = 0; 235 | uint32 itemColor = 99; 236 | uint32 loopbreaker = 0; 237 | while (itemID == 0 && loopbreaker <= 50) 238 | { 239 | ++loopbreaker; 240 | uint32 choice = urand(0, 13); 241 | itemColor = choice; 242 | switch (choice) 243 | { 244 | case 0: 245 | { 246 | if ((greyItemsBin.size() > 0) && (greyItems < greyIcount)) 247 | itemID = greyItemsBin[urand(0, greyItemsBin.size() - 1)]; 248 | else continue; 249 | break; 250 | } 251 | case 1: 252 | { 253 | if ((whiteItemsBin.size() > 0) && (whiteItems < whiteIcount)) 254 | itemID = whiteItemsBin[urand(0, whiteItemsBin.size() - 1)]; 255 | else continue; 256 | break; 257 | } 258 | case 2: 259 | { 260 | if ((greenItemsBin.size() > 0) && (greenItems < greenIcount)) 261 | itemID = greenItemsBin[urand(0, greenItemsBin.size() - 1)]; 262 | else continue; 263 | break; 264 | } 265 | case 3: 266 | { 267 | if ((blueItemsBin.size() > 0) && (blueItems < blueIcount)) 268 | itemID = blueItemsBin[urand(0, blueItemsBin.size() - 1)]; 269 | else continue; 270 | break; 271 | } 272 | case 4: 273 | { 274 | if ((purpleItemsBin.size() > 0) && (purpleItems < purpleIcount)) 275 | itemID = purpleItemsBin[urand(0, purpleItemsBin.size() - 1)]; 276 | else continue; 277 | break; 278 | } 279 | case 5: 280 | { 281 | if ((orangeItemsBin.size() > 0) && (orangeItems < orangeIcount)) 282 | itemID = orangeItemsBin[urand(0, orangeItemsBin.size() - 1)]; 283 | else continue; 284 | break; 285 | } 286 | case 6: 287 | { 288 | if ((yellowItemsBin.size() > 0) && (yellowItems < yellowIcount)) 289 | itemID = yellowItemsBin[urand(0, yellowItemsBin.size() - 1)]; 290 | else continue; 291 | break; 292 | } 293 | case 7: 294 | { 295 | if ((greyTradeGoodsBin.size() > 0) && (greyTGoods < greyTGcount)) 296 | itemID = greyTradeGoodsBin[urand(0, greyTradeGoodsBin.size() - 1)]; 297 | else continue; 298 | break; 299 | } 300 | case 8: 301 | { 302 | if ((whiteTradeGoodsBin.size() > 0) && (whiteTGoods < whiteTGcount)) 303 | itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)]; 304 | else continue; 305 | break; 306 | } 307 | case 9: 308 | { 309 | if ((greenTradeGoodsBin.size() > 0) && (greenTGoods < greenTGcount)) 310 | itemID = greenTradeGoodsBin[urand(0, greenTradeGoodsBin.size() - 1)]; 311 | else continue; 312 | break; 313 | } 314 | case 10: 315 | { 316 | if ((blueTradeGoodsBin.size() > 0) && (blueTGoods < blueTGcount)) 317 | itemID = blueTradeGoodsBin[urand(0, blueTradeGoodsBin.size() - 1)]; 318 | else continue; 319 | break; 320 | } 321 | case 11: 322 | { 323 | if ((purpleTradeGoodsBin.size() > 0) && (purpleTGoods < purpleTGcount)) 324 | itemID = purpleTradeGoodsBin[urand(0, purpleTradeGoodsBin.size() - 1)]; 325 | else continue; 326 | break; 327 | } 328 | case 12: 329 | { 330 | if ((orangeTradeGoodsBin.size() > 0) && (orangeTGoods < orangeTGcount)) 331 | itemID = orangeTradeGoodsBin[urand(0, orangeTradeGoodsBin.size() - 1)]; 332 | else continue; 333 | break; 334 | } 335 | case 13: 336 | { 337 | if ((yellowTradeGoodsBin.size() > 0) && (yellowTGoods < yellowTGcount)) 338 | itemID = yellowTradeGoodsBin[urand(0, yellowTradeGoodsBin.size() - 1)]; 339 | else continue; 340 | break; 341 | } 342 | default: 343 | { 344 | if (debug_Out) sLog->outError( "AHSeller: itemID Switch - Default Reached"); 345 | break; 346 | } 347 | } 348 | 349 | if (itemID == 0) 350 | { 351 | if (debug_Out) sLog->outError( "AHSeller: Item::CreateItem() - ItemID is 0"); 352 | continue; 353 | } 354 | 355 | ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(itemID); 356 | if (prototype == NULL) 357 | { 358 | if (debug_Out) sLog->outError( "AHSeller: Huh?!?! prototype == NULL"); 359 | continue; 360 | } 361 | 362 | Item* item = Item::CreateItem(itemID, 1, AHBplayer); 363 | if (item == NULL) 364 | { 365 | if (debug_Out) sLog->outError( "AHSeller: Item::CreateItem() returned NULL"); 366 | break; 367 | } 368 | item->AddToUpdateQueueOf(AHBplayer); 369 | 370 | uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemID); 371 | if (randomPropertyId != 0) 372 | item->SetItemRandomProperties(randomPropertyId); 373 | 374 | uint64 buyoutPrice = 0; 375 | uint64 bidPrice = 0; 376 | uint32 stackCount = 1; 377 | 378 | switch (SellMethod) 379 | { 380 | case 0: 381 | buyoutPrice = prototype->SellPrice; 382 | break; 383 | case 1: 384 | buyoutPrice = prototype->BuyPrice; 385 | break; 386 | } 387 | 388 | if (prototype->Quality <= AHB_MAX_QUALITY) 389 | { 390 | if (config->GetMaxStack(prototype->Quality) > 1 && item->GetMaxStackCount() > 1) 391 | stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(prototype->Quality))); 392 | else if (config->GetMaxStack(prototype->Quality) == 0 && item->GetMaxStackCount() > 1) 393 | stackCount = urand(1, item->GetMaxStackCount()); 394 | else 395 | stackCount = 1; 396 | buyoutPrice *= urand(config->GetMinPrice(prototype->Quality), config->GetMaxPrice(prototype->Quality)); 397 | buyoutPrice /= 100; 398 | bidPrice = buyoutPrice * urand(config->GetMinBidPrice(prototype->Quality), config->GetMaxBidPrice(prototype->Quality)); 399 | bidPrice /= 100; 400 | } 401 | else 402 | { 403 | // quality is something it shouldn't be, let's get out of here 404 | if (debug_Out) sLog->outError( "AHBuyer: Quality %u not Supported", prototype->Quality); 405 | item->RemoveFromUpdateQueueOf(AHBplayer); 406 | continue; 407 | } 408 | 409 | uint32 etime = urand(1,3); 410 | switch(etime) 411 | { 412 | case 1: 413 | etime = 43200; 414 | break; 415 | case 2: 416 | etime = 86400; 417 | break; 418 | case 3: 419 | etime = 172800; 420 | break; 421 | default: 422 | etime = 86400; 423 | break; 424 | } 425 | item->SetCount(stackCount); 426 | 427 | uint32 dep = sAuctionMgr->GetAuctionDeposit(ahEntry, etime, item, stackCount); 428 | 429 | SQLTransaction trans = CharacterDatabase.BeginTransaction(); 430 | AuctionEntry* auctionEntry = new AuctionEntry(); 431 | auctionEntry->Id = sObjectMgr->GenerateAuctionID(); 432 | auctionEntry->auctioneer = AuctioneerGUID; 433 | auctionEntry->item_guidlow = item->GetGUIDLow(); 434 | auctionEntry->item_template = item->GetEntry(); 435 | auctionEntry->itemCount = item->GetCount(); 436 | auctionEntry->owner = AHBplayer->GetGUIDLow(); 437 | auctionEntry->startbid = bidPrice * stackCount; 438 | auctionEntry->buyout = buyoutPrice * stackCount; 439 | auctionEntry->bidder = 0; 440 | auctionEntry->bid = 0; 441 | auctionEntry->deposit = dep; 442 | auctionEntry->expire_time = (time_t) etime + time(NULL); 443 | auctionEntry->auctionHouseEntry = ahEntry; 444 | item->SaveToDB(trans); 445 | item->RemoveFromUpdateQueueOf(AHBplayer); 446 | sAuctionMgr->AddAItem(item); 447 | auctionHouse->AddAuction(auctionEntry); 448 | auctionEntry->SaveToDB(trans); 449 | CharacterDatabase.CommitTransaction(trans); 450 | 451 | switch(itemColor) 452 | { 453 | case 0: 454 | ++greyItems; 455 | break; 456 | case 1: 457 | ++whiteItems; 458 | break; 459 | case 2: 460 | ++greenItems; 461 | break; 462 | case 3: 463 | ++blueItems; 464 | break; 465 | case 4: 466 | ++purpleItems; 467 | break; 468 | case 5: 469 | ++orangeItems; 470 | break; 471 | case 6: 472 | ++yellowItems; 473 | break; 474 | case 7: 475 | ++greyTGoods; 476 | break; 477 | case 8: 478 | ++whiteTGoods; 479 | break; 480 | case 9: 481 | ++greenTGoods; 482 | break; 483 | case 10: 484 | ++blueTGoods; 485 | break; 486 | case 11: 487 | ++purpleTGoods; 488 | break; 489 | case 12: 490 | ++orangeTGoods; 491 | break; 492 | case 13: 493 | ++yellowTGoods; 494 | break; 495 | default: 496 | break; 497 | } 498 | } 499 | } 500 | } 501 | void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session) 502 | { 503 | if (!AHBBuyer) 504 | { 505 | if (debug_Out) sLog->outError( "AHBuyer: Disabled"); 506 | return; 507 | } 508 | 509 | QueryResult result = CharacterDatabase.PQuery("SELECT id FROM auctionhouse WHERE itemowner<>%u AND buyguid<>%u", AHBplayerGUID, AHBplayerGUID); 510 | 511 | if (!result) 512 | return; 513 | 514 | if (result->GetRowCount() == 0) 515 | return; 516 | 517 | // Fetches content of selected AH 518 | AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID()); 519 | vector possibleBids; 520 | 521 | do 522 | { 523 | uint32 tmpdata = result->Fetch()->GetUInt32(); 524 | possibleBids.push_back(tmpdata); 525 | }while (result->NextRow()); 526 | 527 | for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) 528 | { 529 | // Do we have anything to bid? If not, stop here. 530 | if (possibleBids.empty()) 531 | { 532 | //if (debug_Out) sLog->outError( "AHBuyer: I have no items to bid on."); 533 | count = config->GetBidsPerInterval(); 534 | continue; 535 | } 536 | 537 | // Choose random auction from possible auctions 538 | uint32 vectorPos = urand(0, possibleBids.size() - 1); 539 | vector::iterator iter = possibleBids.begin(); 540 | advance(iter, vectorPos); 541 | 542 | // from auctionhousehandler.cpp, creates auction pointer & player pointer 543 | AuctionEntry* auction = auctionHouse->GetAuction(*iter); 544 | 545 | // Erase the auction from the vector to prevent bidding on item in next iteration. 546 | possibleBids.erase(iter); 547 | 548 | if (!auction) 549 | continue; 550 | 551 | // get exact item information 552 | Item *pItem = sAuctionMgr->GetAItem(auction->item_guidlow); 553 | if (!pItem) 554 | { 555 | if (debug_Out) sLog->outError( "AHBuyer: Item %u doesn't exist, perhaps bought already?", auction->item_guidlow); 556 | continue; 557 | } 558 | 559 | // get item prototype 560 | ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(auction->item_template); 561 | 562 | // check which price we have to use, startbid or if it is bidded already 563 | uint32 currentprice; 564 | if (auction->bid) 565 | currentprice = auction->bid; 566 | else 567 | currentprice = auction->startbid; 568 | 569 | // Prepare portion from maximum bid 570 | double bidrate = static_cast(urand(1, 100)) / 100; 571 | long double bidMax = 0; 572 | 573 | // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality 574 | switch (BuyMethod) 575 | { 576 | case 0: 577 | { 578 | if (prototype->Quality <= AHB_MAX_QUALITY) 579 | { 580 | if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality)) 581 | bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality); 582 | } 583 | else 584 | { 585 | // quality is something it shouldn't be, let's get out of here 586 | if (debug_Out) sLog->outError( "AHBuyer: Quality %u not Supported", prototype->Quality); 587 | continue; 588 | } 589 | break; 590 | } 591 | case 1: 592 | { 593 | if (prototype->Quality <= AHB_MAX_QUALITY) 594 | { 595 | if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality)) 596 | bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality); 597 | } 598 | else 599 | { 600 | // quality is something it shouldn't be, let's get out of here 601 | if (debug_Out) sLog->outError( "AHBuyer: Quality %u not Supported", prototype->Quality); 602 | continue; 603 | } 604 | break; 605 | } 606 | } 607 | 608 | // check some special items, and do recalculating to their prices 609 | switch (prototype->Class) 610 | { 611 | // ammo 612 | case 6: 613 | bidMax = 0; 614 | break; 615 | default: 616 | break; 617 | } 618 | 619 | if (bidMax == 0) 620 | { 621 | // quality check failed to get bidmax, let's get out of here 622 | continue; 623 | } 624 | 625 | // Calculate our bid 626 | long double bidvalue = currentprice + ((bidMax - currentprice) * bidrate); 627 | // Convert to uint32 628 | uint32 bidprice = static_cast(bidvalue); 629 | 630 | // Check our bid is high enough to be valid. If not, correct it to minimum. 631 | if ((currentprice + auction->GetAuctionOutBid()) > bidprice) 632 | bidprice = currentprice + auction->GetAuctionOutBid(); 633 | 634 | if (debug_Out) 635 | { 636 | sLog->outString("-------------------------------------------------"); 637 | sLog->outString("AHBuyer: Info for Auction #%u:", auction->Id); 638 | sLog->outString("AHBuyer: AuctionHouse: %u", auction->GetHouseId()); 639 | sLog->outString("AHBuyer: Auctioneer: %u", auction->auctioneer); 640 | sLog->outString("AHBuyer: Owner: %u", auction->owner); 641 | sLog->outString("AHBuyer: Bidder: %u", auction->bidder); 642 | sLog->outString("AHBuyer: Starting Bid: %u", auction->startbid); 643 | sLog->outString("AHBuyer: Current Bid: %u", currentprice); 644 | sLog->outString("AHBuyer: Buyout: %u", auction->buyout); 645 | sLog->outString("AHBuyer: Deposit: %u", auction->deposit); 646 | sLog->outString("AHBuyer: Expire Time: %u", uint32(auction->expire_time)); 647 | sLog->outString("AHBuyer: Bid Rate: %f", bidrate); 648 | sLog->outString("AHBuyer: Bid Max: %Lf", bidMax); 649 | sLog->outString("AHBuyer: Bid Value: %Lf", bidvalue); 650 | sLog->outString("AHBuyer: Bid Price: %u", bidprice); 651 | sLog->outString("AHBuyer: Item GUID: %u", auction->item_guidlow); 652 | sLog->outString("AHBuyer: Item Template: %u", auction->item_template); 653 | sLog->outString("AHBuyer: Item Info:"); 654 | sLog->outString("AHBuyer: Item ID: %u", prototype->ItemId); 655 | sLog->outString("AHBuyer: Buy Price: %u", prototype->BuyPrice); 656 | sLog->outString("AHBuyer: Sell Price: %u", prototype->SellPrice); 657 | sLog->outString("AHBuyer: Bonding: %u", prototype->Bonding); 658 | sLog->outString("AHBuyer: Quality: %u", prototype->Quality); 659 | sLog->outString("AHBuyer: Item Level: %u", prototype->ItemLevel); 660 | sLog->outString("AHBuyer: Ammo Type: %u", prototype->AmmoType); 661 | sLog->outString("-------------------------------------------------"); 662 | } 663 | 664 | // Check whether we do normal bid, or buyout 665 | if ((bidprice < auction->buyout) || (auction->buyout == 0)) 666 | { 667 | 668 | if (auction->bidder > 0) 669 | { 670 | if (auction->bidder == AHBplayer->GetGUIDLow()) 671 | { 672 | //pl->ModifyMoney(-int32(price - auction->bid)); 673 | } 674 | else 675 | { 676 | // mail to last bidder and return money 677 | SQLTransaction trans = CharacterDatabase.BeginTransaction(); 678 | sAuctionMgr->SendAuctionOutbiddedMail(auction , bidprice, session->GetPlayer(), trans); 679 | CharacterDatabase.CommitTransaction(trans); 680 | //pl->ModifyMoney(-int32(price)); 681 | } 682 | } 683 | 684 | auction->bidder = AHBplayer->GetGUIDLow(); 685 | auction->bid = bidprice; 686 | 687 | // Saving auction into database 688 | CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id); 689 | } 690 | else 691 | { 692 | SQLTransaction trans = CharacterDatabase.BeginTransaction(); 693 | //buyout 694 | if ((auction->bidder) && (AHBplayer->GetGUIDLow() != auction->bidder)) 695 | { 696 | sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, session->GetPlayer(), trans); 697 | } 698 | auction->bidder = AHBplayer->GetGUIDLow(); 699 | auction->bid = auction->buyout; 700 | 701 | // Send mails to buyer & seller 702 | //sAuctionMgr->SendAuctionSalePendingMail(auction, trans); 703 | sAuctionMgr->SendAuctionSuccessfulMail(auction, trans); 704 | sAuctionMgr->SendAuctionWonMail(auction, trans); 705 | auction->DeleteFromDB( trans); 706 | 707 | sAuctionMgr->RemoveAItem(auction->item_guidlow); 708 | auctionHouse->RemoveAuction(auction); 709 | CharacterDatabase.CommitTransaction(trans); 710 | } 711 | } 712 | } 713 | 714 | void AuctionHouseBot::Update() 715 | { 716 | time_t _newrun = time(NULL); 717 | if ((!AHBSeller) && (!AHBBuyer)) 718 | return; 719 | 720 | WorldSession _session(AHBplayerAccount, NULL, SEC_PLAYER, sWorld->getIntConfig(CONFIG_EXPANSION), 0, LOCALE_zhCN,0,false,false); 721 | Player _AHBplayer(&_session); 722 | _AHBplayer.Initialize(AHBplayerGUID); 723 | sObjectAccessor->AddObject(&_AHBplayer); 724 | 725 | // Add New Bids 726 | if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) 727 | { 728 | addNewAuctions(&_AHBplayer, &AllianceConfig); 729 | if (((_newrun - _lastrun_a) >= (AllianceConfig.GetBiddingInterval() * MINUTE)) && (AllianceConfig.GetBidsPerInterval() > 0)) 730 | { 731 | //if (debug_Out) sLog->outError( "AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_a)); 732 | //if (debug_Out) sLog->outError( "AHBuyer: Bidding on Alliance Auctions"); 733 | addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig, &_session); 734 | _lastrun_a = _newrun; 735 | } 736 | 737 | addNewAuctions(&_AHBplayer, &HordeConfig); 738 | if (((_newrun - _lastrun_h) >= (HordeConfig.GetBiddingInterval() * MINUTE)) && (HordeConfig.GetBidsPerInterval() > 0)) 739 | { 740 | //if (debug_Out) sLog->outError( "AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_h)); 741 | //if (debug_Out) sLog->outError( "AHBuyer: Bidding on Horde Auctions"); 742 | addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig, &_session); 743 | _lastrun_h = _newrun; 744 | } 745 | } 746 | 747 | addNewAuctions(&_AHBplayer, &NeutralConfig); 748 | if (((_newrun - _lastrun_n) >= (NeutralConfig.GetBiddingInterval() * MINUTE)) && (NeutralConfig.GetBidsPerInterval() > 0)) 749 | { 750 | //if (debug_Out) sLog->outError( "AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_n)); 751 | //if (debug_Out) sLog->outError( "AHBuyer: Bidding on Neutral Auctions"); 752 | addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig, &_session); 753 | _lastrun_n = _newrun; 754 | } 755 | sObjectAccessor->RemoveObject(&_AHBplayer); 756 | } 757 | 758 | void AuctionHouseBot::Initialize() 759 | { 760 | std::string disabledItems = sConfigMgr->GetStringDefault("AuctionHouseBot.DisabledItems", ""); 761 | DisableItemStore.clear(); 762 | Tokenizer tokens(disabledItems, ' '); 763 | for (Tokenizer::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter) 764 | { 765 | uint32 id = uint32(atol(*iter)); 766 | DisableItemStore.insert(id); 767 | } 768 | 769 | //End Filters 770 | if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) 771 | { 772 | LoadValues(&AllianceConfig); 773 | LoadValues(&HordeConfig); 774 | } 775 | LoadValues(&NeutralConfig); 776 | 777 | // 778 | // check if the AHBot account/GUID in the config actually exists 779 | // 780 | 781 | if ((AHBplayerAccount != 0) || (AHBplayerGUID != 0)) 782 | { 783 | QueryResult result = CharacterDatabase.PQuery("SELECT 1 FROM characters WHERE account = %u AND guid = %u", AHBplayerAccount, AHBplayerGUID); 784 | if (!result) 785 | { 786 | sLog->outError( "AuctionHouseBot: The account/GUID-information set for your AHBot is incorrect (account: %u guid: %u)", AHBplayerAccount, AHBplayerGUID); 787 | return; 788 | } 789 | } 790 | 791 | if (AHBSeller) 792 | { 793 | QueryResult results = QueryResult(NULL); 794 | char npcQuery[] = "SELECT distinct item FROM npc_vendor"; 795 | results = WorldDatabase.Query(npcQuery); 796 | if (results) 797 | { 798 | do 799 | { 800 | Field* fields = results->Fetch(); 801 | npcItems.push_back(fields[0].GetUInt32()); 802 | 803 | } while (results->NextRow()); 804 | } 805 | else 806 | { 807 | if (debug_Out) sLog->outError( "AuctionHouseBot: \"%s\" failed", npcQuery); 808 | } 809 | 810 | char lootQuery[] = "SELECT item FROM creature_loot_template UNION " 811 | "SELECT item FROM reference_loot_template UNION " 812 | "SELECT item FROM disenchant_loot_template UNION " 813 | "SELECT item FROM fishing_loot_template UNION " 814 | "SELECT item FROM gameobject_loot_template UNION " 815 | "SELECT item FROM item_loot_template UNION " 816 | "SELECT item FROM milling_loot_template UNION " 817 | "SELECT item FROM pickpocketing_loot_template UNION " 818 | "SELECT item FROM prospecting_loot_template UNION " 819 | "SELECT item FROM skinning_loot_template"; 820 | 821 | results = WorldDatabase.Query(lootQuery); 822 | if (results) 823 | { 824 | do 825 | { 826 | Field* fields = results->Fetch(); 827 | lootItems.push_back(fields[0].GetUInt32()); 828 | 829 | } while (results->NextRow()); 830 | } 831 | else 832 | { 833 | if (debug_Out) sLog->outError( "AuctionHouseBot: \"%s\" failed", lootQuery); 834 | } 835 | 836 | ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); 837 | for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr) 838 | { 839 | 840 | 841 | 842 | switch (itr->second.Bonding) 843 | { 844 | case NO_BIND: 845 | if (!No_Bind) 846 | continue; 847 | break; 848 | case BIND_WHEN_PICKED_UP: 849 | if (!Bind_When_Picked_Up) 850 | continue; 851 | break; 852 | case BIND_WHEN_EQUIPED: 853 | if (!Bind_When_Equipped) 854 | continue; 855 | break; 856 | case BIND_WHEN_USE: 857 | if (!Bind_When_Use) 858 | continue; 859 | break; 860 | case BIND_QUEST_ITEM: 861 | if (!Bind_Quest_Item) 862 | continue; 863 | break; 864 | default: 865 | continue; 866 | break; 867 | } 868 | 869 | switch (SellMethod) 870 | { 871 | case 0: 872 | if (itr->second.SellPrice == 0) 873 | continue; 874 | break; 875 | case 1: 876 | if (itr->second.BuyPrice == 0) 877 | continue; 878 | break; 879 | } 880 | 881 | if (itr->second.Quality > 6) 882 | continue; 883 | 884 | if ((Vendor_Items == 0) && !(itr->second.Class == ITEM_CLASS_TRADE_GOODS)) 885 | { 886 | bool isVendorItem = false; 887 | 888 | for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++) 889 | { 890 | if (itr->second.ItemId == npcItems[i]) 891 | isVendorItem = true; 892 | } 893 | 894 | if (isVendorItem) 895 | continue; 896 | } 897 | 898 | if ((Vendor_TGs == 0) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS)) 899 | { 900 | bool isVendorTG = false; 901 | 902 | for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorTG); i++) 903 | { 904 | if (itr->second.ItemId == npcItems[i]) 905 | isVendorTG = true; 906 | } 907 | 908 | if (isVendorTG) 909 | continue; 910 | } 911 | 912 | if ((Loot_Items == 0) && !(itr->second.Class == ITEM_CLASS_TRADE_GOODS)) 913 | { 914 | bool isLootItem = false; 915 | 916 | for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++) 917 | { 918 | if (itr->second.ItemId == lootItems[i]) 919 | isLootItem = true; 920 | } 921 | 922 | if (isLootItem) 923 | continue; 924 | } 925 | 926 | if ((Loot_TGs == 0) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS)) 927 | { 928 | bool isLootTG = false; 929 | 930 | for (unsigned int i = 0; (i < lootItems.size()) && (!isLootTG); i++) 931 | { 932 | if (itr->second.ItemId == lootItems[i]) 933 | isLootTG = true; 934 | } 935 | 936 | if (isLootTG) 937 | continue; 938 | } 939 | 940 | if ((Other_Items == 0) && !(itr->second.Class == ITEM_CLASS_TRADE_GOODS)) 941 | { 942 | bool isVendorItem = false; 943 | bool isLootItem = false; 944 | 945 | for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++) 946 | { 947 | if (itr->second.ItemId == npcItems[i]) 948 | isVendorItem = true; 949 | } 950 | for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++) 951 | { 952 | if (itr->second.ItemId == lootItems[i]) 953 | isLootItem = true; 954 | } 955 | if ((!isLootItem) && (!isVendorItem)) 956 | continue; 957 | } 958 | 959 | if ((Other_TGs == 0) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS)) 960 | { 961 | bool isVendorTG = false; 962 | bool isLootTG = false; 963 | 964 | for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorTG); i++) 965 | { 966 | if (itr->second.ItemId == npcItems[i]) 967 | isVendorTG = true; 968 | } 969 | for (unsigned int i = 0; (i < lootItems.size()) && (!isLootTG); i++) 970 | { 971 | if (itr->second.ItemId == lootItems[i]) 972 | isLootTG = true; 973 | } 974 | if ((!isLootTG) && (!isVendorTG)) 975 | continue; 976 | } 977 | 978 | // Disable items by Id 979 | if (DisableItemStore.find(itr->second.ItemId) != DisableItemStore.end()) 980 | { 981 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (PTR/Beta/Unused Item)", itr->second.ItemId); 982 | continue; 983 | } 984 | 985 | // Disable permanent enchants items 986 | if ((DisablePermEnchant) && (itr->second.Class == ITEM_CLASS_PERMANENT)) 987 | { 988 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Permanent Enchant Item)", itr->second.ItemId); 989 | continue; 990 | } 991 | 992 | // Disable conjured items 993 | if ((DisableConjured) && (itr->second.IsConjuredConsumable())) 994 | { 995 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Conjured Consumable)", itr->second.ItemId); 996 | continue; 997 | } 998 | 999 | // Disable gems 1000 | if ((DisableGems) && (itr->second.Class == ITEM_CLASS_GEM)) 1001 | { 1002 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Gem)", itr->second.ItemId); 1003 | continue; 1004 | } 1005 | 1006 | // Disable money 1007 | if ((DisableMoney) && (itr->second.Class == ITEM_CLASS_MONEY)) 1008 | { 1009 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Money)", itr->second.ItemId); 1010 | continue; 1011 | } 1012 | 1013 | // Disable moneyloot 1014 | if ((DisableMoneyLoot) && (itr->second.MinMoneyLoot > 0)) 1015 | { 1016 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (MoneyLoot)", itr->second.ItemId); 1017 | continue; 1018 | } 1019 | 1020 | // Disable lootable items 1021 | if ((DisableLootable) && (itr->second.Flags & 4)) 1022 | { 1023 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Lootable Item)", itr->second.ItemId); 1024 | continue; 1025 | } 1026 | 1027 | // Disable Keys 1028 | if ((DisableKeys) && (itr->second.Class == ITEM_CLASS_KEY)) 1029 | { 1030 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Quest Item)", itr->second.ItemId); 1031 | continue; 1032 | } 1033 | 1034 | // Disable items with duration 1035 | if ((DisableDuration) && (itr->second.Duration > 0)) 1036 | { 1037 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Has a Duration)", itr->second.ItemId); 1038 | continue; 1039 | } 1040 | 1041 | // Disable items which are BOP or Quest Items and have a required level lower than the item level 1042 | if ((DisableBOP_Or_Quest_NoReqLevel) && ((itr->second.Bonding == BIND_WHEN_PICKED_UP || itr->second.Bonding == BIND_QUEST_ITEM) && (itr->second.RequiredLevel < itr->second.ItemLevel))) 1043 | { 1044 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (BOP or BQI and Required Level is less than Item Level)", itr->second.ItemId); 1045 | continue; 1046 | } 1047 | 1048 | // Disable items specifically for Warrior 1049 | if ((DisableWarriorItems) && (itr->second.AllowableClass == 1)) 1050 | { 1051 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Warrior Item)", itr->second.ItemId); 1052 | continue; 1053 | } 1054 | 1055 | // Disable items specifically for Paladin 1056 | if ((DisablePaladinItems) && (itr->second.AllowableClass == 2)) 1057 | { 1058 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Paladin Item)", itr->second.ItemId); 1059 | continue; 1060 | } 1061 | 1062 | // Disable items specifically for Hunter 1063 | if ((DisableHunterItems) && (itr->second.AllowableClass == 4)) 1064 | { 1065 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Hunter Item)", itr->second.ItemId); 1066 | continue; 1067 | } 1068 | 1069 | // Disable items specifically for Rogue 1070 | if ((DisableRogueItems) && (itr->second.AllowableClass == 8)) 1071 | { 1072 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Rogue Item)", itr->second.ItemId); 1073 | continue; 1074 | } 1075 | 1076 | // Disable items specifically for Priest 1077 | if ((DisablePriestItems) && (itr->second.AllowableClass == 16)) 1078 | { 1079 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Priest Item)", itr->second.ItemId); 1080 | continue; 1081 | } 1082 | 1083 | // Disable items specifically for DK 1084 | if ((DisableDKItems) && (itr->second.AllowableClass == 32)) 1085 | { 1086 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (DK Item)", itr->second.ItemId); 1087 | continue; 1088 | } 1089 | 1090 | // Disable items specifically for Shaman 1091 | if ((DisableShamanItems) && (itr->second.AllowableClass == 64)) 1092 | { 1093 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Shaman Item)", itr->second.ItemId); 1094 | continue; 1095 | } 1096 | 1097 | // Disable items specifically for Mage 1098 | if ((DisableMageItems) && (itr->second.AllowableClass == 128)) 1099 | { 1100 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Mage Item)", itr->second.ItemId); 1101 | continue; 1102 | } 1103 | 1104 | // Disable items specifically for Warlock 1105 | if ((DisableWarlockItems) && (itr->second.AllowableClass == 256)) 1106 | { 1107 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Warlock Item)", itr->second.ItemId); 1108 | continue; 1109 | } 1110 | 1111 | // Disable items specifically for Unused Class 1112 | if ((DisableUnusedClassItems) && (itr->second.AllowableClass == 512)) 1113 | { 1114 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Unused Item)", itr->second.ItemId); 1115 | continue; 1116 | } 1117 | 1118 | // Disable items specifically for Druid 1119 | if ((DisableDruidItems) && (itr->second.AllowableClass == 1024)) 1120 | { 1121 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Druid Item)", itr->second.ItemId); 1122 | continue; 1123 | } 1124 | 1125 | // Disable Items below level X 1126 | if ((DisableItemsBelowLevel) && (itr->second.Class != ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemLevel < DisableItemsBelowLevel)) 1127 | { 1128 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Item Level = %u)", itr->second.ItemId, itr->second.ItemLevel); 1129 | continue; 1130 | } 1131 | 1132 | // Disable Items above level X 1133 | if ((DisableItemsAboveLevel) && (itr->second.Class != ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemLevel > DisableItemsAboveLevel)) 1134 | { 1135 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Item Level = %u)", itr->second.ItemId, itr->second.ItemLevel); 1136 | continue; 1137 | } 1138 | 1139 | // Disable Trade Goods below level X 1140 | if ((DisableTGsBelowLevel) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemLevel < DisableTGsBelowLevel)) 1141 | { 1142 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Trade Good %u disabled (Trade Good Level = %u)", itr->second.ItemId, itr->second.ItemLevel); 1143 | continue; 1144 | } 1145 | 1146 | // Disable Trade Goods above level X 1147 | if ((DisableTGsAboveLevel) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemLevel > DisableTGsAboveLevel)) 1148 | { 1149 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Trade Good %u disabled (Trade Good Level = %u)", itr->second.ItemId, itr->second.ItemLevel); 1150 | continue; 1151 | } 1152 | 1153 | // Disable Items below GUID X 1154 | if ((DisableItemsBelowGUID) && (itr->second.Class != ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemId < DisableItemsBelowGUID)) 1155 | { 1156 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Item Level = %u)", itr->second.ItemId, itr->second.ItemLevel); 1157 | continue; 1158 | } 1159 | 1160 | // Disable Items above GUID X 1161 | if ((DisableItemsAboveGUID) && (itr->second.Class != ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemId > DisableItemsAboveGUID)) 1162 | { 1163 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Item Level = %u)", itr->second.ItemId, itr->second.ItemLevel); 1164 | continue; 1165 | } 1166 | 1167 | // Disable Trade Goods below GUID X 1168 | if ((DisableTGsBelowGUID) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemId < DisableTGsBelowGUID)) 1169 | { 1170 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Trade Good Level = %u)", itr->second.ItemId, itr->second.ItemLevel); 1171 | continue; 1172 | } 1173 | 1174 | // Disable Trade Goods above GUID X 1175 | if ((DisableTGsAboveGUID) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemId > DisableTGsAboveGUID)) 1176 | { 1177 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (Trade Good Level = %u)", itr->second.ItemId, itr->second.ItemLevel); 1178 | continue; 1179 | } 1180 | 1181 | // Disable Items for level lower than X 1182 | if ((DisableItemsBelowReqLevel) && (itr->second.RequiredLevel < DisableItemsBelowReqLevel)) 1183 | { 1184 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (RequiredLevel = %u)", itr->second.ItemId, itr->second.RequiredLevel); 1185 | continue; 1186 | } 1187 | 1188 | // Disable Items for level higher than X 1189 | if ((DisableItemsAboveReqLevel) && (itr->second.RequiredLevel > DisableItemsAboveReqLevel)) 1190 | { 1191 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (RequiredLevel = %u)", itr->second.ItemId, itr->second.RequiredLevel); 1192 | continue; 1193 | } 1194 | 1195 | // Disable Trade Goods for level lower than X 1196 | if ((DisableTGsBelowReqLevel) && (itr->second.RequiredLevel < DisableTGsBelowReqLevel)) 1197 | { 1198 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Trade Good %u disabled (RequiredLevel = %u)", itr->second.ItemId, itr->second.RequiredLevel); 1199 | continue; 1200 | } 1201 | 1202 | // Disable Trade Goods for level higher than X 1203 | if ((DisableTGsAboveReqLevel) && (itr->second.RequiredLevel > DisableTGsAboveReqLevel)) 1204 | { 1205 | if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Trade Good %u disabled (RequiredLevel = %u)", itr->second.ItemId, itr->second.RequiredLevel); 1206 | continue; 1207 | } 1208 | 1209 | // Disable Items that require skill lower than X 1210 | // if ((DisableItemsBelowReqSkillRank) && (itr->second.RequiredSkillRank < DisableItemsBelowReqSkillRank)) 1211 | // { 1212 | // if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", itr->second.ItemId, itr->second.RequiredSkillRank); 1213 | // continue; 1214 | // } 1215 | 1216 | // Disable Items that require skill higher than X 1217 | // if ((DisableItemsAboveReqSkillRank) && (itr->second.RequiredSkillRank > DisableItemsAboveReqSkillRank)) 1218 | // { 1219 | // if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", itr->second.ItemId, itr->second.RequiredSkillRank); 1220 | // continue; 1221 | // } 1222 | 1223 | // Disable Trade Goods that require skill lower than X 1224 | // if ((DisableTGsBelowReqSkillRank) && (itr->second.RequiredSkillRank < DisableTGsBelowReqSkillRank)) 1225 | // { 1226 | // if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", itr->second.ItemId, itr->second.RequiredSkillRank); 1227 | // continue; 1228 | // } 1229 | 1230 | // Disable Trade Goods that require skill higher than X 1231 | // if ((DisableTGsAboveReqSkillRank) && (itr->second.?RequiredSkillRank > DisableTGsAboveReqSkillRank)) 1232 | // { 1233 | // if (debug_Out_Filters) sLog->outError( "AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", itr->second.ItemId, itr->second.RequiredSkillRank); 1234 | // continue; 1235 | // } 1236 | 1237 | switch (itr->second.Quality) 1238 | { 1239 | case AHB_GREY: 1240 | if (itr->second.Class == ITEM_CLASS_TRADE_GOODS) 1241 | greyTradeGoodsBin.push_back(itr->second.ItemId); 1242 | else 1243 | greyItemsBin.push_back(itr->second.ItemId); 1244 | break; 1245 | 1246 | case AHB_WHITE: 1247 | if (itr->second.Class == ITEM_CLASS_TRADE_GOODS) 1248 | whiteTradeGoodsBin.push_back(itr->second.ItemId); 1249 | else 1250 | whiteItemsBin.push_back(itr->second.ItemId); 1251 | break; 1252 | 1253 | case AHB_GREEN: 1254 | if (itr->second.Class == ITEM_CLASS_TRADE_GOODS) 1255 | greenTradeGoodsBin.push_back(itr->second.ItemId); 1256 | else 1257 | greenItemsBin.push_back(itr->second.ItemId); 1258 | break; 1259 | 1260 | case AHB_BLUE: 1261 | if (itr->second.Class == ITEM_CLASS_TRADE_GOODS) 1262 | blueTradeGoodsBin.push_back(itr->second.ItemId); 1263 | else 1264 | blueItemsBin.push_back(itr->second.ItemId); 1265 | break; 1266 | 1267 | case AHB_PURPLE: 1268 | if (itr->second.Class == ITEM_CLASS_TRADE_GOODS) 1269 | purpleTradeGoodsBin.push_back(itr->second.ItemId); 1270 | else 1271 | purpleItemsBin.push_back(itr->second.ItemId); 1272 | break; 1273 | 1274 | case AHB_ORANGE: 1275 | if (itr->second.Class == ITEM_CLASS_TRADE_GOODS) 1276 | orangeTradeGoodsBin.push_back(itr->second.ItemId); 1277 | else 1278 | orangeItemsBin.push_back(itr->second.ItemId); 1279 | break; 1280 | 1281 | case AHB_YELLOW: 1282 | if (itr->second.Class == ITEM_CLASS_TRADE_GOODS) 1283 | yellowTradeGoodsBin.push_back(itr->second.ItemId); 1284 | else 1285 | yellowItemsBin.push_back(itr->second.ItemId); 1286 | break; 1287 | } 1288 | } 1289 | 1290 | if ((greyTradeGoodsBin.size() == 0) && 1291 | (whiteTradeGoodsBin.size() == 0) && 1292 | (greenTradeGoodsBin.size() == 0) && 1293 | (blueTradeGoodsBin.size() == 0) && 1294 | (purpleTradeGoodsBin.size() == 0) && 1295 | (orangeTradeGoodsBin.size() == 0) && 1296 | (yellowTradeGoodsBin.size() == 0) && 1297 | (greyItemsBin.size() == 0) && 1298 | (whiteItemsBin.size() == 0) && 1299 | (greenItemsBin.size() == 0) && 1300 | (blueItemsBin.size() == 0) && 1301 | (purpleItemsBin.size() == 0) && 1302 | (orangeItemsBin.size() == 0) && 1303 | (yellowItemsBin.size() == 0)) 1304 | { 1305 | sLog->outError( "AuctionHouseBot: No items"); 1306 | AHBSeller = 0; 1307 | } 1308 | 1309 | sLog->outString("AuctionHouseBot:"); 1310 | sLog->outString("loaded %u grey trade goods", uint32(greyTradeGoodsBin.size())); 1311 | sLog->outString("loaded %u white trade goods", uint32(whiteTradeGoodsBin.size())); 1312 | sLog->outString("loaded %u green trade goods", uint32(greenTradeGoodsBin.size())); 1313 | sLog->outString("loaded %u blue trade goods", uint32(blueTradeGoodsBin.size())); 1314 | sLog->outString("loaded %u purple trade goods", uint32(purpleTradeGoodsBin.size())); 1315 | sLog->outString("loaded %u orange trade goods", uint32(orangeTradeGoodsBin.size())); 1316 | sLog->outString("loaded %u yellow trade goods", uint32(yellowTradeGoodsBin.size())); 1317 | sLog->outString("loaded %u grey items", uint32(greyItemsBin.size())); 1318 | sLog->outString("loaded %u white items", uint32(whiteItemsBin.size())); 1319 | sLog->outString("loaded %u green items", uint32(greenItemsBin.size())); 1320 | sLog->outString("loaded %u blue items", uint32(blueItemsBin.size())); 1321 | sLog->outString("loaded %u purple items", uint32(purpleItemsBin.size())); 1322 | sLog->outString("loaded %u orange items", uint32(orangeItemsBin.size())); 1323 | sLog->outString("loaded %u yellow items", uint32(yellowItemsBin.size())); 1324 | } 1325 | sLog->outString("AuctionHouseBot and AuctionHouseBuyer have been loaded."); 1326 | } 1327 | 1328 | void AuctionHouseBot::InitializeConfiguration() 1329 | { 1330 | debug_Out = sConfigMgr->GetBoolDefault("AuctionHouseBot.DEBUG", false); 1331 | debug_Out_Filters = sConfigMgr->GetBoolDefault("AuctionHouseBot.DEBUG_FILTERS", false); 1332 | 1333 | AHBSeller = sConfigMgr->GetBoolDefault("AuctionHouseBot.EnableSeller", false); 1334 | AHBBuyer = sConfigMgr->GetBoolDefault("AuctionHouseBot.EnableBuyer", false); 1335 | SellMethod = sConfigMgr->GetBoolDefault("AuctionHouseBot.UseBuyPriceForSeller", false); 1336 | BuyMethod = sConfigMgr->GetBoolDefault("AuctionHouseBot.UseBuyPriceForBuyer", false); 1337 | 1338 | AHBplayerAccount = sConfigMgr->GetIntDefault("AuctionHouseBot.Account", 0); 1339 | AHBplayerGUID = sConfigMgr->GetIntDefault("AuctionHouseBot.GUID", 0); 1340 | ItemsPerCycle = sConfigMgr->GetIntDefault("AuctionHouseBot.ItemsPerCycle", 200); 1341 | 1342 | //Begin Filters 1343 | 1344 | Vendor_Items = sConfigMgr->GetBoolDefault("AuctionHouseBot.VendorItems", false); 1345 | Loot_Items = sConfigMgr->GetBoolDefault("AuctionHouseBot.LootItems", true); 1346 | Other_Items = sConfigMgr->GetBoolDefault("AuctionHouseBot.OtherItems", false); 1347 | Vendor_TGs = sConfigMgr->GetBoolDefault("AuctionHouseBot.VendorTradeGoods", false); 1348 | Loot_TGs = sConfigMgr->GetBoolDefault("AuctionHouseBot.LootTradeGoods", true); 1349 | Other_TGs = sConfigMgr->GetBoolDefault("AuctionHouseBot.OtherTradeGoods", false); 1350 | 1351 | No_Bind = sConfigMgr->GetBoolDefault("AuctionHouseBot.No_Bind", true); 1352 | Bind_When_Picked_Up = sConfigMgr->GetBoolDefault("AuctionHouseBot.Bind_When_Picked_Up", false); 1353 | Bind_When_Equipped = sConfigMgr->GetBoolDefault("AuctionHouseBot.Bind_When_Equipped", true); 1354 | Bind_When_Use = sConfigMgr->GetBoolDefault("AuctionHouseBot.Bind_When_Use", true); 1355 | Bind_Quest_Item = sConfigMgr->GetBoolDefault("AuctionHouseBot.Bind_Quest_Item", false); 1356 | 1357 | DisablePermEnchant = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisablePermEnchant", false); 1358 | DisableConjured = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableConjured", false); 1359 | DisableGems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableGems", false); 1360 | DisableMoney = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableMoney", false); 1361 | DisableMoneyLoot = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableMoneyLoot", false); 1362 | DisableLootable = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableLootable", false); 1363 | DisableKeys = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableKeys", false); 1364 | DisableDuration = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableDuration", false); 1365 | DisableBOP_Or_Quest_NoReqLevel = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel", false); 1366 | 1367 | DisableWarriorItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableWarriorItems", false); 1368 | DisablePaladinItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisablePaladinItems", false); 1369 | DisableHunterItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableHunterItems", false); 1370 | DisableRogueItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableRogueItems", false); 1371 | DisablePriestItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisablePriestItems", false); 1372 | DisableDKItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableDKItems", false); 1373 | DisableShamanItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableShamanItems", false); 1374 | DisableMageItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableMageItems", false); 1375 | DisableWarlockItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableWarlockItems", false); 1376 | DisableUnusedClassItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableUnusedClassItems", false); 1377 | DisableDruidItems = sConfigMgr->GetBoolDefault("AuctionHouseBot.DisableDruidItems", false); 1378 | 1379 | DisableItemsBelowLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableItemsBelowLevel", 0); 1380 | DisableItemsAboveLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableItemsAboveLevel", 0); 1381 | DisableTGsBelowLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableTGsBelowLevel", 0); 1382 | DisableTGsAboveLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableTGsAboveLevel", 0); 1383 | DisableItemsBelowGUID = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableItemsBelowGUID", 0); 1384 | DisableItemsAboveGUID = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableItemsAboveGUID", 0); 1385 | DisableTGsBelowGUID = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableTGsBelowGUID", 0); 1386 | DisableTGsAboveGUID = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableTGsAboveGUID", 0); 1387 | DisableItemsBelowReqLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableItemsBelowReqLevel", 0); 1388 | DisableItemsAboveReqLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableItemsAboveReqLevel", 0); 1389 | DisableTGsBelowReqLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableTGsBelowReqLevel", 0); 1390 | DisableTGsAboveReqLevel = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableTGsAboveReqLevel", 0); 1391 | DisableItemsBelowReqSkillRank = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableItemsBelowReqSkillRank", 0); 1392 | DisableItemsAboveReqSkillRank = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableItemsAboveReqSkillRank", 0); 1393 | DisableTGsBelowReqSkillRank = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableTGsBelowReqSkillRank", 0); 1394 | DisableTGsAboveReqSkillRank = sConfigMgr->GetIntDefault("AuctionHouseBot.DisableTGsAboveReqSkillRank", 0); 1395 | } 1396 | 1397 | void AuctionHouseBot::IncrementItemCounts(AuctionEntry* ah) 1398 | { 1399 | // from auctionhousehandler.cpp, creates auction pointer & player pointer 1400 | 1401 | // get exact item information 1402 | Item *pItem = sAuctionMgr->GetAItem(ah->item_guidlow); 1403 | if (!pItem) 1404 | { 1405 | if (debug_Out) sLog->outError( "AHBot: Item %u doesn't exist, perhaps bought already?", ah->item_guidlow); 1406 | return; 1407 | } 1408 | 1409 | // get item prototype 1410 | ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(ah->item_template); 1411 | 1412 | AHBConfig *config; 1413 | 1414 | FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseFaction()); 1415 | if (!u_entry) 1416 | { 1417 | if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction()); 1418 | config = &NeutralConfig; 1419 | } 1420 | else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) 1421 | { 1422 | if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Alliance", ah->GetHouseFaction()); 1423 | config = &AllianceConfig; 1424 | } 1425 | else if (u_entry->ourMask & FACTION_MASK_HORDE) 1426 | { 1427 | if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Horde", ah->GetHouseFaction()); 1428 | config = &HordeConfig; 1429 | } 1430 | else 1431 | { 1432 | if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction()); 1433 | config = &NeutralConfig; 1434 | } 1435 | 1436 | config->IncItemCounts(prototype->Class, prototype->Quality); 1437 | } 1438 | 1439 | void AuctionHouseBot::DecrementItemCounts(AuctionEntry* ah, uint32 itemEntry) 1440 | { 1441 | // get item prototype 1442 | ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(itemEntry); 1443 | 1444 | AHBConfig *config; 1445 | 1446 | FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseFaction()); 1447 | if (!u_entry) 1448 | { 1449 | if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction()); 1450 | config = &NeutralConfig; 1451 | } 1452 | else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) 1453 | { 1454 | if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Alliance", ah->GetHouseFaction()); 1455 | config = &AllianceConfig; 1456 | } 1457 | else if (u_entry->ourMask & FACTION_MASK_HORDE) 1458 | { 1459 | if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Horde", ah->GetHouseFaction()); 1460 | config = &HordeConfig; 1461 | } 1462 | else 1463 | { 1464 | if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction()); 1465 | config = &NeutralConfig; 1466 | } 1467 | 1468 | config->DecItemCounts(prototype->Class, prototype->Quality); 1469 | } 1470 | 1471 | void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char* args) 1472 | { 1473 | AHBConfig *config = NULL; 1474 | switch (ahMapID) 1475 | { 1476 | case 2: 1477 | config = &AllianceConfig; 1478 | break; 1479 | case 6: 1480 | config = &HordeConfig; 1481 | break; 1482 | case 7: 1483 | config = &NeutralConfig; 1484 | break; 1485 | } 1486 | std::string color; 1487 | switch (col) 1488 | { 1489 | case AHB_GREY: 1490 | color = "grey"; 1491 | break; 1492 | case AHB_WHITE: 1493 | color = "white"; 1494 | break; 1495 | case AHB_GREEN: 1496 | color = "green"; 1497 | break; 1498 | case AHB_BLUE: 1499 | color = "blue"; 1500 | break; 1501 | case AHB_PURPLE: 1502 | color = "purple"; 1503 | break; 1504 | case AHB_ORANGE: 1505 | color = "orange"; 1506 | break; 1507 | case AHB_YELLOW: 1508 | color = "yellow"; 1509 | break; 1510 | default: 1511 | break; 1512 | } 1513 | switch (command) 1514 | { 1515 | case 0: //ahexpire 1516 | { 1517 | AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID()); 1518 | 1519 | AuctionHouseObject::AuctionEntryMap::iterator itr; 1520 | itr = auctionHouse->GetAuctionsBegin(); 1521 | 1522 | while (itr != auctionHouse->GetAuctionsEnd()) 1523 | { 1524 | if (itr->second->owner == AHBplayerGUID) 1525 | { 1526 | itr->second->expire_time = sWorld->GetGameTime(); 1527 | uint32 id = itr->second->Id; 1528 | uint32 expire_time = itr->second->expire_time; 1529 | CharacterDatabase.PExecute("UPDATE auctionhouse SET time = '%u' WHERE id = '%u'", expire_time, id); 1530 | } 1531 | ++itr; 1532 | } 1533 | } 1534 | break; 1535 | case 1: //min items 1536 | { 1537 | char * param1 = strtok(args, " "); 1538 | uint32 minItems = (uint32) strtoul(param1, NULL, 0); 1539 | WorldDatabase.PExecute("UPDATE auctionhousebot SET minitems = '%u' WHERE auctionhouse = '%u'", minItems, ahMapID); 1540 | config->SetMinItems(minItems); 1541 | } 1542 | break; 1543 | case 2: //max items 1544 | { 1545 | char * param1 = strtok(args, " "); 1546 | uint32 maxItems = (uint32) strtoul(param1, NULL, 0); 1547 | WorldDatabase.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems, ahMapID); 1548 | config->SetMaxItems(maxItems); 1549 | config->CalculatePercents(); 1550 | } 1551 | break; 1552 | case 3: //min time Deprecated (Place holder for future commands) 1553 | break; 1554 | case 4: //max time Deprecated (Place holder for future commands) 1555 | break; 1556 | case 5: //percentages 1557 | { 1558 | char * param1 = strtok(args, " "); 1559 | char * param2 = strtok(NULL, " "); 1560 | char * param3 = strtok(NULL, " "); 1561 | char * param4 = strtok(NULL, " "); 1562 | char * param5 = strtok(NULL, " "); 1563 | char * param6 = strtok(NULL, " "); 1564 | char * param7 = strtok(NULL, " "); 1565 | char * param8 = strtok(NULL, " "); 1566 | char * param9 = strtok(NULL, " "); 1567 | char * param10 = strtok(NULL, " "); 1568 | char * param11 = strtok(NULL, " "); 1569 | char * param12 = strtok(NULL, " "); 1570 | char * param13 = strtok(NULL, " "); 1571 | char * param14 = strtok(NULL, " "); 1572 | uint32 greytg = (uint32) strtoul(param1, NULL, 0); 1573 | uint32 whitetg = (uint32) strtoul(param2, NULL, 0); 1574 | uint32 greentg = (uint32) strtoul(param3, NULL, 0); 1575 | uint32 bluetg = (uint32) strtoul(param4, NULL, 0); 1576 | uint32 purpletg = (uint32) strtoul(param5, NULL, 0); 1577 | uint32 orangetg = (uint32) strtoul(param6, NULL, 0); 1578 | uint32 yellowtg = (uint32) strtoul(param7, NULL, 0); 1579 | uint32 greyi = (uint32) strtoul(param8, NULL, 0); 1580 | uint32 whitei = (uint32) strtoul(param9, NULL, 0); 1581 | uint32 greeni = (uint32) strtoul(param10, NULL, 0); 1582 | uint32 bluei = (uint32) strtoul(param11, NULL, 0); 1583 | uint32 purplei = (uint32) strtoul(param12, NULL, 0); 1584 | uint32 orangei = (uint32) strtoul(param13, NULL, 0); 1585 | uint32 yellowi = (uint32) strtoul(param14, NULL, 0); 1586 | 1587 | SQLTransaction trans = WorldDatabase.BeginTransaction(); 1588 | trans->PAppend("UPDATE auctionhousebot SET percentgreytradegoods = '%u' WHERE auctionhouse = '%u'", greytg, ahMapID); 1589 | trans->PAppend("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", whitetg, ahMapID); 1590 | trans->PAppend("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", greentg, ahMapID); 1591 | trans->PAppend("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", bluetg, ahMapID); 1592 | trans->PAppend("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", purpletg, ahMapID); 1593 | trans->PAppend("UPDATE auctionhousebot SET percentorangetradegoods = '%u' WHERE auctionhouse = '%u'", orangetg, ahMapID); 1594 | trans->PAppend("UPDATE auctionhousebot SET percentyellowtradegoods = '%u' WHERE auctionhouse = '%u'", yellowtg, ahMapID); 1595 | trans->PAppend("UPDATE auctionhousebot SET percentgreyitems = '%u' WHERE auctionhouse = '%u'", greyi, ahMapID); 1596 | trans->PAppend("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", whitei, ahMapID); 1597 | trans->PAppend("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", greeni, ahMapID); 1598 | trans->PAppend("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bluei, ahMapID); 1599 | trans->PAppend("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", purplei, ahMapID); 1600 | trans->PAppend("UPDATE auctionhousebot SET percentorangeitems = '%u' WHERE auctionhouse = '%u'", orangei, ahMapID); 1601 | trans->PAppend("UPDATE auctionhousebot SET percentyellowitems = '%u' WHERE auctionhouse = '%u'", yellowi, ahMapID); 1602 | WorldDatabase.CommitTransaction(trans); 1603 | config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi); 1604 | } 1605 | break; 1606 | case 6: //min prices 1607 | { 1608 | char * param1 = strtok(args, " "); 1609 | uint32 minPrice = (uint32) strtoul(param1, NULL, 0); 1610 | WorldDatabase.PExecute("UPDATE auctionhousebot SET minprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), minPrice, ahMapID); 1611 | config->SetMinPrice(col, minPrice); 1612 | } 1613 | break; 1614 | case 7: //max prices 1615 | { 1616 | char * param1 = strtok(args, " "); 1617 | uint32 maxPrice = (uint32) strtoul(param1, NULL, 0); 1618 | WorldDatabase.PExecute("UPDATE auctionhousebot SET maxprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), maxPrice, ahMapID); 1619 | config->SetMaxPrice(col, maxPrice); 1620 | } 1621 | break; 1622 | case 8: //min bid price 1623 | { 1624 | char * param1 = strtok(args, " "); 1625 | uint32 minBidPrice = (uint32) strtoul(param1, NULL, 0); 1626 | WorldDatabase.PExecute("UPDATE auctionhousebot SET minbidprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), minBidPrice, ahMapID); 1627 | config->SetMinBidPrice(col, minBidPrice); 1628 | } 1629 | break; 1630 | case 9: //max bid price 1631 | { 1632 | char * param1 = strtok(args, " "); 1633 | uint32 maxBidPrice = (uint32) strtoul(param1, NULL, 0); 1634 | WorldDatabase.PExecute("UPDATE auctionhousebot SET maxbidprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), maxBidPrice, ahMapID); 1635 | config->SetMaxBidPrice(col, maxBidPrice); 1636 | } 1637 | break; 1638 | case 10: //max stacks 1639 | { 1640 | char * param1 = strtok(args, " "); 1641 | uint32 maxStack = (uint32) strtoul(param1, NULL, 0); 1642 | WorldDatabase.PExecute("UPDATE auctionhousebot SET maxstack%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), maxStack, ahMapID); 1643 | config->SetMaxStack(col, maxStack); 1644 | } 1645 | break; 1646 | case 11: //buyer bid prices 1647 | { 1648 | char * param1 = strtok(args, " "); 1649 | uint32 buyerPrice = (uint32) strtoul(param1, NULL, 0); 1650 | WorldDatabase.PExecute("UPDATE auctionhousebot SET buyerprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), buyerPrice, ahMapID); 1651 | config->SetBuyerPrice(col, buyerPrice); 1652 | } 1653 | break; 1654 | case 12: //buyer bidding interval 1655 | { 1656 | char * param1 = strtok(args, " "); 1657 | uint32 bidInterval = (uint32) strtoul(param1, NULL, 0); 1658 | WorldDatabase.PExecute("UPDATE auctionhousebot SET buyerbiddinginterval = '%u' WHERE auctionhouse = '%u'", bidInterval, ahMapID); 1659 | config->SetBiddingInterval(bidInterval); 1660 | } 1661 | break; 1662 | case 13: //buyer bids per interval 1663 | { 1664 | char * param1 = strtok(args, " "); 1665 | uint32 bidsPerInterval = (uint32) strtoul(param1, NULL, 0); 1666 | WorldDatabase.PExecute("UPDATE auctionhousebot SET buyerbidsperinterval = '%u' WHERE auctionhouse = '%u'", bidsPerInterval, ahMapID); 1667 | config->SetBidsPerInterval(bidsPerInterval); 1668 | } 1669 | break; 1670 | default: 1671 | break; 1672 | } 1673 | } 1674 | 1675 | void AuctionHouseBot::LoadValues(AHBConfig *config) 1676 | { 1677 | if (debug_Out) 1678 | sLog->outError( "Start Settings for %s Auctionhouses:", WorldDatabase.PQuery("SELECT name FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetCString()); 1679 | if (AHBSeller) 1680 | { 1681 | //load min and max items 1682 | config->SetMinItems(WorldDatabase.PQuery("SELECT minitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1683 | config->SetMaxItems(WorldDatabase.PQuery("SELECT maxitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1684 | //load percentages 1685 | uint32 greytg = WorldDatabase.PQuery("SELECT percentgreytradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1686 | uint32 whitetg = WorldDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1687 | uint32 greentg = WorldDatabase.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1688 | uint32 bluetg = WorldDatabase.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1689 | uint32 purpletg = WorldDatabase.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1690 | uint32 orangetg = WorldDatabase.PQuery("SELECT percentorangetradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1691 | uint32 yellowtg = WorldDatabase.PQuery("SELECT percentyellowtradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1692 | uint32 greyi = WorldDatabase.PQuery("SELECT percentgreyitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1693 | uint32 whitei = WorldDatabase.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1694 | uint32 greeni = WorldDatabase.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1695 | uint32 bluei = WorldDatabase.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1696 | uint32 purplei = WorldDatabase.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1697 | uint32 orangei = WorldDatabase.PQuery("SELECT percentorangeitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1698 | uint32 yellowi = WorldDatabase.PQuery("SELECT percentyellowitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32(); 1699 | config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi); 1700 | //load min and max prices 1701 | config->SetMinPrice(AHB_GREY, WorldDatabase.PQuery("SELECT minpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1702 | config->SetMaxPrice(AHB_GREY, WorldDatabase.PQuery("SELECT maxpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1703 | config->SetMinPrice(AHB_WHITE, WorldDatabase.PQuery("SELECT minpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1704 | config->SetMaxPrice(AHB_WHITE, WorldDatabase.PQuery("SELECT maxpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1705 | config->SetMinPrice(AHB_GREEN, WorldDatabase.PQuery("SELECT minpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1706 | config->SetMaxPrice(AHB_GREEN, WorldDatabase.PQuery("SELECT maxpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1707 | config->SetMinPrice(AHB_BLUE, WorldDatabase.PQuery("SELECT minpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1708 | config->SetMaxPrice(AHB_BLUE, WorldDatabase.PQuery("SELECT maxpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1709 | config->SetMinPrice(AHB_PURPLE, WorldDatabase.PQuery("SELECT minpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1710 | config->SetMaxPrice(AHB_PURPLE, WorldDatabase.PQuery("SELECT maxpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1711 | config->SetMinPrice(AHB_ORANGE, WorldDatabase.PQuery("SELECT minpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1712 | config->SetMaxPrice(AHB_ORANGE, WorldDatabase.PQuery("SELECT maxpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1713 | config->SetMinPrice(AHB_YELLOW, WorldDatabase.PQuery("SELECT minpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1714 | config->SetMaxPrice(AHB_YELLOW, WorldDatabase.PQuery("SELECT maxpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1715 | //load min and max bid prices 1716 | config->SetMinBidPrice(AHB_GREY, WorldDatabase.PQuery("SELECT minbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1717 | config->SetMaxBidPrice(AHB_GREY, WorldDatabase.PQuery("SELECT maxbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1718 | config->SetMinBidPrice(AHB_WHITE, WorldDatabase.PQuery("SELECT minbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1719 | config->SetMaxBidPrice(AHB_WHITE, WorldDatabase.PQuery("SELECT maxbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1720 | config->SetMinBidPrice(AHB_GREEN, WorldDatabase.PQuery("SELECT minbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1721 | config->SetMaxBidPrice(AHB_GREEN, WorldDatabase.PQuery("SELECT maxbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1722 | config->SetMinBidPrice(AHB_BLUE, WorldDatabase.PQuery("SELECT minbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1723 | config->SetMaxBidPrice(AHB_BLUE, WorldDatabase.PQuery("SELECT maxbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1724 | config->SetMinBidPrice(AHB_PURPLE, WorldDatabase.PQuery("SELECT minbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1725 | config->SetMaxBidPrice(AHB_PURPLE, WorldDatabase.PQuery("SELECT maxbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1726 | config->SetMinBidPrice(AHB_ORANGE, WorldDatabase.PQuery("SELECT minbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1727 | config->SetMaxBidPrice(AHB_ORANGE, WorldDatabase.PQuery("SELECT maxbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1728 | config->SetMinBidPrice(AHB_YELLOW, WorldDatabase.PQuery("SELECT minbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1729 | config->SetMaxBidPrice(AHB_YELLOW, WorldDatabase.PQuery("SELECT maxbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1730 | //load max stacks 1731 | config->SetMaxStack(AHB_GREY, WorldDatabase.PQuery("SELECT maxstackgrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1732 | config->SetMaxStack(AHB_WHITE, WorldDatabase.PQuery("SELECT maxstackwhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1733 | config->SetMaxStack(AHB_GREEN, WorldDatabase.PQuery("SELECT maxstackgreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1734 | config->SetMaxStack(AHB_BLUE, WorldDatabase.PQuery("SELECT maxstackblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1735 | config->SetMaxStack(AHB_PURPLE, WorldDatabase.PQuery("SELECT maxstackpurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1736 | config->SetMaxStack(AHB_ORANGE, WorldDatabase.PQuery("SELECT maxstackorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1737 | config->SetMaxStack(AHB_YELLOW, WorldDatabase.PQuery("SELECT maxstackyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1738 | if (debug_Out) 1739 | { 1740 | sLog->outError( "minItems = %u", config->GetMinItems()); 1741 | sLog->outError( "maxItems = %u", config->GetMaxItems()); 1742 | sLog->outError( "percentGreyTradeGoods = %u", config->GetPercentages(AHB_GREY_TG)); 1743 | sLog->outError( "percentWhiteTradeGoods = %u", config->GetPercentages(AHB_WHITE_TG)); 1744 | sLog->outError( "percentGreenTradeGoods = %u", config->GetPercentages(AHB_GREEN_TG)); 1745 | sLog->outError( "percentBlueTradeGoods = %u", config->GetPercentages(AHB_BLUE_TG)); 1746 | sLog->outError( "percentPurpleTradeGoods = %u", config->GetPercentages(AHB_PURPLE_TG)); 1747 | sLog->outError( "percentOrangeTradeGoods = %u", config->GetPercentages(AHB_ORANGE_TG)); 1748 | sLog->outError( "percentYellowTradeGoods = %u", config->GetPercentages(AHB_YELLOW_TG)); 1749 | sLog->outError( "percentGreyItems = %u", config->GetPercentages(AHB_GREY_I)); 1750 | sLog->outError( "percentWhiteItems = %u", config->GetPercentages(AHB_WHITE_I)); 1751 | sLog->outError( "percentGreenItems = %u", config->GetPercentages(AHB_GREEN_I)); 1752 | sLog->outError( "percentBlueItems = %u", config->GetPercentages(AHB_BLUE_I)); 1753 | sLog->outError( "percentPurpleItems = %u", config->GetPercentages(AHB_PURPLE_I)); 1754 | sLog->outError( "percentOrangeItems = %u", config->GetPercentages(AHB_ORANGE_I)); 1755 | sLog->outError( "percentYellowItems = %u", config->GetPercentages(AHB_YELLOW_I)); 1756 | sLog->outError( "minPriceGrey = %u", config->GetMinPrice(AHB_GREY)); 1757 | sLog->outError( "maxPriceGrey = %u", config->GetMaxPrice(AHB_GREY)); 1758 | sLog->outError( "minPriceWhite = %u", config->GetMinPrice(AHB_WHITE)); 1759 | sLog->outError( "maxPriceWhite = %u", config->GetMaxPrice(AHB_WHITE)); 1760 | sLog->outError( "minPriceGreen = %u", config->GetMinPrice(AHB_GREEN)); 1761 | sLog->outError( "maxPriceGreen = %u", config->GetMaxPrice(AHB_GREEN)); 1762 | sLog->outError( "minPriceBlue = %u", config->GetMinPrice(AHB_BLUE)); 1763 | sLog->outError( "maxPriceBlue = %u", config->GetMaxPrice(AHB_BLUE)); 1764 | sLog->outError( "minPricePurple = %u", config->GetMinPrice(AHB_PURPLE)); 1765 | sLog->outError( "maxPricePurple = %u", config->GetMaxPrice(AHB_PURPLE)); 1766 | sLog->outError( "minPriceOrange = %u", config->GetMinPrice(AHB_ORANGE)); 1767 | sLog->outError( "maxPriceOrange = %u", config->GetMaxPrice(AHB_ORANGE)); 1768 | sLog->outError( "minPriceYellow = %u", config->GetMinPrice(AHB_YELLOW)); 1769 | sLog->outError( "maxPriceYellow = %u", config->GetMaxPrice(AHB_YELLOW)); 1770 | sLog->outError( "minBidPriceGrey = %u", config->GetMinBidPrice(AHB_GREY)); 1771 | sLog->outError( "maxBidPriceGrey = %u", config->GetMaxBidPrice(AHB_GREY)); 1772 | sLog->outError( "minBidPriceWhite = %u", config->GetMinBidPrice(AHB_WHITE)); 1773 | sLog->outError( "maxBidPriceWhite = %u", config->GetMaxBidPrice(AHB_WHITE)); 1774 | sLog->outError( "minBidPriceGreen = %u", config->GetMinBidPrice(AHB_GREEN)); 1775 | sLog->outError( "maxBidPriceGreen = %u", config->GetMaxBidPrice(AHB_GREEN)); 1776 | sLog->outError( "minBidPriceBlue = %u", config->GetMinBidPrice(AHB_BLUE)); 1777 | sLog->outError( "maxBidPriceBlue = %u", config->GetMinBidPrice(AHB_BLUE)); 1778 | sLog->outError( "minBidPricePurple = %u", config->GetMinBidPrice(AHB_PURPLE)); 1779 | sLog->outError( "maxBidPricePurple = %u", config->GetMaxBidPrice(AHB_PURPLE)); 1780 | sLog->outError( "minBidPriceOrange = %u", config->GetMinBidPrice(AHB_ORANGE)); 1781 | sLog->outError( "maxBidPriceOrange = %u", config->GetMaxBidPrice(AHB_ORANGE)); 1782 | sLog->outError( "minBidPriceYellow = %u", config->GetMinBidPrice(AHB_YELLOW)); 1783 | sLog->outError( "maxBidPriceYellow = %u", config->GetMaxBidPrice(AHB_YELLOW)); 1784 | sLog->outError( "maxStackGrey = %u", config->GetMaxStack(AHB_GREY)); 1785 | sLog->outError( "maxStackWhite = %u", config->GetMaxStack(AHB_WHITE)); 1786 | sLog->outError( "maxStackGreen = %u", config->GetMaxStack(AHB_GREEN)); 1787 | sLog->outError( "maxStackBlue = %u", config->GetMaxStack(AHB_BLUE)); 1788 | sLog->outError( "maxStackPurple = %u", config->GetMaxStack(AHB_PURPLE)); 1789 | sLog->outError( "maxStackOrange = %u", config->GetMaxStack(AHB_ORANGE)); 1790 | sLog->outError( "maxStackYellow = %u", config->GetMaxStack(AHB_YELLOW)); 1791 | } 1792 | //AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntry(config->GetAHFID()); 1793 | AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID()); 1794 | 1795 | config->ResetItemCounts(); 1796 | uint32 auctions = auctionHouse->Getcount(); 1797 | 1798 | if (auctions) 1799 | { 1800 | for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr) 1801 | { 1802 | AuctionEntry *Aentry = itr->second; 1803 | Item *item = sAuctionMgr->GetAItem(Aentry->item_guidlow); 1804 | if (item) 1805 | { 1806 | ItemTemplate const *prototype = item->GetTemplate(); 1807 | if (prototype) 1808 | { 1809 | switch (prototype->Quality) 1810 | { 1811 | case 0: 1812 | if (prototype->Class == ITEM_CLASS_TRADE_GOODS) 1813 | config->IncItemCounts(AHB_GREY_TG); 1814 | else 1815 | config->IncItemCounts(AHB_GREY_I); 1816 | break; 1817 | case 1: 1818 | if (prototype->Class == ITEM_CLASS_TRADE_GOODS) 1819 | config->IncItemCounts(AHB_WHITE_TG); 1820 | else 1821 | config->IncItemCounts(AHB_WHITE_I); 1822 | break; 1823 | case 2: 1824 | if (prototype->Class == ITEM_CLASS_TRADE_GOODS) 1825 | config->IncItemCounts(AHB_GREEN_TG); 1826 | else 1827 | config->IncItemCounts(AHB_GREEN_I); 1828 | break; 1829 | case 3: 1830 | if (prototype->Class == ITEM_CLASS_TRADE_GOODS) 1831 | config->IncItemCounts(AHB_BLUE_TG); 1832 | else 1833 | config->IncItemCounts(AHB_BLUE_I); 1834 | break; 1835 | case 4: 1836 | if (prototype->Class == ITEM_CLASS_TRADE_GOODS) 1837 | config->IncItemCounts(AHB_PURPLE_TG); 1838 | else 1839 | config->IncItemCounts(AHB_PURPLE_I); 1840 | break; 1841 | case 5: 1842 | if (prototype->Class == ITEM_CLASS_TRADE_GOODS) 1843 | config->IncItemCounts(AHB_ORANGE_TG); 1844 | else 1845 | config->IncItemCounts(AHB_ORANGE_I); 1846 | break; 1847 | case 6: 1848 | if (prototype->Class == ITEM_CLASS_TRADE_GOODS) 1849 | config->IncItemCounts(AHB_YELLOW_TG); 1850 | else 1851 | config->IncItemCounts(AHB_YELLOW_I); 1852 | break; 1853 | } 1854 | } 1855 | } 1856 | } 1857 | } 1858 | if (debug_Out) 1859 | { 1860 | sLog->outError( "Current Settings for %s Auctionhouses:", WorldDatabase.PQuery("SELECT name FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetCString()); 1861 | sLog->outError( "Grey Trade Goods\t%u\tGrey Items\t%u", config->GetItemCounts(AHB_GREY_TG), config->GetItemCounts(AHB_GREY_I)); 1862 | sLog->outError( "White Trade Goods\t%u\tWhite Items\t%u", config->GetItemCounts(AHB_WHITE_TG), config->GetItemCounts(AHB_WHITE_I)); 1863 | sLog->outError( "Green Trade Goods\t%u\tGreen Items\t%u", config->GetItemCounts(AHB_GREEN_TG), config->GetItemCounts(AHB_GREEN_I)); 1864 | sLog->outError( "Blue Trade Goods\t%u\tBlue Items\t%u", config->GetItemCounts(AHB_BLUE_TG), config->GetItemCounts(AHB_BLUE_I)); 1865 | sLog->outError( "Purple Trade Goods\t%u\tPurple Items\t%u", config->GetItemCounts(AHB_PURPLE_TG), config->GetItemCounts(AHB_PURPLE_I)); 1866 | sLog->outError( "Orange Trade Goods\t%u\tOrange Items\t%u", config->GetItemCounts(AHB_ORANGE_TG), config->GetItemCounts(AHB_ORANGE_I)); 1867 | sLog->outError( "Yellow Trade Goods\t%u\tYellow Items\t%u", config->GetItemCounts(AHB_YELLOW_TG), config->GetItemCounts(AHB_YELLOW_I)); 1868 | } 1869 | } 1870 | if (AHBBuyer) 1871 | { 1872 | //load buyer bid prices 1873 | config->SetBuyerPrice(AHB_GREY, WorldDatabase.PQuery("SELECT buyerpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1874 | config->SetBuyerPrice(AHB_WHITE, WorldDatabase.PQuery("SELECT buyerpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1875 | config->SetBuyerPrice(AHB_GREEN, WorldDatabase.PQuery("SELECT buyerpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1876 | config->SetBuyerPrice(AHB_BLUE, WorldDatabase.PQuery("SELECT buyerpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1877 | config->SetBuyerPrice(AHB_PURPLE, WorldDatabase.PQuery("SELECT buyerpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1878 | config->SetBuyerPrice(AHB_ORANGE, WorldDatabase.PQuery("SELECT buyerpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1879 | config->SetBuyerPrice(AHB_YELLOW, WorldDatabase.PQuery("SELECT buyerpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1880 | //load bidding interval 1881 | config->SetBiddingInterval(WorldDatabase.PQuery("SELECT buyerbiddinginterval FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1882 | //load bids per interval 1883 | config->SetBidsPerInterval(WorldDatabase.PQuery("SELECT buyerbidsperinterval FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32()); 1884 | if (debug_Out) 1885 | { 1886 | sLog->outError( "buyerPriceGrey = %u", config->GetBuyerPrice(AHB_GREY)); 1887 | sLog->outError( "buyerPriceWhite = %u", config->GetBuyerPrice(AHB_WHITE)); 1888 | sLog->outError( "buyerPriceGreen = %u", config->GetBuyerPrice(AHB_GREEN)); 1889 | sLog->outError( "buyerPriceBlue = %u", config->GetBuyerPrice(AHB_BLUE)); 1890 | sLog->outError( "buyerPricePurple = %u", config->GetBuyerPrice(AHB_PURPLE)); 1891 | sLog->outError( "buyerPriceOrange = %u", config->GetBuyerPrice(AHB_ORANGE)); 1892 | sLog->outError( "buyerPriceYellow = %u", config->GetBuyerPrice(AHB_YELLOW)); 1893 | sLog->outError( "buyerBiddingInterval = %u", config->GetBiddingInterval()); 1894 | sLog->outError( "buyerBidsPerInterval = %u", config->GetBidsPerInterval()); 1895 | } 1896 | } 1897 | if (debug_Out) sLog->outError( "End Settings for %s Auctionhouses:", WorldDatabase.PQuery("SELECT name FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetCString()); 1898 | } 1899 | -------------------------------------------------------------------------------- /src/AuctionHouseBot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2010 Trinity 3 | * Copyright (C) 2005-2009 MaNGOS 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef AUCTION_HOUSE_BOT_H 21 | #define AUCTION_HOUSE_BOT_H 22 | 23 | #include "Common.h" 24 | 25 | struct AuctionEntry; 26 | class Player; 27 | class WorldSession; 28 | 29 | #include "ItemPrototype.h" 30 | #define AHB_GREY 0 31 | #define AHB_WHITE 1 32 | #define AHB_GREEN 2 33 | #define AHB_BLUE 3 34 | #define AHB_PURPLE 4 35 | #define AHB_ORANGE 5 36 | #define AHB_YELLOW 6 37 | #define AHB_MAX_QUALITY 6 38 | #define AHB_GREY_TG 0 39 | #define AHB_WHITE_TG 1 40 | #define AHB_GREEN_TG 2 41 | #define AHB_BLUE_TG 3 42 | #define AHB_PURPLE_TG 4 43 | #define AHB_ORANGE_TG 5 44 | #define AHB_YELLOW_TG 6 45 | #define AHB_GREY_I 7 46 | #define AHB_WHITE_I 8 47 | #define AHB_GREEN_I 9 48 | #define AHB_BLUE_I 10 49 | #define AHB_PURPLE_I 11 50 | #define AHB_ORANGE_I 12 51 | #define AHB_YELLOW_I 13 52 | 53 | class AHBConfig 54 | { 55 | private: 56 | uint32 AHID; 57 | uint32 AHFID; 58 | uint32 minItems; 59 | uint32 maxItems; 60 | uint32 percentGreyTradeGoods; 61 | uint32 percentWhiteTradeGoods; 62 | uint32 percentGreenTradeGoods; 63 | uint32 percentBlueTradeGoods; 64 | uint32 percentPurpleTradeGoods; 65 | uint32 percentOrangeTradeGoods; 66 | uint32 percentYellowTradeGoods; 67 | uint32 percentGreyItems; 68 | uint32 percentWhiteItems; 69 | uint32 percentGreenItems; 70 | uint32 percentBlueItems; 71 | uint32 percentPurpleItems; 72 | uint32 percentOrangeItems; 73 | uint32 percentYellowItems; 74 | uint32 minPriceGrey; 75 | uint32 maxPriceGrey; 76 | uint32 minBidPriceGrey; 77 | uint32 maxBidPriceGrey; 78 | uint32 maxStackGrey; 79 | uint32 minPriceWhite; 80 | uint32 maxPriceWhite; 81 | uint32 minBidPriceWhite; 82 | uint32 maxBidPriceWhite; 83 | uint32 maxStackWhite; 84 | uint32 minPriceGreen; 85 | uint32 maxPriceGreen; 86 | uint32 minBidPriceGreen; 87 | uint32 maxBidPriceGreen; 88 | uint32 maxStackGreen; 89 | uint32 minPriceBlue; 90 | uint32 maxPriceBlue; 91 | uint32 minBidPriceBlue; 92 | uint32 maxBidPriceBlue; 93 | uint32 maxStackBlue; 94 | uint32 minPricePurple; 95 | uint32 maxPricePurple; 96 | uint32 minBidPricePurple; 97 | uint32 maxBidPricePurple; 98 | uint32 maxStackPurple; 99 | uint32 minPriceOrange; 100 | uint32 maxPriceOrange; 101 | uint32 minBidPriceOrange; 102 | uint32 maxBidPriceOrange; 103 | uint32 maxStackOrange; 104 | uint32 minPriceYellow; 105 | uint32 maxPriceYellow; 106 | uint32 minBidPriceYellow; 107 | uint32 maxBidPriceYellow; 108 | uint32 maxStackYellow; 109 | 110 | uint32 buyerPriceGrey; 111 | uint32 buyerPriceWhite; 112 | uint32 buyerPriceGreen; 113 | uint32 buyerPriceBlue; 114 | uint32 buyerPricePurple; 115 | uint32 buyerPriceOrange; 116 | uint32 buyerPriceYellow; 117 | uint32 buyerBiddingInterval; 118 | uint32 buyerBidsPerInterval; 119 | 120 | uint32 greytgp; 121 | uint32 whitetgp; 122 | uint32 greentgp; 123 | uint32 bluetgp; 124 | uint32 purpletgp; 125 | uint32 orangetgp; 126 | uint32 yellowtgp; 127 | uint32 greyip; 128 | uint32 whiteip; 129 | uint32 greenip; 130 | uint32 blueip; 131 | uint32 purpleip; 132 | uint32 orangeip; 133 | uint32 yellowip; 134 | 135 | uint32 greyTGoods; 136 | uint32 whiteTGoods; 137 | uint32 greenTGoods; 138 | uint32 blueTGoods; 139 | uint32 purpleTGoods; 140 | uint32 orangeTGoods; 141 | uint32 yellowTGoods; 142 | 143 | uint32 greyItems; 144 | uint32 whiteItems; 145 | uint32 greenItems; 146 | uint32 blueItems; 147 | uint32 purpleItems; 148 | uint32 orangeItems; 149 | uint32 yellowItems; 150 | 151 | public: 152 | AHBConfig(uint32 ahid) 153 | { 154 | AHID = ahid; 155 | switch(ahid) 156 | { 157 | case 2: 158 | AHFID = 55; 159 | break; 160 | case 6: 161 | AHFID = 29; 162 | break; 163 | case 7: 164 | AHFID = 120; 165 | break; 166 | default: 167 | AHFID = 120; 168 | break; 169 | } 170 | } 171 | AHBConfig() 172 | { 173 | } 174 | uint32 GetAHID() 175 | { 176 | return AHID; 177 | } 178 | uint32 GetAHFID() 179 | { 180 | return AHFID; 181 | } 182 | void SetMinItems(uint32 value) 183 | { 184 | minItems = value; 185 | } 186 | uint32 GetMinItems() 187 | { 188 | if ((minItems == 0) && (maxItems)) 189 | return maxItems; 190 | else if ((maxItems) && (minItems > maxItems)) 191 | return maxItems; 192 | else 193 | return minItems; 194 | } 195 | void SetMaxItems(uint32 value) 196 | { 197 | maxItems = value; 198 | // CalculatePercents() needs to be called, but only if 199 | // SetPercentages() has been called at least once already. 200 | } 201 | uint32 GetMaxItems() 202 | { 203 | return maxItems; 204 | } 205 | void SetPercentages(uint32 greytg, uint32 whitetg, uint32 greentg, uint32 bluetg, uint32 purpletg, uint32 orangetg, uint32 yellowtg, uint32 greyi, uint32 whitei, uint32 greeni, uint32 bluei, uint32 purplei, uint32 orangei, uint32 yellowi) 206 | { 207 | uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi; 208 | 209 | if (totalPercent == 0) 210 | { 211 | maxItems = 0; 212 | } 213 | else if (totalPercent != 100) 214 | { 215 | greytg = 0; 216 | whitetg = 27; 217 | greentg = 12; 218 | bluetg = 10; 219 | purpletg = 1; 220 | orangetg = 0; 221 | yellowtg = 0; 222 | greyi = 0; 223 | whitei = 10; 224 | greeni = 30; 225 | bluei = 8; 226 | purplei = 2; 227 | orangei = 0; 228 | yellowi = 0; 229 | } 230 | percentGreyTradeGoods = greytg; 231 | percentWhiteTradeGoods = whitetg; 232 | percentGreenTradeGoods = greentg; 233 | percentBlueTradeGoods = bluetg; 234 | percentPurpleTradeGoods = purpletg; 235 | percentOrangeTradeGoods = orangetg; 236 | percentYellowTradeGoods = yellowtg; 237 | percentGreyItems = greyi; 238 | percentWhiteItems = whitei; 239 | percentGreenItems = greeni; 240 | percentBlueItems = bluei; 241 | percentPurpleItems = purplei; 242 | percentOrangeItems = orangei; 243 | percentYellowItems = yellowi; 244 | CalculatePercents(); 245 | } 246 | uint32 GetPercentages(uint32 color) 247 | { 248 | switch(color) 249 | { 250 | case AHB_GREY_TG: 251 | return percentGreyTradeGoods; 252 | break; 253 | case AHB_WHITE_TG: 254 | return percentWhiteTradeGoods; 255 | break; 256 | case AHB_GREEN_TG: 257 | return percentGreenTradeGoods; 258 | break; 259 | case AHB_BLUE_TG: 260 | return percentBlueTradeGoods; 261 | break; 262 | case AHB_PURPLE_TG: 263 | return percentPurpleTradeGoods; 264 | break; 265 | case AHB_ORANGE_TG: 266 | return percentOrangeTradeGoods; 267 | break; 268 | case AHB_YELLOW_TG: 269 | return percentYellowTradeGoods; 270 | break; 271 | case AHB_GREY_I: 272 | return percentGreyItems; 273 | break; 274 | case AHB_WHITE_I: 275 | return percentWhiteItems; 276 | break; 277 | case AHB_GREEN_I: 278 | return percentGreenItems; 279 | break; 280 | case AHB_BLUE_I: 281 | return percentBlueItems; 282 | break; 283 | case AHB_PURPLE_I: 284 | return percentPurpleItems; 285 | break; 286 | case AHB_ORANGE_I: 287 | return percentOrangeItems; 288 | break; 289 | case AHB_YELLOW_I: 290 | return percentYellowItems; 291 | break; 292 | default: 293 | return 0; 294 | break; 295 | } 296 | } 297 | void SetMinPrice(uint32 color, uint32 value) 298 | { 299 | switch(color) 300 | { 301 | case AHB_GREY: 302 | minPriceGrey = value; 303 | break; 304 | case AHB_WHITE: 305 | minPriceWhite = value; 306 | break; 307 | case AHB_GREEN: 308 | minPriceGreen = value; 309 | break; 310 | case AHB_BLUE: 311 | minPriceBlue = value; 312 | break; 313 | case AHB_PURPLE: 314 | minPricePurple = value; 315 | break; 316 | case AHB_ORANGE: 317 | minPriceOrange = value; 318 | break; 319 | case AHB_YELLOW: 320 | minPriceYellow = value; 321 | break; 322 | default: 323 | break; 324 | } 325 | } 326 | uint32 GetMinPrice(uint32 color) 327 | { 328 | switch(color) 329 | { 330 | case AHB_GREY: 331 | { 332 | if (minPriceGrey == 0) 333 | return 100; 334 | else if (minPriceGrey > maxPriceGrey) 335 | return maxPriceGrey; 336 | else 337 | return minPriceGrey; 338 | break; 339 | } 340 | case AHB_WHITE: 341 | { 342 | if (minPriceWhite == 0) 343 | return 150; 344 | else if (minPriceWhite > maxPriceWhite) 345 | return maxPriceWhite; 346 | else 347 | return minPriceWhite; 348 | break; 349 | } 350 | case AHB_GREEN: 351 | { 352 | if (minPriceGreen == 0) 353 | return 200; 354 | else if (minPriceGreen > maxPriceGreen) 355 | return maxPriceGreen; 356 | else 357 | return minPriceGreen; 358 | break; 359 | } 360 | case AHB_BLUE: 361 | { 362 | if (minPriceBlue == 0) 363 | return 250; 364 | else if (minPriceBlue > maxPriceBlue) 365 | return maxPriceBlue; 366 | else 367 | return minPriceBlue; 368 | break; 369 | } 370 | case AHB_PURPLE: 371 | { 372 | if (minPricePurple == 0) 373 | return 300; 374 | else if (minPricePurple > maxPricePurple) 375 | return maxPricePurple; 376 | else 377 | return minPricePurple; 378 | break; 379 | } 380 | case AHB_ORANGE: 381 | { 382 | if (minPriceOrange == 0) 383 | return 400; 384 | else if (minPriceOrange > maxPriceOrange) 385 | return maxPriceOrange; 386 | else 387 | return minPriceOrange; 388 | break; 389 | } 390 | case AHB_YELLOW: 391 | { 392 | if (minPriceYellow == 0) 393 | return 500; 394 | else if (minPriceYellow > maxPriceYellow) 395 | return maxPriceYellow; 396 | else 397 | return minPriceYellow; 398 | break; 399 | } 400 | default: 401 | { 402 | return 0; 403 | break; 404 | } 405 | } 406 | } 407 | void SetMaxPrice(uint32 color, uint32 value) 408 | { 409 | switch(color) 410 | { 411 | case AHB_GREY: 412 | maxPriceGrey = value; 413 | break; 414 | case AHB_WHITE: 415 | maxPriceWhite = value; 416 | break; 417 | case AHB_GREEN: 418 | maxPriceGreen = value; 419 | break; 420 | case AHB_BLUE: 421 | maxPriceBlue = value; 422 | break; 423 | case AHB_PURPLE: 424 | maxPricePurple = value; 425 | break; 426 | case AHB_ORANGE: 427 | maxPriceOrange = value; 428 | break; 429 | case AHB_YELLOW: 430 | maxPriceYellow = value; 431 | break; 432 | default: 433 | break; 434 | } 435 | } 436 | uint32 GetMaxPrice(uint32 color) 437 | { 438 | switch(color) 439 | { 440 | case AHB_GREY: 441 | { 442 | if (maxPriceGrey == 0) 443 | return 150; 444 | else 445 | return maxPriceGrey; 446 | break; 447 | } 448 | case AHB_WHITE: 449 | { 450 | if (maxPriceWhite == 0) 451 | return 250; 452 | else 453 | return maxPriceWhite; 454 | break; 455 | } 456 | case AHB_GREEN: 457 | { 458 | if (maxPriceGreen == 0) 459 | return 300; 460 | else 461 | return maxPriceGreen; 462 | break; 463 | } 464 | case AHB_BLUE: 465 | { 466 | if (maxPriceBlue == 0) 467 | return 350; 468 | else 469 | return maxPriceBlue; 470 | break; 471 | } 472 | case AHB_PURPLE: 473 | { 474 | if (maxPricePurple == 0) 475 | return 450; 476 | else 477 | return maxPricePurple; 478 | break; 479 | } 480 | case AHB_ORANGE: 481 | { 482 | if (maxPriceOrange == 0) 483 | return 550; 484 | else 485 | return maxPriceOrange; 486 | break; 487 | } 488 | case AHB_YELLOW: 489 | { 490 | if (maxPriceYellow == 0) 491 | return 650; 492 | else 493 | return maxPriceYellow; 494 | break; 495 | } 496 | default: 497 | { 498 | return 0; 499 | break; 500 | } 501 | } 502 | } 503 | void SetMinBidPrice(uint32 color, uint32 value) 504 | { 505 | switch(color) 506 | { 507 | case AHB_GREY: 508 | minBidPriceGrey = value; 509 | break; 510 | case AHB_WHITE: 511 | minBidPriceWhite = value; 512 | break; 513 | case AHB_GREEN: 514 | minBidPriceGreen = value; 515 | break; 516 | case AHB_BLUE: 517 | minBidPriceBlue = value; 518 | break; 519 | case AHB_PURPLE: 520 | minBidPricePurple = value; 521 | break; 522 | case AHB_ORANGE: 523 | minBidPriceOrange = value; 524 | break; 525 | case AHB_YELLOW: 526 | minBidPriceYellow = value; 527 | break; 528 | default: 529 | break; 530 | } 531 | } 532 | uint32 GetMinBidPrice(uint32 color) 533 | { 534 | switch(color) 535 | { 536 | case AHB_GREY: 537 | { 538 | if (minBidPriceGrey > 100) 539 | return 100; 540 | else 541 | return minBidPriceGrey; 542 | break; 543 | } 544 | case AHB_WHITE: 545 | { 546 | if (minBidPriceWhite > 100) 547 | return 100; 548 | else 549 | return minBidPriceWhite; 550 | break; 551 | } 552 | case AHB_GREEN: 553 | { 554 | if (minBidPriceGreen > 100) 555 | return 100; 556 | else 557 | return minBidPriceGreen; 558 | break; 559 | } 560 | case AHB_BLUE: 561 | { 562 | if (minBidPriceBlue > 100) 563 | return 100; 564 | else 565 | return minBidPriceBlue; 566 | break; 567 | } 568 | case AHB_PURPLE: 569 | { 570 | if (minBidPricePurple > 100) 571 | return 100; 572 | else 573 | return minBidPricePurple; 574 | break; 575 | } 576 | case AHB_ORANGE: 577 | { 578 | if (minBidPriceOrange > 100) 579 | return 100; 580 | else 581 | return minBidPriceOrange; 582 | break; 583 | } 584 | case AHB_YELLOW: 585 | { 586 | if (minBidPriceYellow > 100) 587 | return 100; 588 | else 589 | return minBidPriceYellow; 590 | break; 591 | } 592 | default: 593 | { 594 | return 0; 595 | break; 596 | } 597 | } 598 | } 599 | void SetMaxBidPrice(uint32 color, uint32 value) 600 | { 601 | switch(color) 602 | { 603 | case AHB_GREY: 604 | maxBidPriceGrey = value; 605 | break; 606 | case AHB_WHITE: 607 | maxBidPriceWhite = value; 608 | break; 609 | case AHB_GREEN: 610 | maxBidPriceGreen = value; 611 | break; 612 | case AHB_BLUE: 613 | maxBidPriceBlue = value; 614 | break; 615 | case AHB_PURPLE: 616 | maxBidPricePurple = value; 617 | break; 618 | case AHB_ORANGE: 619 | maxBidPriceOrange = value; 620 | break; 621 | case AHB_YELLOW: 622 | maxBidPriceYellow = value; 623 | break; 624 | default: 625 | break; 626 | } 627 | } 628 | uint32 GetMaxBidPrice(uint32 color) 629 | { 630 | switch(color) 631 | { 632 | case AHB_GREY: 633 | { 634 | if (maxBidPriceGrey > 100) 635 | return 100; 636 | else 637 | return maxBidPriceGrey; 638 | break; 639 | } 640 | case AHB_WHITE: 641 | { 642 | if (maxBidPriceWhite > 100) 643 | return 100; 644 | else 645 | return maxBidPriceWhite; 646 | break; 647 | } 648 | case AHB_GREEN: 649 | { 650 | if (maxBidPriceGreen > 100) 651 | return 100; 652 | else 653 | return maxBidPriceGreen; 654 | break; 655 | } 656 | case AHB_BLUE: 657 | { 658 | if (maxBidPriceBlue > 100) 659 | return 100; 660 | else 661 | return maxBidPriceBlue; 662 | break; 663 | } 664 | case AHB_PURPLE: 665 | { 666 | if (maxBidPricePurple > 100) 667 | return 100; 668 | else 669 | return maxBidPricePurple; 670 | break; 671 | } 672 | case AHB_ORANGE: 673 | { 674 | if (maxBidPriceOrange > 100) 675 | return 100; 676 | else 677 | return maxBidPriceOrange; 678 | break; 679 | } 680 | case AHB_YELLOW: 681 | { 682 | if (maxBidPriceYellow > 100) 683 | return 100; 684 | else 685 | return maxBidPriceYellow; 686 | break; 687 | } 688 | default: 689 | { 690 | return 0; 691 | break; 692 | } 693 | } 694 | } 695 | void SetMaxStack(uint32 color, uint32 value) 696 | { 697 | switch(color) 698 | { 699 | case AHB_GREY: 700 | maxStackGrey = value; 701 | break; 702 | case AHB_WHITE: 703 | maxStackWhite = value; 704 | break; 705 | case AHB_GREEN: 706 | maxStackGreen = value; 707 | break; 708 | case AHB_BLUE: 709 | maxStackBlue = value; 710 | break; 711 | case AHB_PURPLE: 712 | maxStackPurple = value; 713 | break; 714 | case AHB_ORANGE: 715 | maxStackOrange = value; 716 | break; 717 | case AHB_YELLOW: 718 | maxStackYellow = value; 719 | break; 720 | default: 721 | break; 722 | } 723 | } 724 | uint32 GetMaxStack(uint32 color) 725 | { 726 | switch(color) 727 | { 728 | case AHB_GREY: 729 | { 730 | return maxStackGrey; 731 | break; 732 | } 733 | case AHB_WHITE: 734 | { 735 | return maxStackWhite; 736 | break; 737 | } 738 | case AHB_GREEN: 739 | { 740 | return maxStackGreen; 741 | break; 742 | } 743 | case AHB_BLUE: 744 | { 745 | return maxStackBlue; 746 | break; 747 | } 748 | case AHB_PURPLE: 749 | { 750 | return maxStackPurple; 751 | break; 752 | } 753 | case AHB_ORANGE: 754 | { 755 | return maxStackOrange; 756 | break; 757 | } 758 | case AHB_YELLOW: 759 | { 760 | return maxStackYellow; 761 | break; 762 | } 763 | default: 764 | { 765 | return 0; 766 | break; 767 | } 768 | } 769 | } 770 | void SetBuyerPrice(uint32 color, uint32 value) 771 | { 772 | switch(color) 773 | { 774 | case AHB_GREY: 775 | buyerPriceGrey = value; 776 | break; 777 | case AHB_WHITE: 778 | buyerPriceWhite = value; 779 | break; 780 | case AHB_GREEN: 781 | buyerPriceGreen = value; 782 | break; 783 | case AHB_BLUE: 784 | buyerPriceBlue = value; 785 | break; 786 | case AHB_PURPLE: 787 | buyerPricePurple = value; 788 | break; 789 | case AHB_ORANGE: 790 | buyerPriceOrange = value; 791 | break; 792 | case AHB_YELLOW: 793 | buyerPriceYellow = value; 794 | break; 795 | default: 796 | break; 797 | } 798 | } 799 | uint32 GetBuyerPrice(uint32 color) 800 | { 801 | switch(color) 802 | { 803 | case AHB_GREY: 804 | return buyerPriceGrey; 805 | break; 806 | case AHB_WHITE: 807 | return buyerPriceWhite; 808 | break; 809 | case AHB_GREEN: 810 | return buyerPriceGreen; 811 | break; 812 | case AHB_BLUE: 813 | return buyerPriceBlue; 814 | break; 815 | case AHB_PURPLE: 816 | return buyerPricePurple; 817 | break; 818 | case AHB_ORANGE: 819 | return buyerPriceOrange; 820 | break; 821 | case AHB_YELLOW: 822 | return buyerPriceYellow; 823 | break; 824 | default: 825 | return 0; 826 | break; 827 | } 828 | } 829 | void SetBiddingInterval(uint32 value) 830 | { 831 | buyerBiddingInterval = value; 832 | } 833 | uint32 GetBiddingInterval() 834 | { 835 | return buyerBiddingInterval; 836 | } 837 | void CalculatePercents() 838 | { 839 | greytgp = (uint32) (((double)percentGreyTradeGoods / 100.0) * maxItems); 840 | whitetgp = (uint32) (((double)percentWhiteTradeGoods / 100.0) * maxItems); 841 | greentgp = (uint32) (((double)percentGreenTradeGoods / 100.0) * maxItems); 842 | bluetgp = (uint32) (((double)percentBlueTradeGoods / 100.0) * maxItems); 843 | purpletgp = (uint32) (((double)percentPurpleTradeGoods / 100.0) * maxItems); 844 | orangetgp = (uint32) (((double)percentOrangeTradeGoods / 100.0) * maxItems); 845 | yellowtgp = (uint32) (((double)percentYellowTradeGoods / 100.0) * maxItems); 846 | greyip = (uint32) (((double)percentGreyItems / 100.0) * maxItems); 847 | whiteip = (uint32) (((double)percentWhiteItems / 100.0) * maxItems); 848 | greenip = (uint32) (((double)percentGreenItems / 100.0) * maxItems); 849 | blueip = (uint32) (((double)percentBlueItems / 100.0) * maxItems); 850 | purpleip = (uint32) (((double)percentPurpleItems / 100.0) * maxItems); 851 | orangeip = (uint32) (((double)percentOrangeItems / 100.0) * maxItems); 852 | yellowip = (uint32) (((double)percentYellowItems / 100.0) * maxItems); 853 | uint32 total = greytgp + whitetgp + greentgp + bluetgp + purpletgp + orangetgp + yellowtgp + greyip + whiteip + greenip + blueip + purpleip + orangeip + yellowip; 854 | int32 diff = (maxItems - total); 855 | if (diff < 0) 856 | { 857 | if ((whiteip - diff) > 0) 858 | whiteip -= diff; 859 | else if ((greenip - diff) > 0) 860 | greenip -= diff; 861 | } 862 | else if (diff < 0) 863 | { 864 | whiteip += diff; 865 | } 866 | } 867 | uint32 GetPercents(uint32 color) 868 | { 869 | switch(color) 870 | { 871 | case AHB_GREY_TG: 872 | return greytgp; 873 | break; 874 | case AHB_WHITE_TG: 875 | return whitetgp; 876 | break; 877 | case AHB_GREEN_TG: 878 | return greentgp; 879 | break; 880 | case AHB_BLUE_TG: 881 | return bluetgp; 882 | break; 883 | case AHB_PURPLE_TG: 884 | return purpletgp; 885 | break; 886 | case AHB_ORANGE_TG: 887 | return orangetgp; 888 | break; 889 | case AHB_YELLOW_TG: 890 | return yellowtgp; 891 | break; 892 | case AHB_GREY_I: 893 | return greyip; 894 | break; 895 | case AHB_WHITE_I: 896 | return whiteip; 897 | break; 898 | case AHB_GREEN_I: 899 | return greenip; 900 | break; 901 | case AHB_BLUE_I: 902 | return blueip; 903 | break; 904 | case AHB_PURPLE_I: 905 | return purpleip; 906 | break; 907 | case AHB_ORANGE_I: 908 | return orangeip; 909 | break; 910 | case AHB_YELLOW_I: 911 | return yellowip; 912 | break; 913 | default: 914 | return 0; 915 | break; 916 | } 917 | } 918 | 919 | void DecItemCounts(uint32 Class, uint32 Quality) 920 | { 921 | switch(Class) 922 | { 923 | case ITEM_CLASS_TRADE_GOODS: 924 | DecItemCounts(Quality); 925 | break; 926 | default: 927 | DecItemCounts(Quality + 7); 928 | break; 929 | } 930 | } 931 | 932 | void DecItemCounts(uint32 color) 933 | { 934 | switch(color) 935 | { 936 | case AHB_GREY_TG: 937 | --greyTGoods; 938 | break; 939 | case AHB_WHITE_TG: 940 | --whiteTGoods; 941 | break; 942 | case AHB_GREEN_TG: 943 | --greenTGoods; 944 | break; 945 | case AHB_BLUE_TG: 946 | --blueTGoods; 947 | break; 948 | case AHB_PURPLE_TG: 949 | --purpleTGoods; 950 | break; 951 | case AHB_ORANGE_TG: 952 | --orangeTGoods; 953 | break; 954 | case AHB_YELLOW_TG: 955 | --yellowTGoods; 956 | break; 957 | case AHB_GREY_I: 958 | --greyItems; 959 | break; 960 | case AHB_WHITE_I: 961 | --whiteItems; 962 | break; 963 | case AHB_GREEN_I: 964 | --greenItems; 965 | break; 966 | case AHB_BLUE_I: 967 | --blueItems; 968 | break; 969 | case AHB_PURPLE_I: 970 | --purpleItems; 971 | break; 972 | case AHB_ORANGE_I: 973 | --orangeItems; 974 | break; 975 | case AHB_YELLOW_I: 976 | --yellowItems; 977 | break; 978 | default: 979 | break; 980 | } 981 | } 982 | 983 | void IncItemCounts(uint32 Class, uint32 Quality) 984 | { 985 | switch(Class) 986 | { 987 | case ITEM_CLASS_TRADE_GOODS: 988 | IncItemCounts(Quality); 989 | break; 990 | default: 991 | IncItemCounts(Quality + 7); 992 | break; 993 | } 994 | } 995 | 996 | void IncItemCounts(uint32 color) 997 | { 998 | switch(color) 999 | { 1000 | case AHB_GREY_TG: 1001 | ++greyTGoods; 1002 | break; 1003 | case AHB_WHITE_TG: 1004 | ++whiteTGoods; 1005 | break; 1006 | case AHB_GREEN_TG: 1007 | ++greenTGoods; 1008 | break; 1009 | case AHB_BLUE_TG: 1010 | ++blueTGoods; 1011 | break; 1012 | case AHB_PURPLE_TG: 1013 | ++purpleTGoods; 1014 | break; 1015 | case AHB_ORANGE_TG: 1016 | ++orangeTGoods; 1017 | break; 1018 | case AHB_YELLOW_TG: 1019 | ++yellowTGoods; 1020 | break; 1021 | case AHB_GREY_I: 1022 | ++greyItems; 1023 | break; 1024 | case AHB_WHITE_I: 1025 | ++whiteItems; 1026 | break; 1027 | case AHB_GREEN_I: 1028 | ++greenItems; 1029 | break; 1030 | case AHB_BLUE_I: 1031 | ++blueItems; 1032 | break; 1033 | case AHB_PURPLE_I: 1034 | ++purpleItems; 1035 | break; 1036 | case AHB_ORANGE_I: 1037 | ++orangeItems; 1038 | break; 1039 | case AHB_YELLOW_I: 1040 | ++yellowItems; 1041 | break; 1042 | default: 1043 | break; 1044 | } 1045 | } 1046 | 1047 | void ResetItemCounts() 1048 | { 1049 | greyTGoods = 0; 1050 | whiteTGoods = 0; 1051 | greenTGoods = 0; 1052 | blueTGoods = 0; 1053 | purpleTGoods = 0; 1054 | orangeTGoods = 0; 1055 | yellowTGoods = 0; 1056 | 1057 | greyItems = 0; 1058 | whiteItems = 0; 1059 | greenItems = 0; 1060 | blueItems = 0; 1061 | purpleItems = 0; 1062 | orangeItems = 0; 1063 | yellowItems = 0; 1064 | } 1065 | 1066 | uint32 TotalItemCounts() 1067 | { 1068 | return( 1069 | greyTGoods + 1070 | whiteTGoods + 1071 | greenTGoods + 1072 | blueTGoods + 1073 | purpleTGoods + 1074 | orangeTGoods + 1075 | yellowTGoods + 1076 | 1077 | greyItems + 1078 | whiteItems + 1079 | greenItems + 1080 | blueItems + 1081 | purpleItems + 1082 | orangeItems + 1083 | yellowItems); 1084 | } 1085 | 1086 | uint32 GetItemCounts(uint32 color) 1087 | { 1088 | switch(color) 1089 | { 1090 | case AHB_GREY_TG: 1091 | return greyTGoods; 1092 | break; 1093 | case AHB_WHITE_TG: 1094 | return whiteTGoods; 1095 | break; 1096 | case AHB_GREEN_TG: 1097 | return greenTGoods; 1098 | break; 1099 | case AHB_BLUE_TG: 1100 | return blueTGoods; 1101 | break; 1102 | case AHB_PURPLE_TG: 1103 | return purpleTGoods; 1104 | break; 1105 | case AHB_ORANGE_TG: 1106 | return orangeTGoods; 1107 | break; 1108 | case AHB_YELLOW_TG: 1109 | return yellowTGoods; 1110 | break; 1111 | case AHB_GREY_I: 1112 | return greyItems; 1113 | break; 1114 | case AHB_WHITE_I: 1115 | return whiteItems; 1116 | break; 1117 | case AHB_GREEN_I: 1118 | return greenItems; 1119 | break; 1120 | case AHB_BLUE_I: 1121 | return blueItems; 1122 | break; 1123 | case AHB_PURPLE_I: 1124 | return purpleItems; 1125 | break; 1126 | case AHB_ORANGE_I: 1127 | return orangeItems; 1128 | break; 1129 | case AHB_YELLOW_I: 1130 | return yellowItems; 1131 | break; 1132 | default: 1133 | return 0; 1134 | break; 1135 | } 1136 | } 1137 | void SetBidsPerInterval(uint32 value) 1138 | { 1139 | buyerBidsPerInterval = value; 1140 | } 1141 | uint32 GetBidsPerInterval() 1142 | { 1143 | return buyerBidsPerInterval; 1144 | } 1145 | ~AHBConfig() 1146 | { 1147 | } 1148 | }; 1149 | class AuctionHouseBot 1150 | { 1151 | private: 1152 | 1153 | bool debug_Out; 1154 | bool debug_Out_Filters; 1155 | 1156 | bool AHBSeller; 1157 | bool AHBBuyer; 1158 | bool BuyMethod; 1159 | bool SellMethod; 1160 | 1161 | uint32 AHBplayerAccount; 1162 | uint32 AHBplayerGUID; 1163 | uint32 ItemsPerCycle; 1164 | 1165 | //Begin Filters 1166 | 1167 | bool Vendor_Items; 1168 | bool Loot_Items; 1169 | bool Other_Items; 1170 | bool Vendor_TGs; 1171 | bool Loot_TGs; 1172 | bool Other_TGs; 1173 | 1174 | bool No_Bind; 1175 | bool Bind_When_Picked_Up; 1176 | bool Bind_When_Equipped; 1177 | bool Bind_When_Use; 1178 | bool Bind_Quest_Item; 1179 | 1180 | bool DisablePermEnchant; 1181 | bool DisableConjured; 1182 | bool DisableGems; 1183 | bool DisableMoney; 1184 | bool DisableMoneyLoot; 1185 | bool DisableLootable; 1186 | bool DisableKeys; 1187 | bool DisableDuration; 1188 | bool DisableBOP_Or_Quest_NoReqLevel; 1189 | 1190 | bool DisableWarriorItems; 1191 | bool DisablePaladinItems; 1192 | bool DisableHunterItems; 1193 | bool DisableRogueItems; 1194 | bool DisablePriestItems; 1195 | bool DisableDKItems; 1196 | bool DisableShamanItems; 1197 | bool DisableMageItems; 1198 | bool DisableWarlockItems; 1199 | bool DisableUnusedClassItems; 1200 | bool DisableDruidItems; 1201 | 1202 | uint32 DisableItemsBelowLevel; 1203 | uint32 DisableItemsAboveLevel; 1204 | uint32 DisableTGsBelowLevel; 1205 | uint32 DisableTGsAboveLevel; 1206 | uint32 DisableItemsBelowGUID; 1207 | uint32 DisableItemsAboveGUID; 1208 | uint32 DisableTGsBelowGUID; 1209 | uint32 DisableTGsAboveGUID; 1210 | uint32 DisableItemsBelowReqLevel; 1211 | uint32 DisableItemsAboveReqLevel; 1212 | uint32 DisableTGsBelowReqLevel; 1213 | uint32 DisableTGsAboveReqLevel; 1214 | uint32 DisableItemsBelowReqSkillRank; 1215 | uint32 DisableItemsAboveReqSkillRank; 1216 | uint32 DisableTGsBelowReqSkillRank; 1217 | uint32 DisableTGsAboveReqSkillRank; 1218 | 1219 | std::set DisableItemStore; 1220 | 1221 | //End Filters 1222 | 1223 | AHBConfig AllianceConfig; 1224 | AHBConfig HordeConfig; 1225 | AHBConfig NeutralConfig; 1226 | 1227 | time_t _lastrun_a; 1228 | time_t _lastrun_h; 1229 | time_t _lastrun_n; 1230 | 1231 | inline uint32 minValue(uint32 a, uint32 b) { return a <= b ? a : b; }; 1232 | void addNewAuctions(Player *AHBplayer, AHBConfig *config); 1233 | void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session); 1234 | 1235 | // friend class ACE_Singleton; 1236 | AuctionHouseBot(); 1237 | 1238 | public: 1239 | static AuctionHouseBot* instance() 1240 | { 1241 | static AuctionHouseBot instance; 1242 | return &instance; 1243 | } 1244 | 1245 | ~AuctionHouseBot(); 1246 | void Update(); 1247 | void Initialize(); 1248 | void InitializeConfiguration(); 1249 | void LoadValues(AHBConfig*); 1250 | void DecrementItemCounts(AuctionEntry* ah, uint32 itemEntry); 1251 | void IncrementItemCounts(AuctionEntry* ah); 1252 | void Commands(uint32, uint32, uint32, char*); 1253 | uint32 GetAHBplayerGUID() { return AHBplayerGUID; }; 1254 | }; 1255 | 1256 | #define auctionbot AuctionHouseBot::instance() 1257 | 1258 | #endif 1259 | -------------------------------------------------------------------------------- /src/cs_ah_bot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2012 TrinityCore 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License as published by the 6 | * Free Software Foundation; either version 2 of the License, or (at your 7 | * option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program. If not, see . 16 | */ 17 | 18 | /* ScriptData 19 | Name: ah_bot_commandscript 20 | %Complete: 100 21 | Comment: All ah_bot related commands 22 | Category: commandscripts 23 | EndScriptData */ 24 | 25 | #include "ScriptMgr.h" 26 | #include "Chat.h" 27 | #include "AuctionHouseBot.h" 28 | #include "Config.h" 29 | 30 | class ah_bot_commandscript : public CommandScript 31 | { 32 | public: 33 | ah_bot_commandscript() : CommandScript("ah_bot_commandscript") { } 34 | 35 | std::vector GetCommands() const override 36 | { 37 | static std::vector commandTable = 38 | { 39 | { "ahbotoptions", SEC_GAMEMASTER, true, &HandleAHBotOptionsCommand, "" }, 40 | }; 41 | return commandTable; 42 | } 43 | 44 | static bool HandleAHBotOptionsCommand(ChatHandler* handler, const char*args) 45 | { 46 | uint32 ahMapID = 0; 47 | char* opt = strtok((char*)args, " "); 48 | char* ahMapIdStr = strtok(NULL, " "); 49 | 50 | if (ahMapIdStr) 51 | { 52 | ahMapID = uint32(strtoul(ahMapIdStr, NULL, 0)); 53 | switch (ahMapID) 54 | { 55 | case 2: 56 | case 6: 57 | case 7: 58 | break; 59 | default: 60 | opt = NULL; 61 | break; 62 | } 63 | } 64 | 65 | if (!opt) 66 | { 67 | handler->PSendSysMessage("Syntax is: ahbotoptions $option $ahMapID (2, 6 or 7) $parameter"); 68 | handler->PSendSysMessage("Try ahbotoptions help to see a list of options."); 69 | return false; 70 | } 71 | 72 | int l = strlen(opt); 73 | 74 | if (strncmp(opt, "help", l) == 0) 75 | { 76 | handler->PSendSysMessage("AHBot commands:"); 77 | handler->PSendSysMessage("ahexpire"); 78 | handler->PSendSysMessage("minitems"); 79 | handler->PSendSysMessage("maxitems"); 80 | //handler->PSendSysMessage(""); 81 | //handler->PSendSysMessage(""); 82 | handler->PSendSysMessage("percentages"); 83 | handler->PSendSysMessage("minprice"); 84 | handler->PSendSysMessage("maxprice"); 85 | handler->PSendSysMessage("minbidprice"); 86 | handler->PSendSysMessage("maxbidprice"); 87 | handler->PSendSysMessage("maxstack"); 88 | handler->PSendSysMessage("buyerprice"); 89 | handler->PSendSysMessage("bidinterval"); 90 | handler->PSendSysMessage("bidsperinterval"); 91 | return true; 92 | } 93 | else if (strncmp(opt, "ahexpire", l) == 0) 94 | { 95 | if (!ahMapIdStr) 96 | { 97 | handler->PSendSysMessage("Syntax is: ahbotoptions ahexpire $ahMapID (2, 6 or 7)"); 98 | return false; 99 | } 100 | 101 | auctionbot->Commands(0, ahMapID, NULL, NULL); 102 | } 103 | else if (strncmp(opt, "minitems", l) == 0) 104 | { 105 | char* param1 = strtok(NULL, " "); 106 | if (!ahMapIdStr || !param1) 107 | { 108 | handler->PSendSysMessage("Syntax is: ahbotoptions minitems $ahMapID (2, 6 or 7) $minItems"); 109 | return false; 110 | } 111 | 112 | auctionbot->Commands(1, ahMapID, NULL, param1); 113 | } 114 | else if (strncmp(opt, "maxitems", l) == 0) 115 | { 116 | char* param1 = strtok(NULL, " "); 117 | if (!ahMapIdStr || !param1) 118 | { 119 | handler->PSendSysMessage("Syntax is: ahbotoptions maxitems $ahMapID (2, 6 or 7) $maxItems"); 120 | return false; 121 | } 122 | 123 | auctionbot->Commands(2, ahMapID, NULL, param1); 124 | } 125 | else if (strncmp(opt, "mintime", l) == 0) 126 | { 127 | handler->PSendSysMessage("ahbotoptions mintime has been deprecated"); 128 | return false; 129 | /* 130 | char* param1 = strtok(NULL, " "); 131 | if (!ahMapIdStr || !param1) 132 | { 133 | PSendSysMessage("Syntax is: ahbotoptions mintime $ahMapID (2, 6 or 7) $mintime"); 134 | return false; 135 | } 136 | 137 | auctionbot.Commands(3, ahMapID, NULL, param1); 138 | */ 139 | } 140 | else if (strncmp(opt, "maxtime", l) == 0) 141 | { 142 | handler->PSendSysMessage("ahbotoptions maxtime has been deprecated"); 143 | return false; 144 | /* 145 | char* param1 = strtok(NULL, " "); 146 | if (!ahMapIdStr || !param1) 147 | { 148 | PSendSysMessage("Syntax is: ahbotoptions maxtime $ahMapID (2, 6 or 7) $maxtime"); 149 | return false; 150 | } 151 | 152 | auctionbot.Commands(4, ahMapID, NULL, param1); 153 | */ 154 | } 155 | else if (strncmp(opt, "percentages", l) == 0) 156 | { 157 | char* param1 = strtok(NULL, " "); 158 | char* param2 = strtok(NULL, " "); 159 | char* param3 = strtok(NULL, " "); 160 | char* param4 = strtok(NULL, " "); 161 | char* param5 = strtok(NULL, " "); 162 | char* param6 = strtok(NULL, " "); 163 | char* param7 = strtok(NULL, " "); 164 | char* param8 = strtok(NULL, " "); 165 | char* param9 = strtok(NULL, " "); 166 | char* param10 = strtok(NULL, " "); 167 | char* param11 = strtok(NULL, " "); 168 | char* param12 = strtok(NULL, " "); 169 | char* param13 = strtok(NULL, " "); 170 | char* param14 = strtok(NULL, " "); 171 | 172 | if (!ahMapIdStr || !param14) 173 | { 174 | handler->PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14"); 175 | handler->PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods"); 176 | handler->PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems"); 177 | handler->PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems"); 178 | handler->PSendSysMessage("The total must add up to 100%%"); 179 | return false; 180 | } 181 | 182 | uint32 greytg = uint32(strtoul(param1, NULL, 0)); 183 | uint32 whitetg = uint32(strtoul(param2, NULL, 0)); 184 | uint32 greentg = uint32(strtoul(param3, NULL, 0)); 185 | uint32 bluetg = uint32(strtoul(param3, NULL, 0)); 186 | uint32 purpletg = uint32(strtoul(param5, NULL, 0)); 187 | uint32 orangetg = uint32(strtoul(param6, NULL, 0)); 188 | uint32 yellowtg = uint32(strtoul(param7, NULL, 0)); 189 | uint32 greyi = uint32(strtoul(param8, NULL, 0)); 190 | uint32 whitei = uint32(strtoul(param9, NULL, 0)); 191 | uint32 greeni = uint32(strtoul(param10, NULL, 0)); 192 | uint32 bluei = uint32(strtoul(param11, NULL, 0)); 193 | uint32 purplei = uint32(strtoul(param12, NULL, 0)); 194 | uint32 orangei = uint32(strtoul(param13, NULL, 0)); 195 | uint32 yellowi = uint32(strtoul(param14, NULL, 0)); 196 | uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi; 197 | 198 | if (totalPercent == 0 || totalPercent != 100) 199 | { 200 | handler->PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14"); 201 | handler->PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods"); 202 | handler->PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems"); 203 | handler->PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems"); 204 | handler->PSendSysMessage("The total must add up to 100%%"); 205 | return false; 206 | } 207 | 208 | char param[100]; 209 | param[0] = '\0'; 210 | strcat(param, param1); 211 | strcat(param, " "); 212 | strcat(param, param2); 213 | strcat(param, " "); 214 | strcat(param, param3); 215 | strcat(param, " "); 216 | strcat(param, param4); 217 | strcat(param, " "); 218 | strcat(param, param5); 219 | strcat(param, " "); 220 | strcat(param, param6); 221 | strcat(param, " "); 222 | strcat(param, param7); 223 | strcat(param, " "); 224 | strcat(param, param8); 225 | strcat(param, " "); 226 | strcat(param, param9); 227 | strcat(param, " "); 228 | strcat(param, param10); 229 | strcat(param, " "); 230 | strcat(param, param11); 231 | strcat(param, " "); 232 | strcat(param, param12); 233 | strcat(param, " "); 234 | strcat(param, param13); 235 | strcat(param, " "); 236 | strcat(param, param14); 237 | auctionbot->Commands(5, ahMapID, NULL, param); 238 | } 239 | else if (strncmp(opt, "minprice", l) == 0) 240 | { 241 | char* param1 = strtok(NULL, " "); 242 | char* param2 = strtok(NULL, " "); 243 | 244 | if (!ahMapIdStr || !param1 || !param2) 245 | { 246 | handler->PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); 247 | return false; 248 | } 249 | 250 | if (strncmp(param1, "grey", l) == 0) 251 | auctionbot->Commands(6, ahMapID, AHB_GREY, param2); 252 | else if (strncmp(param1, "white", l) == 0) 253 | auctionbot->Commands(6, ahMapID, AHB_WHITE, param2); 254 | else if (strncmp(param1, "green", l) == 0) 255 | auctionbot->Commands(6, ahMapID, AHB_GREEN, param2); 256 | else if (strncmp(param1, "blue", l) == 0) 257 | auctionbot->Commands(6, ahMapID, AHB_BLUE, param2); 258 | else if (strncmp(param1, "purple", l) == 0) 259 | auctionbot->Commands(6, ahMapID, AHB_PURPLE, param2); 260 | else if (strncmp(param1, "orange", l) == 0) 261 | auctionbot->Commands(6, ahMapID, AHB_ORANGE, param2); 262 | else if (strncmp(param1, "yellow", l) == 0) 263 | auctionbot->Commands(6, ahMapID, AHB_YELLOW, param2); 264 | else 265 | { 266 | handler->PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); 267 | return false; 268 | } 269 | } 270 | else if (strncmp(opt, "maxprice", l) == 0) 271 | { 272 | char* param1 = strtok(NULL, " "); 273 | char* param2 = strtok(NULL, " "); 274 | if (!ahMapIdStr || !param1 || !param2) 275 | { 276 | handler->PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); 277 | return false; 278 | } 279 | if (strncmp(param1, "grey", l) == 0) 280 | auctionbot->Commands(7, ahMapID, AHB_GREY, param2); 281 | else if (strncmp(param1, "white", l) == 0) 282 | auctionbot->Commands(7, ahMapID, AHB_WHITE, param2); 283 | else if (strncmp(param1, "green", l) == 0) 284 | auctionbot->Commands(7, ahMapID, AHB_GREEN, param2); 285 | else if (strncmp(param1, "blue", l) == 0) 286 | auctionbot->Commands(7, ahMapID, AHB_BLUE, param2); 287 | else if (strncmp(param1, "purple", l) == 0) 288 | auctionbot->Commands(7, ahMapID, AHB_PURPLE, param2); 289 | else if (strncmp(param1, "orange",l) == 0) 290 | auctionbot->Commands(7, ahMapID, AHB_ORANGE, param2); 291 | else if (strncmp(param1, "yellow", l) == 0) 292 | auctionbot->Commands(7, ahMapID, AHB_YELLOW, param2); 293 | else 294 | { 295 | handler->PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); 296 | return false; 297 | } 298 | } 299 | else if (strncmp(opt, "minbidprice", l) == 0) 300 | { 301 | char* param1 = strtok(NULL, " "); 302 | char* param2 = strtok(NULL, " "); 303 | 304 | if (!ahMapIdStr || !param2 || !param2) 305 | { 306 | handler->PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); 307 | return false; 308 | } 309 | 310 | uint32 minBidPrice = uint32(strtoul(param2, NULL, 0)); 311 | if (minBidPrice < 1 || minBidPrice > 100) 312 | { 313 | handler->PSendSysMessage("The min bid price multiplier must be between 1 and 100"); 314 | return false; 315 | } 316 | 317 | if (strncmp(param1, "grey", l) == 0) 318 | auctionbot->Commands(8, ahMapID, AHB_GREY, param2); 319 | else if (strncmp(param1, "white", l) == 0) 320 | auctionbot->Commands(8, ahMapID, AHB_WHITE, param2); 321 | else if (strncmp(param1, "green", l) == 0) 322 | auctionbot->Commands(8, ahMapID, AHB_GREEN, param2); 323 | else if (strncmp(param1, "blue", l) == 0) 324 | auctionbot->Commands(8, ahMapID, AHB_BLUE, param2); 325 | else if (strncmp(param1, "purple", l) == 0) 326 | auctionbot->Commands(8, ahMapID, AHB_PURPLE, param2); 327 | else if (strncmp(param1, "orange", l) == 0) 328 | auctionbot->Commands(8, ahMapID, AHB_ORANGE, param2); 329 | else if (strncmp(param1, "yellow", l) == 0) 330 | auctionbot->Commands(8, ahMapID, AHB_YELLOW, param2); 331 | else 332 | { 333 | handler->PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); 334 | return false; 335 | } 336 | } 337 | else if (strncmp(opt, "maxbidprice", l) == 0) 338 | { 339 | char* param1 = strtok(NULL, " "); 340 | char* param2 = strtok(NULL, " "); 341 | 342 | if (!ahMapIdStr || !param1 || !param2) 343 | { 344 | handler->PSendSysMessage("Syntax is: ahbotoptions maxbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); 345 | return false; 346 | } 347 | 348 | uint32 maxBidPrice = uint32(strtoul(param2, NULL, 0)); 349 | if (maxBidPrice < 1 || maxBidPrice > 100) 350 | { 351 | handler->PSendSysMessage("The max bid price multiplier must be between 1 and 100"); 352 | return false; 353 | } 354 | 355 | if (strncmp(param1, "grey", l) == 0) 356 | auctionbot->Commands(9, ahMapID, AHB_GREY, param2); 357 | else if (strncmp(param1, "white", l) == 0) 358 | auctionbot->Commands(9, ahMapID, AHB_WHITE, param2); 359 | else if (strncmp(param1, "green", l) == 0) 360 | auctionbot->Commands(9, ahMapID, AHB_GREEN, param2); 361 | else if (strncmp(param1, "blue", l) == 0) 362 | auctionbot->Commands(9, ahMapID, AHB_BLUE, param2); 363 | else if (strncmp(param1, "purple", l) == 0) 364 | auctionbot->Commands(9, ahMapID, AHB_PURPLE, param2); 365 | else if (strncmp(param1, " orange", l) == 0) 366 | auctionbot->Commands(9, ahMapID, AHB_ORANGE, param2); 367 | else if (strncmp(param1, "yellow", l) == 0) 368 | auctionbot->Commands(9, ahMapID, AHB_YELLOW, param2); 369 | else 370 | { 371 | handler->PSendSysMessage("Syntax is: ahbotoptions max bidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); 372 | return false; 373 | } 374 | } 375 | else if (strncmp(opt, "maxstack",l) == 0) 376 | { 377 | char* param1 = strtok(NULL, " "); 378 | char* param2 = strtok(NULL, " "); 379 | 380 | if (!ahMapIdStr || !param1 || !param2) 381 | { 382 | handler->PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value"); 383 | return false; 384 | } 385 | 386 | // uint32 maxStack = uint32(strtoul(param2, NULL, 0)); 387 | // if (maxStack < 0) 388 | // { 389 | // handler->PSendSysMessage("maxstack can't be a negative number."); 390 | // return false; 391 | // } 392 | 393 | if (strncmp(param1, "grey",l) == 0) 394 | auctionbot->Commands(10, ahMapID, AHB_GREY, param2); 395 | else if (strncmp(param1, "white", l) == 0) 396 | auctionbot->Commands(10, ahMapID, AHB_WHITE, param2); 397 | else if (strncmp(param1, "green", l) == 0) 398 | auctionbot->Commands(10, ahMapID, AHB_GREEN, param2); 399 | else if (strncmp(param1, "blue", l) == 0) 400 | auctionbot->Commands(10, ahMapID, AHB_BLUE, param2); 401 | else if (strncmp(param1, "purple", l) == 0) 402 | auctionbot->Commands(10, ahMapID, AHB_PURPLE, param2); 403 | else if (strncmp(param1, "orange", l) == 0) 404 | auctionbot->Commands(10, ahMapID, AHB_ORANGE, param2); 405 | else if (strncmp(param1, "yellow", l) == 0) 406 | auctionbot->Commands(10, ahMapID, AHB_YELLOW, param2); 407 | else 408 | { 409 | handler->PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value"); 410 | return false; 411 | } 412 | } 413 | else if (strncmp(opt, "buyerprice", l) == 0) 414 | { 415 | char* param1 = strtok(NULL, " "); 416 | char* param2 = strtok(NULL, " "); 417 | 418 | if (!ahMapIdStr || !param1 || !param2) 419 | { 420 | handler->PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price"); 421 | return false; 422 | } 423 | 424 | if (strncmp(param1, "grey", l) == 0) 425 | auctionbot->Commands(11, ahMapID, AHB_GREY, param2); 426 | else if (strncmp(param1, "white", l) == 0) 427 | auctionbot->Commands(11, ahMapID, AHB_WHITE, param2); 428 | else if (strncmp(param1, "green", l) == 0) 429 | auctionbot->Commands(11, ahMapID, AHB_GREEN, param2); 430 | else if (strncmp(param1, "blue", l) == 0) 431 | auctionbot->Commands(11, ahMapID, AHB_BLUE, param2); 432 | else if (strncmp(param1, "purple", l) == 0) 433 | auctionbot->Commands(11, ahMapID, AHB_PURPLE, param2); 434 | else if (strncmp(param1, "orange", l) == 0) 435 | auctionbot->Commands(11, ahMapID, AHB_ORANGE, param2); 436 | else if (strncmp(param1, "yellow", l) == 0) 437 | auctionbot->Commands(11, ahMapID, AHB_YELLOW, param2); 438 | else 439 | { 440 | handler->PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price"); 441 | return false; 442 | } 443 | } 444 | else if (strncmp(opt, "bidinterval", l) == 0) 445 | { 446 | char* param1 = strtok(NULL, " "); 447 | 448 | if (!ahMapIdStr || !param1) 449 | { 450 | handler->PSendSysMessage("Syntax is: ahbotoptions bidinterval $ahMapID (2, 6 or 7) $interval(in minutes)"); 451 | return false; 452 | } 453 | 454 | auctionbot->Commands(12, ahMapID, NULL, param1); 455 | } 456 | else if (strncmp(opt, "bidsperinterval", l) == 0) 457 | { 458 | char* param1 = strtok(NULL, " "); 459 | 460 | if (!ahMapIdStr || !param1) 461 | { 462 | handler->PSendSysMessage("Syntax is: ahbotoptions bidsperinterval $ahMapID (2, 6 or 7) $bids"); 463 | return false; 464 | } 465 | 466 | auctionbot->Commands(13, ahMapID, NULL, param1); 467 | } 468 | else 469 | { 470 | handler->PSendSysMessage("Syntax is: ahbotoptions $option $ahMapID (2, 6 or 7) $parameter"); 471 | handler->PSendSysMessage("Try ahbotoptions help to see a list of options."); 472 | return false; 473 | } 474 | 475 | return true; 476 | } 477 | }; 478 | 479 | void AddSC_ah_bot_commandscript() 480 | { 481 | new ah_bot_commandscript(); 482 | } 483 | -------------------------------------------------------------------------------- /src/loader_cs_ah_bot.h: -------------------------------------------------------------------------------- 1 | void AddSC_ah_bot_commandscript(); 2 | 3 | void AddAHBotCommandScripts() 4 | { 5 | AddSC_ah_bot_commandscript(); 6 | } 7 | --------------------------------------------------------------------------------