Skip to content
Browse files

New version of aucbot/aucbyer (from Xeross, big rewrited by me) added.

  • Loading branch information...
1 parent d0c04db commit 7c97114488b36b4427ed91962cd46e277ff8866e @rsa rsa committed Jul 24, 2010
View
179 README.AHBOT
@@ -0,0 +1,179 @@
+This patch modifies the core so it populates the auction houses with items. It
+makes the game feel a bit more like official. Items and prices are chosen
+randomly based on the parameters you define. If an auction expires, auctions
+are deleted quietly. AHBot will not buy it's own items, and will not receive
+mail from the AH or get returned mail.
+
+===============================================================================
+~~HOW TO CONFIGURE~~
+===============================================================================
+Step 1.) Create a character that you are going to use as the auction house bot
+ character. This character will be the auction's owner for all the
+ items created by the bot.
+Step 2.) Go into the realm database and note the account number for the
+ character.
+Step 3.) Go into the characters database and note the character's GUID.
+Step 4.) Log in at least once with this character.
+ (Do not change the configuration before this)
+Step 5.) Tune the configuration options in the configuration file and the
+ Database.
+
+#These are the settings in the configuration file:
+AuctionHouseBot.EnableSeller = 0
+AuctionHouseBot.EnableBuyer = 0
+AuctionHouseBot.Account = 0
+AuctionHouseBot.GUID = 0
+AuctionHouseBot.VendorItems = 0
+AuctionHouseBot.LootItems = 1
+AuctionHouseBot.OtherItems = 0
+AuctionHouseBot.No_Bind = 1
+AuctionHouseBot.Bind_When_Picked_Up = 0
+AuctionHouseBot.Bind_When_Equipped = 1
+AuctionHouseBot.Bind_When_Use = 1
+AuctionHouseBot.Bind_Quest_Item = 0
+AuctionHouseBot.ItemsPerCycle = 200
+AuctionHouseBot.UseBuyPriceForSeller = 0
+AuctionHouseBot.UseBuyPriceForBuyer = 0
+
+AuctionHouseBot.EnableSeller enables (1) or disables (0) the Seller
+AuctionHouseBot.EnableBuyer enables (1) or disables (0) the Buyer
+AuctionHouseBot.Account is the account number (in realmd->account table) of the player you want to run as the auction bot. Note: must be setted anywhere!
+AuctionHouseBot.GUID is the GUID (in characters->characters table) of the player you want to run as the auction bot. Note: must be setted anywhere!
+AuctionHouseBot.VendorItems is a boolean value (0 or 1) that indicates whether to include Vendor only items
+AuctionHouseBot.LootItems is a boolean value (0 or 1) that indicates whether to include Loot/Fish/Skin/etc. only items
+AuctionHouseBot.OtherItems is a boolean value (0 or 1) that indicates whether to include Other items not covered by the first 2
+AuctionHouseBot.No_Bind is a boolean value (0 or 1) that indicates whether to include items with a bonding of 0
+AuctionHouseBot.Bind_When_Picked_Up = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 1
+AuctionHouseBot.Bind_When_Equipped = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 2
+AuctionHouseBot.Bind_When_Use = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 3
+AuctionHouseBot.Bind_Quest_Item = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 4
+AuctionHouseBot.ItemsPerCycle determines how many items are added each time AHBot is run (once per minute, by default)
+AuctionHouseBot.UseBuyPriceForSeller Use SellPrice (0) or BuyPrice (1) for determining prices
+AuctionHouseBot.UseBuyPriceForBuyer Use SellPrice (0) or BuyPrice (1) for determining prices
+
+#These are the settings in the Database:
+#Each Auctionhouse has it's own set of these
+
+MinItems = 0
+#The Minimum number of items you want to keep in the auction houses.
+#(default 0 - minimum will be the same as maximum).
+#If it is higher than the value of the corresponding maxItems setting,
+#it will be set down to match the maxItems setting.
+
+MaxItems = 0
+#The Maximum number of items you want to keep in the auction houses.
+
+MinTime = 8
+#The minimum number of hours for an auction.
+
+MaxTime = 24
+#The maximum number of hours for an auction.
+
+#These must add up to 100 each one is the percentage
+#of the auction items that should be trade goods of
+#that quality. A value of 0 will disable.
+
+PercentGreyTradeGoods = 0
+PercentWhiteTradeGoods = 27
+PercentGreenTradeGoods = 12
+PercentBlueTradeGoods = 10
+PercentPurpleTradeGoods = 1
+PercentOrangeTradeGoods = 0
+PercentYellowTradeGoods = 0
+
+PercentGreyItems = 0
+PercentWhiteItems = 10
+PercentGreenItems = 30
+PercentBlueItems = 8
+PercentPurpleItems = 2
+PercentOrangeItems = 0
+PercentYellowItems = 0
+
+#MinPrice(Color) is the minimum price adjustment for items. For example the default is 150, which means 150%. So if an item vendors for 1g it would go to auction for a minimum of 1.5g.
+#MaxPrice(Color) is the maximum price adjustment for items.
+#MinBidPrice(Color) these two control the starting bid as a percent of the buyout price. For example, if MinBidPrice is 30 and MaxBidPrice is 80 the starting bid for the auction will randomly be between 30-80% of the randomly chosen buyout price.
+#MaxBidPrice(Color) these two control the starting bid as a percent of the buyout price. For example, if MinBidPrice is 30 and MaxBidPrice is 80 the starting bid for the auction will randomly be between 30-80% of the randomly chosen buyout price.
+#MaxStack(Color) is maximum stack size to create for this quality type. A value of zero will disable the maximum stack size for this quality allowing the bot to create stacks (of random size) of items as big as the item type allows.
+
+MinPriceGrey = 100
+MaxPriceGrey = 150
+MinBidPriceGrey = 70
+MaxBidPriceGrey = 100
+MaxStackGrey = 0
+MinPriceWhite = 150
+MaxPriceWhite = 250
+MinBidPriceWhite = 70
+MaxBidPriceWhite = 100
+MaxStackWhite = 0
+MinPriceGreen = 800
+MaxPriceGreen = 1400
+MinBidPriceGreen = 80
+MaxBidPriceGreen = 100
+MaxStackGreen = 3
+MinPriceBlue = 1250
+MaxPriceBlue = 1750
+MinBidPriceBlue = 75
+MaxBidPriceBlue = 100
+MaxStackBlue = 2
+MinPricePurple = 2250
+MaxPricePurple = 4550
+MinBidPricePurple = 80
+MaxBidPricePurple = 100
+MaxStackPurple = 1
+MinPriceOrange = 4250
+MaxPriceOrange = 5550
+MinBidPriceOrange = 80
+MaxBidPriceOrange = 100
+MaxStackOrange = 0
+MinPriceYellow = 5250
+MaxPriceYellow = 6550
+MinBidPriceYellow = 80
+MaxBidPriceYellow = 100
+MaxStackYellow = 0
+
+#These are the multipliers that are applied to the vendor price for an item, that determines if AHBot will buy it or not.
+#1 means AHBot will pay the same as (or less than) a vendor would pay, 2 means up to twice as much, etc.
+
+BuyerPriceGrey = 1
+BuyerPriceWhite = 1
+BuyerPriceGreen = 5
+BuyerPriceBlue = 12
+BuyerPricePurple = 15
+BuyerPriceOrange = 20
+BuyerPriceYellow = 22
+
+#BuyerBiddingInterval is the time (in minutes) between bids.
+#BuyerBidsPerInterval is the number of bids the buyer will make in a cycle
+
+BuyerBiddingInterval = 1
+BuyerBidsPerInterval = 1
+
+
+
+How to use ahcommands from the console (CLI) or in game with GM level 3 players:
+ahbotoptions - will display usage instructions
+ahbotoptions help - will display the list of commands
+
+ahexpire - will expire all the auctions in the requested auction house that were created by AHBot.
+minitems - will set the minimum number of items in the AH before it starts being filled again.
+maxitems - will set the maximum number of items in the AH.
+mintime - will set the minimum time (in hours) for auctions to expire.
+maxtime - will set the maximum time (in hours) for auctions to expire.
+percentages - will set the percentage of each quality in the AH
+minprice - will set the minimum price multiplier for auctions.
+maxprice - will set the maximum price multiplier for auctions.
+minbidprice - will set the minimum starting bid as a percent of the buyout price for auctions.
+maxbidprice - will set the maximum starting bid as a percent of the buyout price for auctions.
+maxstack - will set the maximum number of items in stacks for auctions. 0 will set the maximum to the maximum for that item type.
+buyerprice - will set the bid price multiplier for auctions.
+biddinginterval - will set the number of minutes between bids on auctions.
+bidsperinterval - will set the number of bids to enter per cycle.
+
+The auction house IDs are:
+2 - Alliance
+6 - Horde
+7 - Neutral
+
+AHBot Originally made by Chris K.
+Much thanks to Chris K, grether and Dolomit6!
+AHBot Now includes AHBuyer created by Kerbe as a derivative of AHBot, and later modified by Paradox
View
95 addition/724_characters_auctionhousebot.sql
@@ -0,0 +1,95 @@
+/*
+SQLyog Community Edition- MySQL GUI v6.03
+Host - 5.0.51b-community-nt : Database - characters2
+*********************************************************************
+Server version : 5.0.51b-community-nt
+*/
+
+/*!40101 SET NAMES utf8 */;
+
+/*!40101 SET SQL_MODE=''*/;
+
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+
+/*Table structure for table `auctionhousebot` */
+
+DROP TABLE IF EXISTS `auctionhousebot`;
+CREATE TABLE `auctionhousebot` (
+ `auctionhouse` int(11) NOT NULL default '0' COMMENT 'mapID of the auctionhouse.',
+ `name` char(25) default NULL COMMENT 'Text name of the auctionhouse.',
+ `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.',
+ `maxitems` int(11) default '0' COMMENT 'This is the number of items you want to keep in the auction house.',
+ `mintime` int(11) default '8' COMMENT 'Sets the minimum number of hours for an auction.',
+ `maxtime` int(11) default '24' COMMENT 'Sets the maximum number of hours for an auction.',
+ `percentgreytradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Grey Trade Goods auction items',
+ `percentwhitetradegoods` int(11) default '27' COMMENT 'Sets the percentage of the White Trade Goods auction items',
+ `percentgreentradegoods` int(11) default '12' COMMENT 'Sets the percentage of the Green Trade Goods auction items',
+ `percentbluetradegoods` int(11) default '10' COMMENT 'Sets the percentage of the Blue Trade Goods auction items',
+ `percentpurpletradegoods` int(11) default '1' COMMENT 'Sets the percentage of the Purple Trade Goods auction items',
+ `percentorangetradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Orange Trade Goods auction items',
+ `percentyellowtradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Yellow Trade Goods auction items',
+ `percentgreyitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Grey auction items',
+ `percentwhiteitems` int(11) default '10' COMMENT 'Sets the percentage of the non trade White auction items',
+ `percentgreenitems` int(11) default '30' COMMENT 'Sets the percentage of the non trade Green auction items',
+ `percentblueitems` int(11) default '8' COMMENT 'Sets the percentage of the non trade Blue auction items',
+ `percentpurpleitems` int(11) default '2' COMMENT 'Sets the percentage of the non trade Purple auction items',
+ `percentorangeitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Orange auction items',
+ `percentyellowitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Yellow auction items',
+ `minpricegrey` int(11) default '100' COMMENT 'Minimum price of Grey items (percentage).',
+ `maxpricegrey` int(11) default '150' COMMENT 'Maximum price of Grey items (percentage).',
+ `minpricewhite` int(11) default '150' COMMENT 'Minimum price of White items (percentage).',
+ `maxpricewhite` int(11) default '250' COMMENT 'Maximum price of White items (percentage).',
+ `minpricegreen` int(11) default '800' COMMENT 'Minimum price of Green items (percentage).',
+ `maxpricegreen` int(11) default '1400' COMMENT 'Maximum price of Green items (percentage).',
+ `minpriceblue` int(11) default '1250' COMMENT 'Minimum price of Blue items (percentage).',
+ `maxpriceblue` int(11) default '1750' COMMENT 'Maximum price of Blue items (percentage).',
+ `minpricepurple` int(11) default '2250' COMMENT 'Minimum price of Purple items (percentage).',
+ `maxpricepurple` int(11) default '4550' COMMENT 'Maximum price of Purple items (percentage).',
+ `minpriceorange` int(11) default '3250' COMMENT 'Minimum price of Orange items (percentage).',
+ `maxpriceorange` int(11) default '5550' COMMENT 'Maximum price of Orange items (percentage).',
+ `minpriceyellow` int(11) default '5250' COMMENT 'Minimum price of Yellow items (percentage).',
+ `maxpriceyellow` int(11) default '6550' COMMENT 'Maximum price of Yellow items (percentage).',
+ `minbidpricegrey` int(11) default '70' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 70',
+ `maxbidpricegrey` int(11) default '100' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 100',
+ `minbidpricewhite` int(11) default '70' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 70',
+ `maxbidpricewhite` int(11) default '100' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100',
+ `minbidpricegreen` int(11) default '80' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 80',
+ `maxbidpricegreen` int(11) default '100' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100',
+ `minbidpriceblue` int(11) default '75' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 75',
+ `maxbidpriceblue` int(11) default '100' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100',
+ `minbidpricepurple` int(11) default '80' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 80',
+ `maxbidpricepurple` int(11) default '100' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100',
+ `minbidpriceorange` int(11) default '80' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 80',
+ `maxbidpriceorange` int(11) default '100' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 100',
+ `minbidpriceyellow` int(11) default '80' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 80',
+ `maxbidpriceyellow` int(11) default '100' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 100',
+ `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.',
+ `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.',
+ `maxstackgreen` int(11) default '3' 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.',
+ `maxstackblue` int(11) default '2' 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.',
+ `maxstackpurple` int(11) default '1' 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.',
+ `maxstackorange` int(11) default '1' 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.',
+ `maxstackyellow` int(11) default '1' 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.',
+ `buyerpricegrey` int(11) default '1' COMMENT 'Multiplier to vendorprice when buying grey items from auctionhouse',
+ `buyerpricewhite` int(11) default '1' COMMENT 'Multiplier to vendorprice when buying white items from auctionhouse',
+ `buyerpricegreen` int(11) default '5' COMMENT 'Multiplier to vendorprice when buying green items from auctionhouse',
+ `buyerpriceblue` int(11) default '12' COMMENT 'Multiplier to vendorprice when buying blue items from auctionhouse',
+ `buyerpricepurple` int(11) default '15' COMMENT 'Multiplier to vendorprice when buying purple items from auctionhouse',
+ `buyerpriceorange` int(11) default '20' COMMENT 'Multiplier to vendorprice when buying orange items from auctionhouse',
+ `buyerpriceyellow` int(11) default '22' COMMENT 'Multiplier to vendorprice when buying yellow items from auctionhouse',
+ `buyerbiddinginterval` int(11) default '1' COMMENT 'Interval how frequently AHB bids on each AH. Time in minutes',
+ `buyerbidsperinterval` int(11) default '1' COMMENT 'number of bids to put in per bidding interval',
+ PRIMARY KEY (`auctionhouse`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+/*Data for the table `auctionhousebot` */
+
+insert into `auctionhousebot`(`auctionhouse`,`name`,`minitems`,`maxitems`,`mintime`,`maxtime`,`percentgreytradegoods`,`percentwhitetradegoods`,`percentgreentradegoods`,`percentbluetradegoods`,`percentpurpletradegoods`,`percentorangetradegoods`,`percentyellowtradegoods`,`percentgreyitems`,`percentwhiteitems`,`percentgreenitems`,`percentblueitems`,`percentpurpleitems`,`percentorangeitems`,`percentyellowitems`,`minpricegrey`,`maxpricegrey`,`minpricewhite`,`maxpricewhite`,`minpricegreen`,`maxpricegreen`,`minpriceblue`,`maxpriceblue`,`minpricepurple`,`maxpricepurple`,`minpriceorange`,`maxpriceorange`,`minpriceyellow`,`maxpriceyellow`,`minbidpricegrey`,`maxbidpricegrey`,`minbidpricewhite`,`maxbidpricewhite`,`minbidpricegreen`,`maxbidpricegreen`,`minbidpriceblue`,`maxbidpriceblue`,`minbidpricepurple`,`maxbidpricepurple`,`minbidpriceorange`,`maxbidpriceorange`,`minbidpriceyellow`,`maxbidpriceyellow`,`maxstackgrey`,`maxstackwhite`,`maxstackgreen`,`maxstackblue`,`maxstackpurple`,`maxstackorange`,`maxstackyellow`,`buyerpricegrey`,`buyerpricewhite`,`buyerpricegreen`,`buyerpriceblue`,`buyerpricepurple`,`buyerpriceorange`,`buyerpriceyellow`,`buyerbiddinginterval`,`buyerbidsperinterval`) values
+(2,'Alliance',0,0,8,24,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,1,5,12,15,20,22,1,1),
+(6,'Horde',0,0,8,24,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,1,5,12,15,20,22,1,1),
+(7,'Neutral',0,0,8,24,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,1,5,12,15,20,22,1,1);
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+
View
44 addition/724_characters_auctionhousebot_update.sql
@@ -0,0 +1,44 @@
+/*
+SQLyog Community Edition- MySQL GUI v6.03
+Host - 5.0.51b-community-nt : Database - characters
+*********************************************************************
+Server version : 5.0.51b-community-nt
+*/
+
+/*!40101 SET NAMES utf8 */;
+
+/*!40101 SET SQL_MODE=''*/;
+
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+
+/*Table structure for table `auctionhousebot` */
+
+ALTER TABLE `auctionhousebot`
+ ADD COLUMN `percentgreytradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Grey Trade Goods auction items' AFTER `maxtime`,
+ ADD COLUMN `percentorangetradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Orange Trade Goods auction items' AFTER `percentpurpletradegoods`,
+ ADD COLUMN `percentyellowtradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Yellow Trade Goods auction items' AFTER `percentorangetradegoods`,
+ ADD COLUMN `percentgreyitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Grey auction items' AFTER `percentyellowtradegoods`,
+ ADD COLUMN `percentorangeitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Orange auction items' AFTER `percentpurpleitems`,
+ ADD COLUMN `percentyellowitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Yellow auction items' AFTER `percentorangeitems`,
+ ADD COLUMN `minpricegrey` int(11) default '100' COMMENT 'Minimum price of Grey items (percentage).' AFTER `percentyellowitems`,
+ ADD COLUMN `maxpricegrey` int(11) default '150' COMMENT 'Maximum price of Grey items (percentage).' AFTER `minpricegrey`,
+ ADD COLUMN `minpriceorange` int(11) default '3250' COMMENT 'Minimum price of Orange items (percentage).' AFTER `maxpricepurple`,
+ ADD COLUMN `maxpriceorange` int(11) default '5550' COMMENT 'Maximum price of Orange items (percentage).' AFTER `minpriceorange`,
+ ADD COLUMN `minpriceyellow` int(11) default '5250' COMMENT 'Minimum price of Yellow items (percentage).' AFTER `maxpriceorange`,
+ ADD COLUMN `maxpriceyellow` int(11) default '6550' COMMENT 'Maximum price of Yellow items (percentage).' AFTER `minpriceyellow`,
+ ADD COLUMN `minbidpricegrey` int(11) default '70' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 70' AFTER `maxpriceyellow`,
+ ADD COLUMN `maxbidpricegrey` int(11) default '100' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 100' AFTER `minbidpricegrey`,
+ ADD COLUMN `minbidpriceorange` int(11) default '80' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 80' AFTER `maxbidpricepurple`,
+ ADD COLUMN `maxbidpriceorange` int(11) default '100' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 100' AFTER `minbidpriceorange`,
+ ADD COLUMN `minbidpriceyellow` int(11) default '80' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 80' AFTER `maxbidpriceorange`,
+ ADD COLUMN `maxbidpriceyellow` int(11) default '100' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 100' AFTER `minbidpriceyellow`,
+ ADD COLUMN `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.' AFTER `maxbidpriceyellow`,
+ ADD COLUMN `maxstackorange` int(11) default '1' 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.' AFTER `maxstackpurple`,
+ ADD COLUMN `maxstackyellow` int(11) default '1' 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.' AFTER `maxstackorange`,
+ ADD COLUMN `buyerpriceorange` int(11) default '20' COMMENT 'Multiplier to vendorprice when buying orange items from auctionhouse' AFTER `buyerpricepurple`,
+ ADD COLUMN `buyerpriceyellow` int(11) default '22' COMMENT 'Multiplier to vendorprice when buying yellow items from auctionhouse' AFTER `buyerpriceorange`;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+
View
1,534 src/game/AuctionHouseBot.cpp
@@ -0,0 +1,1534 @@
+#include "AuctionHouseBot.h"
+#include "ObjectMgr.h"
+#include "AuctionHouseMgr.h"
+
+#include "Policies/SingletonImp.h"
+
+INSTANTIATE_SINGLETON_1( AuctionHouseBot );
+
+using namespace std;
+
+AuctionHouseBot::AuctionHouseBot()
+{
+ AHBSeller = 0;
+ AHBBuyer = 0;
+
+ Vendor_Items = 0;
+ Loot_Items = 0;
+ Other_Items = 0;
+
+ No_Bind = 0;
+ Bind_When_Picked_Up = 0;
+ Bind_When_Equipped = 0;
+ Bind_When_Use = 0;
+ Bind_Quest_Item = 0;
+
+ AllianceConfig = AHBConfig(2);
+ HordeConfig = AHBConfig(6);
+ NeutralConfig = AHBConfig(7);
+}
+
+AuctionHouseBot::~AuctionHouseBot()
+{
+
+}
+
+void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
+{
+ if (!AHBSeller)
+ return;
+ AuctionHouseEntry const* ahEntry = sAuctionHouseStore.LookupEntry(config->GetAHID());
+ AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(ahEntry);
+ uint32 items = 0;
+ uint32 minItems = config->GetMinItems();
+ uint32 maxItems = config->GetMaxItems();
+ uint32 auctions = auctionHouse->Getcount();
+ uint32 AuctioneerGUID = 0;
+ switch (config->GetAHID()){
+ case 2:
+ AuctioneerGUID = 79707; //Human in stormwind.
+ break;
+ case 6:
+ AuctioneerGUID = 4656; //orc in Orgrimmar
+ break;
+ case 7:
+ AuctioneerGUID = 23442; //goblin in GZ
+ break;
+ default:
+ sLog.outError("GetAHID() - Default switch reached");
+ AuctioneerGUID = 23442; //default to neutral 7
+ break;
+ }
+
+ if (auctions >= minItems)
+ return;
+
+ if (auctions <= maxItems)
+ {
+ if ((maxItems - auctions) > ItemsPerCycle)
+ items = ItemsPerCycle;
+ else
+ items = (maxItems - auctions);
+ }
+ uint32 greyTGcount = config->GetPercents(AHB_GREY_TG);
+ uint32 whiteTGcount = config->GetPercents(AHB_WHITE_TG);
+ uint32 greenTGcount = config->GetPercents(AHB_GREEN_TG);
+ uint32 blueTGcount = config->GetPercents(AHB_BLUE_TG);
+ uint32 purpleTGcount = config->GetPercents(AHB_PURPLE_TG);
+ uint32 orangeTGcount = config->GetPercents(AHB_ORANGE_TG);
+ uint32 yellowTGcount = config->GetPercents(AHB_YELLOW_TG);
+ uint32 greyIcount = config->GetPercents(AHB_GREY_I);
+ uint32 whiteIcount = config->GetPercents(AHB_WHITE_I);
+ uint32 greenIcount = config->GetPercents(AHB_GREEN_I);
+ uint32 blueIcount = config->GetPercents(AHB_BLUE_I);
+ uint32 purpleIcount = config->GetPercents(AHB_PURPLE_I);
+ uint32 orangeIcount = config->GetPercents(AHB_ORANGE_I);
+ uint32 yellowIcount = config->GetPercents(AHB_YELLOW_I);
+ uint32 total = greyTGcount + whiteTGcount + greenTGcount + blueTGcount
+ + purpleTGcount + orangeTGcount + yellowTGcount
+ + whiteIcount + greenIcount + blueIcount + purpleIcount
+ + orangeIcount + yellowIcount;
+
+ uint32 greyTGoods = 0;
+ uint32 whiteTGoods = 0;
+ uint32 greenTGoods = 0;
+ uint32 blueTGoods = 0;
+ uint32 purpleTGoods = 0;
+ uint32 orangeTGoods = 0;
+ uint32 yellowTGoods = 0;
+
+ uint32 greyItems = 0;
+ uint32 whiteItems = 0;
+ uint32 greenItems = 0;
+ uint32 blueItems = 0;
+ uint32 purpleItems = 0;
+ uint32 orangeItems = 0;
+ uint32 yellowItems = 0;
+ uint32 buyBondingK = 1;
+
+ for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr)
+ {
+ AuctionEntry *Aentry = itr->second;
+ Item *item = sAuctionMgr.GetAItem(Aentry->item_guidlow);
+ if (item)
+ {
+ ItemPrototype const *prototype = item->GetProto();
+ if (prototype)
+ {
+ switch (prototype->Quality)
+ {
+ case 0:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ ++greyTGoods;
+ else
+ ++greyItems;
+ break;
+ case 1:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ ++whiteTGoods;
+ else
+ ++whiteItems;
+ break;
+ case 2:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ ++greenTGoods;
+ else
+ ++greenItems;
+ break;
+ case 3:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ ++blueTGoods;
+ else
+ ++blueItems;
+ break;
+ case 4:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ ++purpleTGoods;
+ else
+ ++purpleItems;
+ break;
+ case 5:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ ++orangeTGoods;
+ else
+ ++orangeItems;
+ break;
+ case 6:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ ++yellowTGoods;
+ else
+ ++yellowItems;
+ break;
+ }
+ }
+ }
+ }
+
+ // only insert a few at a time, so as not to peg the processor
+ for (uint32 cnt = 1;cnt <= items;cnt++)
+ {
+ uint32 itemID = 0;
+ uint32 loopBreaker = 0; // This will prevent endless looping condition where AHBot
+ while (itemID == 0 && loopBreaker < 50) // cannot allocate an item.
+ {
+ uint32 choice = urand(0, 13);
+ switch (choice)
+ {
+ case 0:
+ if ((greyItemsBin.size() > 0) && (greyItems < greyIcount))
+ {
+ itemID = greyItemsBin[urand(0, greyItemsBin.size() - 1)];
+ ++greyItems;
+ }
+ break;
+ case 1:
+ if ((whiteItemsBin.size() > 0) && (whiteItems < whiteIcount))
+ {
+ itemID = whiteItemsBin[urand(0, whiteItemsBin.size() - 1)];
+ ++whiteItems;
+ }
+ break;
+ case 2:
+ if ((greenItemsBin.size() > 0) && (greenItems < greenIcount))
+ {
+ itemID = greenItemsBin[urand(0, greenItemsBin.size() - 1)];
+ ++greenItems;
+ }
+ break;
+ case 3:
+ if ((blueItemsBin.size() > 0) && (blueItems < blueIcount))
+ {
+ itemID = blueItemsBin[urand(0, blueItemsBin.size() - 1)];
+ ++blueItems;
+ }
+ break;
+ case 4:
+ if ((purpleItemsBin.size() > 0) && (purpleItems < purpleIcount))
+ {
+ itemID = purpleItemsBin[urand(0, purpleItemsBin.size() - 1)];
+ ++purpleItems;
+ }
+ break;
+ case 5:
+ if ((orangeItemsBin.size() > 0) && (orangeItems < orangeIcount))
+ {
+ itemID = orangeItemsBin[urand(0, orangeItemsBin.size() - 1)];
+ ++orangeItems;
+ }
+ break;
+ case 6:
+ if ((yellowItemsBin.size() > 0) && (yellowItems < yellowIcount))
+ {
+ itemID = yellowItemsBin[urand(0, yellowItemsBin.size() - 1)];
+ ++yellowItems;
+ }
+ break;
+ case 7:
+ if ((greyTradeGoodsBin.size() > 0) && (greyTGoods < greyTGcount))
+ {
+ itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)];
+ ++greyTGoods;
+ }
+ break;
+ case 8:
+ if ((whiteTradeGoodsBin.size() > 0) && (whiteTGoods < whiteTGcount))
+ {
+ itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)];
+ ++whiteTGoods;
+ }
+ break;
+ case 9:
+ if ((greenTradeGoodsBin.size() > 0) && (greenTGoods < greenTGcount))
+ {
+ itemID = greenTradeGoodsBin[urand(0, greenTradeGoodsBin.size() - 1)];
+ ++greenTGoods;
+ }
+ break;
+ case 10:
+ if ((blueTradeGoodsBin.size() > 0) && (blueTGoods < blueTGcount))
+ {
+ itemID = blueTradeGoodsBin[urand(0, blueTradeGoodsBin.size() - 1)];
+ ++blueTGoods;
+ }
+ break;
+ case 11:
+ if ((purpleTradeGoodsBin.size() > 0) && (purpleTGoods < purpleTGcount))
+ {
+ itemID = purpleTradeGoodsBin[urand(0, purpleTradeGoodsBin.size() - 1)];
+ ++purpleTGoods;
+ }
+ break;
+ case 12:
+ if ((orangeTradeGoodsBin.size() > 0) && (orangeTGoods < orangeTGcount))
+ {
+ itemID = orangeTradeGoodsBin[urand(0, orangeTradeGoodsBin.size() - 1)];
+ ++orangeTGoods;
+ }
+ break;
+ case 13:
+ if ((yellowTradeGoodsBin.size() > 0) && (yellowTGoods < yellowTGcount))
+ {
+ itemID = yellowTradeGoodsBin[urand(0, yellowTradeGoodsBin.size() - 1)];
+ ++yellowTGoods;
+ }
+ break;
+ default:
+ sLog.outString("AuctionHouseBot: itemID Switch - Default Reached");
+ break;
+ }
+
+ ++loopBreaker;
+ }
+
+ if (itemID == 0)
+ {
+ if (debug_Out)
+ sLog.outString("AuctionHouseBot: Item::CreateItem() - Unable to find item");
+ continue;
+ }
+
+ ItemPrototype const* prototype = sObjectMgr.GetItemPrototype(itemID);
+ if (prototype == NULL)
+ {
+ sLog.outString("AuctionHouseBot: Huh?!?! prototype == NULL");
+ continue;
+ }
+
+ Item* item = Item::CreateItem(itemID, 1, AHBplayer);
+ item->AddToUpdateQueueOf(AHBplayer);
+ if (item == NULL)
+ {
+ sLog.outString("AuctionHouseBot: Item::CreateItem() returned NULL");
+ break;
+ }
+
+ uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemID);
+ if (randomPropertyId != 0)
+ item->SetItemRandomProperties(randomPropertyId);
+
+ uint32 buyoutPrice;
+ uint32 bidPrice = 0;
+ uint32 stackCount = urand(1, item->GetMaxStackCount());
+
+ switch (prototype->Bonding)
+ {
+ case NO_BIND:
+ buyBondingK = No_Bind;
+ break;
+ case BIND_WHEN_PICKED_UP:
+ buyBondingK = Bind_When_Picked_Up;
+ break;
+ case BIND_WHEN_EQUIPED:
+ buyBondingK = Bind_When_Equipped;
+ break;
+ case BIND_WHEN_USE:
+ buyBondingK = Bind_When_Use;
+ break;
+ case BIND_QUEST_ITEM:
+ buyBondingK = Bind_Quest_Item;
+ break;
+ default:
+ buyBondingK = 1;
+ }
+
+ switch (SellMethod)
+ {
+ case 0:
+ if ( prototype->SellPrice > 8 )
+ buyoutPrice = prototype->SellPrice * item->GetCount();
+ else buyoutPrice = prototype->BuyPrice * item->GetCount() / 8 ;
+ break;
+ case 1:
+ if ( prototype->BuyPrice > 1)
+ buyoutPrice = prototype->BuyPrice * item->GetCount();
+ else buyoutPrice = prototype->SellPrice * item->GetCount() * 8 ;
+ break;
+ }
+
+ switch (prototype->Quality)
+ {
+ case 0:
+ if (config->GetMaxStack(AHB_GREY) != 0)
+ {
+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_GREY)));
+ }
+ buyoutPrice *= urand(config->GetMinPrice(AHB_GREY), config->GetMaxPrice(AHB_GREY)) * stackCount;
+ buyoutPrice /= 100;
+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_GREY), config->GetMaxBidPrice(AHB_GREY));
+ bidPrice /= 100;
+ break;
+ case 1:
+ if (config->GetMaxStack(AHB_WHITE) != 0)
+ {
+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_WHITE)));
+ }
+ buyoutPrice *= urand(config->GetMinPrice(AHB_WHITE), config->GetMaxPrice(AHB_WHITE)) * stackCount;
+ buyoutPrice /= 100;
+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_WHITE), config->GetMaxBidPrice(AHB_WHITE));
+ bidPrice /= 100;
+ break;
+ case 2:
+ if (config->GetMaxStack(AHB_GREEN) != 0)
+ {
+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_GREEN)));
+ }
+ buyoutPrice *= urand(config->GetMinPrice(AHB_GREEN), config->GetMaxPrice(AHB_GREEN)) * stackCount;
+ buyoutPrice /= 100;
+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_GREEN), config->GetMaxBidPrice(AHB_GREEN));
+ bidPrice /= 100;
+ break;
+ case 3:
+ if (config->GetMaxStack(AHB_BLUE) != 0)
+ {
+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_BLUE)));
+ }
+ buyoutPrice *= urand(config->GetMinPrice(AHB_BLUE), config->GetMaxPrice(AHB_BLUE)) * stackCount;
+ buyoutPrice /= 100;
+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_BLUE), config->GetMaxBidPrice(AHB_BLUE));
+ bidPrice /= 100;
+ break;
+ case 4:
+ if (config->GetMaxStack(AHB_PURPLE) != 0)
+ {
+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_PURPLE)));
+ }
+ buyoutPrice *= urand(config->GetMinPrice(AHB_PURPLE), config->GetMaxPrice(AHB_PURPLE)) * stackCount;
+ buyoutPrice /= 100;
+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_PURPLE), config->GetMaxBidPrice(AHB_PURPLE));
+ bidPrice /= 100;
+ break;
+ case 5:
+ if (config->GetMaxStack(AHB_ORANGE) != 0)
+ {
+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_ORANGE)));
+ }
+ buyoutPrice *= urand(config->GetMinPrice(AHB_ORANGE), config->GetMaxPrice(AHB_ORANGE)) * stackCount;
+ buyoutPrice /= 100;
+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_ORANGE), config->GetMaxBidPrice(AHB_ORANGE));
+ bidPrice /= 100;
+ break;
+ case 6:
+ if (config->GetMaxStack(AHB_YELLOW) != 0)
+ {
+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_YELLOW)));
+ }
+ buyoutPrice *= urand(config->GetMinPrice(AHB_YELLOW), config->GetMaxPrice(AHB_YELLOW)) * stackCount;
+ buyoutPrice /= 100;
+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_YELLOW), config->GetMaxBidPrice(AHB_YELLOW));
+ bidPrice /= 100;
+ break;
+ }
+
+ item->SetCount(stackCount);
+
+ AuctionEntry* auctionEntry = new AuctionEntry;
+ auctionEntry->Id = sObjectMgr.GenerateAuctionID();
+ auctionEntry->item_guidlow = item->GetGUIDLow();
+ auctionEntry->item_template = item->GetEntry();
+ auctionEntry->owner = AHBplayer->GetGUIDLow();
+ auctionEntry->startbid = bidPrice * buyBondingK;
+ auctionEntry->buyout = buyoutPrice * buyBondingK;
+ auctionEntry->bidder = 0;
+ auctionEntry->bid = 0;
+ auctionEntry->deposit = 0;
+ auctionEntry->expire_time = (time_t) (urand(config->GetMinTime(), config->GetMaxTime()) * 60 * 60 + time(NULL));
+ auctionEntry->auctionHouseEntry = ahEntry;
+ item->SaveToDB();
+ item->RemoveFromUpdateQueueOf(AHBplayer);
+ sAuctionMgr.AddAItem(item);
+ auctionHouse->AddAuction(auctionEntry);
+ auctionEntry->SaveToDB();
+ }
+}
+
+void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session)
+{
+ if (!AHBBuyer)
+ return;
+
+ // Fetches content of selected AH
+ AuctionHouseEntry const* ahEntry = sAuctionHouseStore.LookupEntry(config->GetAHID());
+ AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(ahEntry);
+ vector<uint32> possibleBids;
+
+ for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr)
+ {
+ // Check if the auction is ours
+ // if it is, we skip this iteration.
+ if (itr->second->owner == AHBplayerGUID)
+ {
+ continue;
+ }
+ // Check that we haven't bidded in this auction already.
+ if (itr->second->bidder != AHBplayerGUID)
+ {
+ uint32 tmpdata = itr->second->Id;
+ possibleBids.push_back(tmpdata);
+ }
+ }
+
+ for (uint32 count = 0;count < config->GetBidsPerInterval();++count)
+ {
+
+ // Do we have anything to bid? If not, stop here.
+ if (possibleBids.empty())
+ {
+ count = config->GetBidsPerInterval();
+ continue;
+ }
+
+ // Choose random auction from possible auctions
+ uint32 vectorPos = urand(0, possibleBids.size() - 1);
+ uint32 auctionID = possibleBids[vectorPos];
+
+ // Erase the auction from the vector to prevent bidding on item in next iteration.
+ vector<uint32>::iterator iter = possibleBids.begin();
+ advance(iter, vectorPos);
+ possibleBids.erase(iter);
+
+ // from auctionhousehandler.cpp, creates auction pointer & player pointer
+ AuctionEntry* auction = auctionHouse->GetAuction(auctionID);
+ if (!auction)
+ {
+ sLog.outError("Item doesn't exists, perhaps bought already?");
+ continue;
+ }
+
+ // get exact item information
+ Item *pItem = sAuctionMgr.GetAItem(auction->item_guidlow);
+ if (!pItem)
+ {
+ sLog.outError("Item doesn't exists, perhaps bought already?");
+ continue;
+ }
+
+ // get item prototype
+ ItemPrototype const* prototype = sObjectMgr.GetItemPrototype(auction->item_template);
+
+ // check which price we have to use, startbid or if it is bidded already
+ if (debug_Out)
+ {
+ sLog.outError("Auction Number: %u", auction->Id);
+ sLog.outError("Item Template: %u", auction->item_template);
+ sLog.outError("Buy Price: %u", prototype->BuyPrice);
+ sLog.outError("Sell Price: %u", prototype->SellPrice);
+ sLog.outError("Quality: %u", prototype->Quality);
+ }
+ uint32 currentprice;
+ if (auction->bid)
+ {
+ currentprice = auction->bid;
+ if (debug_Out)
+ {
+ sLog.outError("Current Price: %u", auction->bid);
+ }
+ }
+ else
+ {
+ currentprice = auction->startbid;
+ if (debug_Out)
+ {
+ sLog.outError("Current Price: %u", auction->startbid);
+ }
+ }
+ uint32 bidprice;
+
+ // Prepare portion from maximum bid
+ uint32 tmprate2 = urand(0, 100);
+ double tmprate = static_cast<double>(tmprate2);
+ if (debug_Out)
+ {
+ sLog.outError("tmprate: %f", tmprate);
+ }
+
+ double bidrate = tmprate / 100;
+ if (debug_Out)
+ {
+ sLog.outError("bidrate: %f", bidrate);
+ }
+
+ long double bidMax = 0;
+
+ long double protoSellPrice = prototype->SellPrice;
+ long double protoBuyPrice = prototype->BuyPrice;
+
+ if ( protoSellPrice <= 10000 && protoBuyPrice <= 10000) // вещи меньше 1г не рассматриваем
+ {
+ continue;
+ }
+
+ if (protoBuyPrice <= 1)
+ {
+ protoBuyPrice = protoSellPrice * 8 ;
+ }
+
+ if (protoSellPrice <= 1)
+ {
+ protoSellPrice = protoBuyPrice / 8 ;
+ }
+
+ // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality
+ switch (BuyMethod)
+ {
+ case 0:
+ switch (prototype->Quality)
+ {
+ case 0:
+ if (currentprice < protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY))
+ {
+ bidMax = protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY);
+ }
+ break;
+ case 1:
+ if (currentprice < protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE))
+ {
+ bidMax = protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE);
+ }
+ break;
+ case 2:
+ if (currentprice < protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN))
+ {
+ bidMax = protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN);
+ }
+ break;
+ case 3:
+ if (currentprice < protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE))
+ {
+ bidMax = protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE);
+ }
+ break;
+ case 4:
+ if (currentprice < protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE))
+ {
+ bidMax = protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE);
+ }
+ break;
+ case 5:
+ if (currentprice < protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE))
+ {
+ bidMax = protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE);
+ }
+ break;
+ case 6:
+ if (currentprice < protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW))
+ {
+ bidMax = protoSellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW);
+ }
+ break;
+ default:
+ // quality is something it shouldn't be, let's get out of here
+ if (debug_Out)
+ {
+ sLog.outError("bidMax(fail): %f", bidMax);
+ }
+ continue;
+ break;
+ }
+ break;
+ case 1:
+ switch (prototype->Quality)
+ {
+ case 0:
+ if (currentprice < protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY))
+ {
+ bidMax = protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY);
+ }
+ break;
+ case 1:
+ if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE))
+ {
+ bidMax = protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE);
+ }
+ break;
+ case 2:
+ if (currentprice < protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN))
+ {
+ bidMax = protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN);
+ }
+ break;
+ case 3:
+ if (currentprice < protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE))
+ {
+ bidMax = protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE);
+ }
+ break;
+ case 4:
+ if (currentprice < protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE))
+ {
+ bidMax = protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE);
+ }
+ break;
+ case 5:
+ if (currentprice < protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE))
+ {
+ bidMax = protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE);
+ }
+ break;
+ case 6:
+ if (currentprice < protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW))
+ {
+ bidMax = protoBuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW);
+ }
+ break;
+ default:
+ // quality is something it shouldn't be, let's get out of here
+ if (debug_Out)
+ {
+ sLog.outError("bidMax(fail): %f", bidMax);
+ }
+ continue;
+ break;
+ }
+ break;
+ }
+
+ if (debug_Out)
+ {
+ sLog.outError("bidMax(succeed): %f", bidMax);
+ }
+
+ // check some special items, and do recalculating to their prices
+ switch (prototype->Class)
+ {
+ // ammo
+ case 6:
+ bidMax = 0;
+ break;
+ default:
+ break;
+ }
+
+ if (bidMax == 0)
+ {
+ // quality check failed to get bidmax, let's get out of here
+ continue;
+ }
+
+ // Calculate our bid
+ long double bidvalue = currentprice + ((bidMax - currentprice) * bidrate);
+ if (debug_Out)
+ {
+ sLog.outError("bidvalue: %f", bidvalue);
+ }
+
+ // Convert to uint32
+ bidprice = static_cast<uint32>(bidvalue);
+ if (debug_Out)
+ {
+ sLog.outError("bidprice: %u", bidprice);
+ }
+
+ // Check our bid is high enough to be valid. If not, correct it to minimum.
+ if ((currentprice + auction->GetAuctionOutBid()) > bidprice)
+ {
+ bidprice = currentprice + auction->GetAuctionOutBid();
+ if (debug_Out)
+ {
+ sLog.outError("bidprice(>): %u", bidprice);
+ }
+ }
+
+ // Check wether we do normal bid, or buyout
+ if ((bidprice < auction->buyout) || (auction->buyout == 0))
+ {
+
+ if (auction->bidder > 0)
+ {
+ if (auction->bidder == AHBplayer->GetGUIDLow())
+ {
+ //pl->ModifyMoney(-int32(price - auction->bid));
+ }
+ else
+ {
+ // mail to last bidder and return money
+ session->SendAuctionOutbiddedMail(auction , bidprice);
+ //pl->ModifyMoney(-int32(price));
+ }
+ }
+
+ auction->bidder = AHBplayer->GetGUIDLow();
+ auction->bid = bidprice;
+
+ // Saving auction into database
+ CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
+ }
+ else
+ {
+ //buyout
+ if (AHBplayer->GetGUIDLow() == auction->bidder)
+ {
+ //pl->ModifyMoney(-int32(auction->buyout - auction->bid));
+ }
+ else
+ {
+ //pl->ModifyMoney(-int32(auction->buyout));
+ if (auction->bidder)
+ {
+ session->SendAuctionOutbiddedMail(auction, auction->buyout);
+ }
+ }
+ auction->bidder = AHBplayer->GetGUIDLow();
+ auction->bid = auction->buyout;
+
+ // Send mails to buyer & seller
+ sAuctionMgr.SendAuctionSuccessfulMail(auction);
+ sAuctionMgr.SendAuctionWonMail(auction);
+
+ // Remove item from auctionhouse
+ sAuctionMgr.RemoveAItem(auction->item_guidlow);
+ // Remove auction
+ auctionHouse->RemoveAuction(auction->Id);
+ // Remove from database
+ auction->DeleteFromDB();
+ }
+ }
+}
+
+void AuctionHouseBot::Update()
+{
+ time_t _newrun = time(NULL);
+ if ((!AHBSeller) && (!AHBBuyer))
+ return;
+
+ WorldSession _session(AHBplayerAccount, NULL, SEC_PLAYER, true, 0, LOCALE_enUS);
+ Player _AHBplayer(&_session);
+ _AHBplayer.MinimalLoadFromDB(NULL, AHBplayerGUID);
+ ObjectAccessor::Instance().AddObject(&_AHBplayer);
+
+ // Add New Bids
+ if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
+ {
+ addNewAuctions(&_AHBplayer, &AllianceConfig);
+ if (((_newrun - _lastrun_a) > (AllianceConfig.GetBiddingInterval() * 60)) && (AllianceConfig.GetBidsPerInterval() > 0))
+ {
+ addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig, &_session);
+ _lastrun_a = _newrun;
+ }
+
+ addNewAuctions(&_AHBplayer, &HordeConfig);
+ if (((_newrun - _lastrun_h) > (HordeConfig.GetBiddingInterval() *60)) && (HordeConfig.GetBidsPerInterval() > 0))
+ {
+ addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig, &_session);
+ _lastrun_h = _newrun;
+ }
+ }
+ addNewAuctions(&_AHBplayer, &NeutralConfig);
+ if (((_newrun - _lastrun_n) > (NeutralConfig.GetBiddingInterval() * 60)) && (NeutralConfig.GetBidsPerInterval() > 0))
+ {
+ addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig, &_session);
+ _lastrun_n = _newrun;
+ }
+
+ ObjectAccessor::Instance().RemoveObject(&_AHBplayer);
+}
+
+void AuctionHouseBot::Initialize()
+{
+ AHBSeller = sConfig.GetBoolDefault("AuctionHouseBot.EnableSeller", 0);
+ AHBBuyer = sConfig.GetBoolDefault("AuctionHouseBot.EnableBuyer", 0);
+ AHBplayerAccount = sConfig.GetIntDefault("AuctionHouseBot.Account", 0);
+ AHBplayerGUID = sConfig.GetIntDefault("AuctionHouseBot.GUID", 0);
+ debug_Out = sConfig.GetIntDefault("AuctionHouseBot.DEBUG", 0);
+ No_Bind = sConfig.GetIntDefault("AuctionHouseBot.No_Bind", 1);
+ Bind_When_Picked_Up = sConfig.GetIntDefault("AuctionHouseBot.Bind_When_Picked_Up", 0);
+ Bind_When_Equipped = sConfig.GetIntDefault("AuctionHouseBot.Bind_When_Equipped", 1);
+ Bind_When_Use = sConfig.GetIntDefault("AuctionHouseBot.Bind_When_Use", 1);
+ Bind_Quest_Item = sConfig.GetIntDefault("AuctionHouseBot.Bind_Quest_Item", 0);
+ ItemsPerCycle = sConfig.GetIntDefault("AuctionHouseBot.ItemsPerCycle", 200);
+ SellMethod = sConfig.GetIntDefault("AuctionHouseBot.UseBuyPriceForSeller", 1);
+ BuyMethod = sConfig.GetIntDefault("AuctionHouseBot.UseBuyPriceForBuyer", 0);
+ MaxItemLevel = sConfig.GetIntDefault("AuctionHouseBot.MaxItemLevel", 200);
+
+ if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
+ {
+ LoadValues(&AllianceConfig);
+ LoadValues(&HordeConfig);
+ }
+ LoadValues(&NeutralConfig);
+
+ if (AHBSeller)
+ {
+ Vendor_Items = sConfig.GetBoolDefault("AuctionHouseBot.VendorItems", 0);
+ Loot_Items = sConfig.GetBoolDefault("AuctionHouseBot.LootItems", 1);
+ Other_Items = sConfig.GetBoolDefault("AuctionHouseBot.OtherItems", 0);
+
+ QueryResult* results = (QueryResult*) NULL;
+ char npcQuery[] = "SELECT distinct `item` FROM `npc_vendor`";
+ results = WorldDatabase.PQuery(npcQuery);
+ if (results != NULL)
+ {
+ do
+ {
+ Field* fields = results->Fetch();
+ npcItems.push_back(fields[0].GetUInt32());
+
+ } while (results->NextRow());
+
+ delete results;
+ }
+ else
+ {
+ sLog.outString("AuctionHouseBot: \"%s\" failed", npcQuery);
+ }
+
+ char lootQuery[] = "SELECT `item` FROM `creature_loot_template` UNION "
+ "SELECT `item` FROM `disenchant_loot_template` UNION "
+ "SELECT `item` FROM `fishing_loot_template` UNION "
+ "SELECT `item` FROM `gameobject_loot_template` UNION "
+ "SELECT `item` FROM `item_loot_template` UNION "
+ "SELECT `item` FROM `milling_loot_template` UNION "
+ "SELECT `item` FROM `pickpocketing_loot_template` UNION "
+ "SELECT `item` FROM `prospecting_loot_template` UNION "
+ "SELECT `item` FROM `skinning_loot_template`";
+
+ results = WorldDatabase.PQuery(lootQuery);
+ if (results != NULL)
+ {
+ do
+ {
+ Field* fields = results->Fetch();
+ lootItems.push_back(fields[0].GetUInt32());
+
+ } while (results->NextRow());
+
+ delete results;
+ }
+ else
+ {
+ sLog.outString("AuctionHouseBot: \"%s\" failed", lootQuery);
+ }
+
+ for (uint32 itemID = 0; itemID < sItemStorage.MaxEntry; itemID++)
+ {
+ ItemPrototype const* prototype = sObjectMgr.GetItemPrototype(itemID);
+
+ if (prototype == NULL)
+ continue;
+
+ if (prototype->ItemLevel >= MaxItemLevel)
+ continue;
+
+ switch (prototype->Bonding)
+ {
+ case NO_BIND:
+ if (No_Bind == 0)
+ continue;
+ break;
+ case BIND_WHEN_PICKED_UP:
+ if (Bind_When_Picked_Up == 0)
+ continue;
+ break;
+ case BIND_WHEN_EQUIPED:
+ if (Bind_When_Equipped == 0)
+ continue;
+ break;
+ case BIND_WHEN_USE:
+ if (Bind_When_Use == 0)
+ continue;
+ break;
+ case BIND_QUEST_ITEM:
+ if (Bind_Quest_Item == 0)
+ continue;
+ break;
+ default:
+ continue;
+ break;
+ }
+
+ switch (SellMethod)
+ {
+ case 0:
+ if (prototype->SellPrice == 0)
+ continue;
+ break;
+ case 1:
+ if (prototype->BuyPrice == 0)
+ continue;
+ break;
+ }
+
+ if ((prototype->Quality < 0) || (prototype->Quality > 6))
+ continue;
+
+ if (Vendor_Items == 0)
+ {
+ bool isVendorItem = false;
+
+ for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
+ {
+ if (itemID == npcItems[i])
+ isVendorItem = true;
+ }
+
+ if (isVendorItem)
+ continue;
+ }
+
+ if (Loot_Items == 0)
+ {
+ bool isLootItem = false;
+
+ for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)
+ {
+ if (itemID == lootItems[i])
+ isLootItem = true;
+ }
+
+ if (isLootItem)
+ continue;
+ }
+
+ if (Other_Items == 0)
+ {
+ bool isVendorItem = false;
+ bool isLootItem = false;
+
+ for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
+ {
+ if (itemID == npcItems[i])
+ isVendorItem = true;
+ }
+ for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)
+ {
+ if (itemID == lootItems[i])
+ isLootItem = true;
+ }
+ if ((!isLootItem) && (!isVendorItem))
+ continue;
+ }
+
+ switch (prototype->Quality)
+ {
+ case 0:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ greyTradeGoodsBin.push_back(itemID);
+ else
+ greyItemsBin.push_back(itemID);
+ break;
+
+ case 1:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ whiteTradeGoodsBin.push_back(itemID);
+ else
+ whiteItemsBin.push_back(itemID);
+ break;
+
+ case 2:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ greenTradeGoodsBin.push_back(itemID);
+ else
+ greenItemsBin.push_back(itemID);
+ break;
+
+ case 3:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ blueTradeGoodsBin.push_back(itemID);
+ else
+ blueItemsBin.push_back(itemID);
+ break;
+
+ case 4:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ purpleTradeGoodsBin.push_back(itemID);
+ else
+ purpleItemsBin.push_back(itemID);
+ break;
+
+ case 5:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ orangeTradeGoodsBin.push_back(itemID);
+ else
+ orangeItemsBin.push_back(itemID);
+ break;
+
+ case 6:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ yellowTradeGoodsBin.push_back(itemID);
+ else
+ yellowItemsBin.push_back(itemID);
+ break;
+ }
+ }
+
+ if (
+ (greyTradeGoodsBin.size() == 0) &&
+ (whiteTradeGoodsBin.size() == 0) &&
+ (greenTradeGoodsBin.size() == 0) &&
+ (blueTradeGoodsBin.size() == 0) &&
+ (purpleTradeGoodsBin.size() == 0) &&
+ (orangeTradeGoodsBin.size() == 0) &&
+ (yellowTradeGoodsBin.size() == 0) &&
+ (greyItemsBin.size() == 0) &&
+ (whiteItemsBin.size() == 0) &&
+ (greenItemsBin.size() == 0) &&
+ (blueItemsBin.size() == 0) &&
+ (purpleItemsBin.size() == 0) &&
+ (orangeItemsBin.size() == 0) &&
+ (yellowItemsBin.size() == 0)
+ )
+ {
+ sLog.outString("AuctionHouseBot: No items");
+ AHBSeller = 0;
+ }
+
+ sLog.outString("AuctionHouseBot loading progress:");
+ sLog.outString("loaded %d grey trade goods", greyTradeGoodsBin.size());
+ sLog.outString("loaded %d white trade goods", whiteTradeGoodsBin.size());
+ sLog.outString("loaded %d green trade goods", greenTradeGoodsBin.size());
+ sLog.outString("loaded %d blue trade goods", blueTradeGoodsBin.size());
+ sLog.outString("loaded %d purple trade goods", purpleTradeGoodsBin.size());
+ sLog.outString("loaded %d orange trade goods", orangeTradeGoodsBin.size());
+ sLog.outString("loaded %d yellow trade goods", yellowTradeGoodsBin.size());
+ sLog.outString("loaded %d grey items", greyItemsBin.size());
+ sLog.outString("loaded %d white items", whiteItemsBin.size());
+ sLog.outString("loaded %d green items", greenItemsBin.size());
+ sLog.outString("loaded %d blue items", blueItemsBin.size());
+ sLog.outString("loaded %d purple items", purpleItemsBin.size());
+ sLog.outString("loaded %d orange items", orangeItemsBin.size());
+ sLog.outString("loaded %d yellow items", yellowItemsBin.size());
+ }
+ sLog.outString("AHBot-AHBuyer modified by /dev/rsa is now loaded");
+}
+
+void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char* args)
+{
+ AHBConfig *config;
+ switch (ahMapID)
+ {
+ case 2:
+ config = &AllianceConfig;
+ break;
+ case 6:
+ config = &HordeConfig;
+ break;
+ case 7:
+ config = &NeutralConfig;
+ break;
+ }
+ std::string color;
+ switch (col)
+ {
+ case AHB_GREY:
+ color = "grey";
+ break;
+ case AHB_WHITE:
+ color = "white";
+ break;
+ case AHB_GREEN:
+ color = "green";
+ break;
+ case AHB_BLUE:
+ color = "blue";
+ break;
+ case AHB_PURPLE:
+ color = "purple";
+ break;
+ case AHB_ORANGE:
+ color = "orange";
+ break;
+ case AHB_YELLOW:
+ color = "yellow";
+ break;
+ default:
+ break;
+ }
+ switch (command)
+ {
+ case 0: //ahexpire
+ {
+ AuctionHouseEntry const* ahEntry = sAuctionHouseStore.LookupEntry(config->GetAHID());
+ AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(ahEntry);
+
+ AuctionHouseObject::AuctionEntryMap::iterator itr;
+ itr = auctionHouse->GetAuctionsBegin();
+
+ while (itr != auctionHouse->GetAuctionsEnd())
+ {
+ if (itr->second->owner == AHBplayerGUID)
+ itr->second->expire_time = sWorld.GetGameTime();
+
+ ++itr;
+ }
+ }break;
+ case 1: //min items
+ {
+ char * param1 = strtok(args, " ");
+ uint32 minItems = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET minitems = '%u' WHERE auctionhouse = '%u'", minItems, ahMapID);
+ config->SetMinItems(minItems);
+ }break;
+ case 2: //max items
+ {
+ char * param1 = strtok(args, " ");
+ uint32 maxItems = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems, ahMapID);
+ config->SetMaxItems(maxItems);
+ }break;
+ case 3: //min time
+ {
+ char * param1 = strtok(args, " ");
+ uint32 minTime = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET mintime = '%u' WHERE auctionhouse = '%u'", minTime, ahMapID);
+ config->SetMinTime(minTime);
+ }break;
+ case 4: //max time
+ {
+ char * param1 = strtok(args, " ");
+ uint32 maxTime = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxtime = '%u' WHERE auctionhouse = '%u'", maxTime, ahMapID);
+ config->SetMaxTime(maxTime);
+ }break;
+ case 5: //percentages
+ {
+ char * param1 = strtok(args, " ");
+ char * param2 = strtok(NULL, " ");
+ char * param3 = strtok(NULL, " ");
+ char * param4 = strtok(NULL, " ");
+ char * param5 = strtok(NULL, " ");
+ char * param6 = strtok(NULL, " ");
+ char * param7 = strtok(NULL, " ");
+ char * param8 = strtok(NULL, " ");
+ char * param9 = strtok(NULL, " ");
+ char * param10 = strtok(NULL, " ");
+ char * param11 = strtok(NULL, " ");
+ char * param12 = strtok(NULL, " ");
+ char * param13 = strtok(NULL, " ");
+ char * param14 = strtok(NULL, " ");
+ uint32 greytg = (uint32) strtoul(param1, NULL, 0);
+ uint32 whitetg = (uint32) strtoul(param2, NULL, 0);
+ uint32 greentg = (uint32) strtoul(param3, NULL, 0);
+ uint32 bluetg = (uint32) strtoul(param4, NULL, 0);
+ uint32 purpletg = (uint32) strtoul(param5, NULL, 0);
+ uint32 orangetg = (uint32) strtoul(param6, NULL, 0);
+ uint32 yellowtg = (uint32) strtoul(param7, NULL, 0);
+ uint32 greyi = (uint32) strtoul(param8, NULL, 0);
+ uint32 whitei = (uint32) strtoul(param9, NULL, 0);
+ uint32 greeni = (uint32) strtoul(param10, NULL, 0);
+ uint32 bluei = (uint32) strtoul(param11, NULL, 0);
+ uint32 purplei = (uint32) strtoul(param12, NULL, 0);
+ uint32 orangei = (uint32) strtoul(param13, NULL, 0);
+ uint32 yellowi = (uint32) strtoul(param14, NULL, 0);
+
+ CharacterDatabase.BeginTransaction();
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreytradegoods = '%u' WHERE auctionhouse = '%u'", greytg, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", whitetg, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", greentg, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", bluetg, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", purpletg, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangetradegoods = '%u' WHERE auctionhouse = '%u'", orangetg, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowtradegoods = '%u' WHERE auctionhouse = '%u'", yellowtg, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreyitems = '%u' WHERE auctionhouse = '%u'", greyi, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", whitei, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", greeni, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bluei, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", purplei, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangeitems = '%u' WHERE auctionhouse = '%u'", orangei, ahMapID);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowitems = '%u' WHERE auctionhouse = '%u'", yellowi, ahMapID);
+ CharacterDatabase.CommitTransaction();
+ config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
+ }break;
+ case 6: //min prices
+ {
+ char * param1 = strtok(args, " ");
+ uint32 minPrice = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET minprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), minPrice, ahMapID);
+ config->SetMinPrice(col, minPrice);
+ }break;
+ case 7: //max prices
+ {
+ char * param1 = strtok(args, " ");
+ uint32 maxPrice = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), maxPrice, ahMapID);
+ config->SetMaxPrice(col, maxPrice);
+ }break;
+ case 8: //min bid price
+ {
+ char * param1 = strtok(args, " ");
+ uint32 minBidPrice = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET minbidprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), minBidPrice, ahMapID);
+ config->SetMinBidPrice(col, minBidPrice);
+ }break;
+ case 9: //max bid price
+ {
+ char * param1 = strtok(args, " ");
+ uint32 maxBidPrice = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxbidprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), maxBidPrice, ahMapID);
+ config->SetMaxBidPrice(col, maxBidPrice);
+ }break;
+ case 10: //max stacks
+ {
+ char * param1 = strtok(args, " ");
+ uint32 maxStack = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxstack%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), maxStack, ahMapID);
+ config->SetMaxStack(col, maxStack);
+ }break;
+ case 11: //buyer bid prices
+ {
+ char * param1 = strtok(args, " ");
+ uint32 buyerPrice = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET buyerprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), buyerPrice, ahMapID);
+ config->SetBuyerPrice(col, buyerPrice);
+ }break;
+ case 12: //buyer bidding interval
+ {
+ char * param1 = strtok(args, " ");
+ uint32 bidInterval = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET buyerbiddinginterval = '%u' WHERE auctionhouse = '%u'", bidInterval, ahMapID);
+ config->SetBiddingInterval(bidInterval);
+ }break;
+ case 13: //buyer bids per interval
+ {
+ char * param1 = strtok(args, " ");
+ uint32 bidsPerInterval = (uint32) strtoul(param1, NULL, 0);
+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET buyerbidsperinterval = '%u' WHERE auctionhouse = '%u'", bidsPerInterval, ahMapID);
+ config->SetBidsPerInterval(bidsPerInterval);
+ }break;
+ default:
+ break;
+ }
+}
+
+void AuctionHouseBot::LoadValues(AHBConfig *config)
+{
+ if (AHBSeller)
+ {
+ //load min and max items
+ config->SetMinItems(CharacterDatabase.PQuery("SELECT minitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetMaxItems(CharacterDatabase.PQuery("SELECT maxitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minItems = %u", config->GetMinItems());
+ sLog.outError("maxItems = %u", config->GetMaxItems());
+ }
+ //load min and max auction times
+ config->SetMinTime(CharacterDatabase.PQuery("SELECT mintime FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetMaxTime(CharacterDatabase.PQuery("SELECT maxtime FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minTime = %u", config->GetMinTime());
+ sLog.outError("maxTime = %u", config->GetMaxTime());
+ }
+ //load percentages
+ uint32 greytg = CharacterDatabase.PQuery("SELECT percentgreytradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 whitetg = CharacterDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 greentg = CharacterDatabase.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 bluetg = CharacterDatabase.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 purpletg = CharacterDatabase.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 orangetg = CharacterDatabase.PQuery("SELECT percentorangetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 yellowtg = CharacterDatabase.PQuery("SELECT percentyellowtradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 greyi = CharacterDatabase.PQuery("SELECT percentgreyitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 whitei = CharacterDatabase.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 greeni = CharacterDatabase.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 bluei = CharacterDatabase.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 purplei = CharacterDatabase.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 orangei = CharacterDatabase.PQuery("SELECT percentorangeitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ uint32 yellowi = CharacterDatabase.PQuery("SELECT percentyellowitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
+ config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
+ if (debug_Out)
+ {
+ sLog.outError("percentGreyTradeGoods = %u", config->GetPercentages(AHB_GREY_TG));
+ sLog.outError("percentWhiteTradeGoods = %u", config->GetPercentages(AHB_WHITE_TG));
+ sLog.outError("percentGreenTradeGoods = %u", config->GetPercentages(AHB_GREEN_TG));
+ sLog.outError("percentBlueTradeGoods = %u", config->GetPercentages(AHB_BLUE_TG));
+ sLog.outError("percentPurpleTradeGoods = %u", config->GetPercentages(AHB_PURPLE_TG));
+ sLog.outError("percentOrangeTradeGoods = %u", config->GetPercentages(AHB_ORANGE_TG));
+ sLog.outError("percentYellowTradeGoods = %u", config->GetPercentages(AHB_YELLOW_TG));
+ sLog.outError("percentGreyItems = %u", config->GetPercentages(AHB_GREY_I));
+ sLog.outError("percentWhiteItems = %u", config->GetPercentages(AHB_WHITE_I));
+ sLog.outError("percentGreenItems = %u", config->GetPercentages(AHB_GREEN_I));
+ sLog.outError("percentBlueItems = %u", config->GetPercentages(AHB_BLUE_I));
+ sLog.outError("percentPurpleItems = %u", config->GetPercentages(AHB_PURPLE_I));
+ sLog.outError("percentOrangeItems = %u", config->GetPercentages(AHB_ORANGE_I));
+ sLog.outError("percentYellowItems = %u", config->GetPercentages(AHB_YELLOW_I));
+ }
+ //load min and max prices
+ config->SetMinPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetMaxPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minPriceGrey = %u", config->GetMinPrice(AHB_GREY));
+ sLog.outError("maxPriceGrey = %u", config->GetMaxPrice(AHB_GREY));
+ }
+ config->SetMinPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetMaxPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minPriceWhite = %u", config->GetMinPrice(AHB_WHITE));
+ sLog.outError("maxPriceWhite = %u", config->GetMaxPrice(AHB_WHITE));
+ }
+ config->SetMinPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT minpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetMaxPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT maxpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minPriceGreen = %u", config->GetMinPrice(AHB_GREEN));
+ sLog.outError("maxPriceGreen = %u", config->GetMaxPrice(AHB_GREEN));
+ }
+ config->SetMinPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT minpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetMaxPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT maxpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minPriceBlue = %u", config->GetMinPrice(AHB_BLUE));
+ sLog.outError("maxPriceBlue = %u", config->GetMaxPrice(AHB_BLUE));
+ }
+ config->SetMinPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT minpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetMaxPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minPricePurple = %u", config->GetMinPrice(AHB_PURPLE));
+ sLog.outError("maxPricePurple = %u", config->GetMaxPrice(AHB_PURPLE));
+ }
+ config->SetMinPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetMaxPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minPriceOrange = %u", config->GetMinPrice(AHB_ORANGE));
+ sLog.outError("maxPriceOrange = %u", config->GetMaxPrice(AHB_ORANGE));
+ }
+ config->SetMinPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetMaxPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minPriceYellow = %u", config->GetMinPrice(AHB_YELLOW));
+ sLog.outError("maxPriceYellow = %u", config->GetMaxPrice(AHB_YELLOW));
+ }
+ //load min and max bid prices
+ config->SetMinBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minBidPriceGrey = %u", config->GetMinBidPrice(AHB_GREY));
+ }
+ config->SetMaxBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxBidPriceGrey = %u", config->GetMaxBidPrice(AHB_GREY));
+ }
+ config->SetMinBidPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minBidPriceWhite = %u", config->GetMinBidPrice(AHB_WHITE));
+ }
+ config->SetMaxBidPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxBidPriceWhite = %u", config->GetMaxBidPrice(AHB_WHITE));
+ }
+ config->SetMinBidPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT minbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minBidPriceGreen = %u", config->GetMinBidPrice(AHB_GREEN));
+ }
+ config->SetMaxBidPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT maxbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxBidPriceGreen = %u", config->GetMaxBidPrice(AHB_GREEN));
+ }
+ config->SetMinBidPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT minbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minBidPriceBlue = %u", config->GetMinBidPrice(AHB_BLUE));
+ }
+ config->SetMaxBidPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT maxbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxBidPriceBlue = %u", config->GetMinBidPrice(AHB_BLUE));
+ }
+ config->SetMinBidPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT minbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minBidPricePurple = %u", config->GetMinBidPrice(AHB_PURPLE));
+ }
+ config->SetMaxBidPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxBidPricePurple = %u", config->GetMaxBidPrice(AHB_PURPLE));
+ }
+ config->SetMinBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minBidPriceOrange = %u", config->GetMinBidPrice(AHB_ORANGE));
+ }
+ config->SetMaxBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxBidPriceOrange = %u", config->GetMaxBidPrice(AHB_ORANGE));
+ }
+ config->SetMinBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("minBidPriceYellow = %u", config->GetMinBidPrice(AHB_YELLOW));
+ }
+ config->SetMaxBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {sLog.outError("maxBidPriceYellow = %u", config->GetMaxBidPrice(AHB_YELLOW));
+ }
+ //load max stacks
+ config->SetMaxStack(AHB_GREY, CharacterDatabase.PQuery("SELECT maxstackgrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxStackGrey = %u", config->GetMaxStack(AHB_GREY));
+ }
+ config->SetMaxStack(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxstackwhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxStackWhite = %u", config->GetMaxStack(AHB_WHITE));
+ }
+ config->SetMaxStack(AHB_GREEN, CharacterDatabase.PQuery("SELECT maxstackgreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxStackGreen = %u", config->GetMaxStack(AHB_GREEN));
+ }
+ config->SetMaxStack(AHB_BLUE, CharacterDatabase.PQuery("SELECT maxstackblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxStackBlue = %u", config->GetMaxStack(AHB_BLUE));
+ }
+ config->SetMaxStack(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxstackpurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxStackPurple = %u", config->GetMaxStack(AHB_PURPLE));
+ }
+ config->SetMaxStack(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxstackorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxStackOrange = %u", config->GetMaxStack(AHB_ORANGE));
+ }
+ config->SetMaxStack(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxstackyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("maxStackYellow = %u", config->GetMaxStack(AHB_YELLOW));
+ }
+ }
+ if (AHBBuyer)
+ {
+ //load buyer bid prices
+ config->SetBuyerPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT buyerpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetBuyerPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT buyerpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetBuyerPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT buyerpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetBuyerPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT buyerpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetBuyerPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT buyerpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetBuyerPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT buyerpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ config->SetBuyerPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT buyerpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("buyerPriceGrey = %u", config->GetBuyerPrice(AHB_GREY));
+ sLog.outError("buyerPriceWhite = %u", config->GetBuyerPrice(AHB_WHITE));
+ sLog.outError("buyerPriceGreen = %u", config->GetBuyerPrice(AHB_GREEN));
+ sLog.outError("buyerPriceBlue = %u", config->GetBuyerPrice(AHB_BLUE));
+ sLog.outError("buyerPricePurple = %u", config->GetBuyerPrice(AHB_PURPLE));
+ sLog.outError("buyerPriceOrange = %u", config->GetBuyerPrice(AHB_ORANGE));
+ sLog.outError("buyerPriceYellow = %u", config->GetBuyerPrice(AHB_YELLOW));
+ }
+ //load bidding interval
+ config->SetBiddingInterval(CharacterDatabase.PQuery("SELECT buyerbiddinginterval FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("buyerBiddingInterval = %u", config->GetBiddingInterval());
+ }
+ //load bids per interval
+ config->SetBidsPerInterval(CharacterDatabase.PQuery("SELECT buyerbidsperinterval FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
+ if (debug_Out)
+ {
+ sLog.outError("buyerBidsPerInterval = %u", config->GetBidsPerInterval());
+ }
+ }
+}
View
981 src/game/AuctionHouseBot.h
@@ -0,0 +1,981 @@
+#ifndef AUCTION_HOUSE_BOT_H
+#define AUCTION_HOUSE_BOT_H
+
+#include "World.h"
+#include "Config/Config.h"
+#include "ace/Vector_T.h"
+
+#define AHB_GREY 0
+#define AHB_WHITE 1
+#define AHB_GREEN 2
+#define AHB_BLUE 3
+#define AHB_PURPLE 4
+#define AHB_ORANGE 5
+#define AHB_YELLOW 6
+#define AHB_GREY_TG 0
+#define AHB_WHITE_TG 1
+#define AHB_GREEN_TG 2
+#define AHB_BLUE_TG 3
+#define AHB_PURPLE_TG 4
+#define AHB_ORANGE_TG 5
+#define AHB_YELLOW_TG 6
+#define AHB_GREY_I 7
+#define AHB_WHITE_I 8
+#define AHB_GREEN_I 9
+#define AHB_BLUE_I 10
+#define AHB_PURPLE_I 11
+#define AHB_ORANGE_I 12
+#define AHB_YELLOW_I 13
+
+class AHBConfig
+{
+private:
+ uint32 AHID;
+ uint32 AHFID;
+ uint32 minItems;
+ uint32 maxItems;
+ uint32 minTime;
+ uint32 maxTime;
+ uint32 percentGreyTradeGoods;
+ uint32 percentWhiteTradeGoods;
+ uint32 percentGreenTradeGoods;
+ uint32 percentBlueTradeGoods;
+ uint32 percentPurpleTradeGoods;
+ uint32 percentOrangeTradeGoods;
+ uint32 percentYellowTradeGoods;
+ uint32 percentGreyItems;
+ uint32 percentWhiteItems;
+ uint32 percentGreenItems;
+ uint32 percentBlueItems;
+ uint32 percentPurpleItems;
+ uint32 percentOrangeItems;
+ uint32 percentYellowItems;
+ uint32 minPriceGrey;
+ uint32 maxPriceGrey;
+ uint32 minBidPriceGrey;
+ uint32 maxBidPriceGrey;
+ uint32 maxStackGrey;
+ uint32 minPriceWhite;
+ uint32 maxPriceWhite;
+ uint32 minBidPriceWhite;
+ uint32 maxBidPriceWhite;
+ uint32 maxStackWhite;
+ uint32 minPriceGreen;
+ uint32 maxPriceGreen;
+ uint32 minBidPriceGreen;
+ uint32 maxBidPriceGreen;
+ uint32 maxStackGreen;
+ uint32 minPriceBlue;
+ uint32 maxPriceBlue;
+ uint32 minBidPriceBlue;
+ uint32 maxBidPriceBlue;
+ uint32 maxStackBlue;
+ uint32 minPricePurple;
+ uint32 maxPricePurple;
+ uint32 minBidPricePurple;
+ uint32 maxBidPricePurple;
+ uint32 maxStackPurple;
+ uint32 minPriceOrange;
+ uint32 maxPriceOrange;
+ uint32 minBidPriceOrange;
+ uint32 maxBidPriceOrange;
+ uint32 maxStackOrange;
+ uint32 minPriceYellow;
+ uint32 maxPriceYellow;
+ uint32 minBidPriceYellow;
+ uint32 maxBidPriceYellow;
+ uint32 maxStackYellow;
+
+ uint32 buyerPriceGrey;
+ uint32 buyerPriceWhite;
+ uint32 buyerPriceGreen;
+ uint32 buyerPriceBlue;
+ uint32 buyerPricePurple;
+ uint32 buyerPriceOrange;
+ uint32 buyerPriceYellow;
+ uint32 buyerBiddingInterval;
+ uint32 buyerBidsPerInterval;
+
+ uint32 greytgp;
+ uint32 whitetgp;
+ uint32 greentgp;
+ uint32 bluetgp;
+ uint32 purpletgp;
+ uint32 orangetgp;
+ uint32 yellowtgp;
+ uint32 greyip;
+ uint32 whiteip;
+ uint32 greenip;
+ uint32 blueip;
+ uint32 purpleip;
+ uint32 orangeip;
+ uint32 yellowip;
+
+public:
+ AHBConfig(uint32 ahid)
+ {
+ AHID = ahid;
+ switch(ahid)
+ {
+ case 2:
+ AHFID = 55;
+ break;
+ case 6:
+ AHFID = 29;
+ break;
+ case 7:
+ AHFID = 120;
+ break;
+ default:
+ AHFID = 120;
+ break;
+ }
+ }
+ AHBConfig()
+ {
+ }
+ uint32 GetAHID()
+ {
+ return AHID;
+ }
+ uint32 GetAHFID()
+ {
+ return AHFID;
+ }
+ void SetMinItems(uint32 value)
+ {
+ minItems = value;
+ }
+ uint32 GetMinItems()
+ {
+ if ((minItems == 0) && (maxItems))
+ return maxItems;
+ else if ((maxItems) && (minItems > maxItems))
+ return maxItems;
+ else
+ return minItems;
+ }
+ void SetMaxItems(uint32 value)
+ {
+ maxItems = value;
+ CalculatePercents();
+ }
+ uint32 GetMaxItems()
+ {
+ return maxItems;
+ }
+ void SetMinTime(uint32 value)
+ {
+ minTime = value;
+ }
+ uint32 GetMinTime()
+ {
+ if (minTime < 1)
+ return 1;
+ else if ((maxTime) && (minTime > maxTime))
+ return maxTime;
+ else
+ return minTime;
+ }
+ void SetMaxTime(uint32 value)
+ {
+ maxTime = value;
+ }
+ uint32 GetMaxTime()
+ {
+ return maxTime;
+ }
+ 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)
+ {
+ uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi;
+
+ if (totalPercent == 0)
+ {
+ maxItems = 0;
+ }
+ else if (totalPercent != 100)
+ {
+ greytg = 0;
+ whitetg = 27;
+ greentg = 12;
+ bluetg = 10;
+ purpletg = 1;
+ orangetg = 0;
+ yellowtg = 0;
+ greyi = 0;
+ whitei = 10;
+ greeni = 30;
+ bluei = 8;
+ purplei = 2;
+ orangei = 0;
+ yellowi = 0;
+ }
+ percentGreyTradeGoods = greytg;
+ percentWhiteTradeGoods = whitetg;
+ percentGreenTradeGoods = greentg;
+ percentBlueTradeGoods = bluetg;
+ percentPurpleTradeGoods = purpletg;
+ percentOrangeTradeGoods = orangetg;
+ percentYellowTradeGoods = yellowtg;
+ percentGreyItems = greyi;
+ percentWhiteItems = whitei;
+ percentGreenItems = greeni;
+ percentBlueItems = bluei;
+ percentPurpleItems = purplei;
+ percentOrangeItems = orangei;
+ percentYellowItems = yellowi;
+ CalculatePercents();
+ }
+ uint32 GetPercentages(uint32 color)
+ {
+ switch(color)
+ {
+ case AHB_GREY_TG:
+ return percentGreyTradeGoods;
+ break;
+ case AHB_WHITE_TG:
+ return percentWhiteTradeGoods;
+ break;
+ case AHB_GREEN_TG:
+ return percentGreenTradeGoods;
+ break;
+ case AHB_BLUE_TG:
+ return percentBlueTradeGoods;
+ break;
+ case AHB_PURPLE_TG:
+ return percentPurpleTradeGoods;
+ break;
+ case AHB_ORANGE_TG:
+ return percentOrangeTradeGoods;
+ break;
+ case AHB_YELLOW_TG:
+ return percentYellowTradeGoods;
+ break;
+ case AHB_GREY_I:
+ return percentGreyItems;
+ break;
+ case AHB_WHITE_I:
+ return percentWhiteItems;
+ break;
+ case AHB_GREEN_I:
+ return percentGreenItems;
+ break;
+ case AHB_BLUE_I:
+ return percentBlueItems;
+ break;
+ case AHB_PURPLE_I:
+ return percentPurpleItems;
+ break;
+ case AHB_ORANGE_I:
+ return percentOrangeItems;
+ break;
+ case AHB_YELLOW_I:
+ return percentYellowItems;
+ break;
+ default:
+ return 0;
+ break;
+ }
+ }
+ void SetMinPrice(uint32 color, uint32 value)
+ {
+ switch(color)
+ {
+ case AHB_GREY:
+ minPriceGrey = value;
+ break;
+ case AHB_WHITE:
+ minPriceWhite = value;
+ break;
+ case AHB_GREEN:
+ minPriceGreen = value;
+ break;
+ case AHB_BLUE:
+ minPriceBlue = value;
+ break;
+ case AHB_PURPLE:
+ minPricePurple = value;
+ break;
+ case AHB_ORANGE:
+ minPriceOrange = value;
+ break;
+ case AHB_YELLOW:
+ minPriceYellow = value;
+ break;
+ default:
+ break;
+ }
+ }
+ uint32 GetMinPrice(uint32 color)
+ {
+ switch(color)
+ {
+ case AHB_GREY:
+ {
+ if (minPriceGrey == 0)
+ return 100;
+ else if (minPriceGrey > maxPriceGrey)
+ return maxPriceGrey;
+ else
+ return minPriceGrey;
+ break;
+ }
+ case AHB_WHITE:
+ {
+ if (minPriceWhite == 0)
+ return 150;
+ else if (minPriceWhite > maxPriceWhite)
+ return maxPriceWhite;
+ else
+ return minPriceWhite;
+ break;
+ }
+ case AHB_GREEN:
+ {
+ if (minPriceGreen == 0)
+ return 200;
+ else if (minPriceGreen > maxPriceGreen)
+ return maxPriceGreen;
+ else
+ return minPriceGreen;
+ break;
+ }
+ case AHB_BLUE:
+ {
+ if (minPriceBlue == 0)
+ return 250;
+ else if (minPriceBlue > maxPriceBlue)
+ return maxPriceBlue;
+ else
+ return minPriceBlue;
+ break;
+ }
+ case AHB_PURPLE:
+ {
+ if (minPricePurple == 0)
+ return 300;
+ else if (minPricePurple > maxPricePurple)
+ return maxPricePurple;
+ else
+ return minPricePurple;
+ break;
+ }
+ case AHB_ORANGE:
+ {
+ if (minPriceOrange == 0)
+ return 400;
+ else if (minPriceOrange > maxPriceOrange)
+ return maxPriceOrange;
+ else
+ return minPriceOrange;
+ break;
+ }
+ case AHB_YELLOW:
+ {
+ if (minPriceYellow == 0)
+ return 500;
+ else if (minPriceYellow > maxPriceYellow)
+ return maxPriceYellow;
+ else
+ return minPriceYellow;
+ break;
+ }
+ default:
+ {
+ return 0;
+ break;
+ }
+ }
+ }
+ void SetMaxPrice(uint32 color, uint32 value)
+ {
+ switch(color)
+ {
+ case AHB_GREY:
+ maxPriceGrey = value;
+ break;
+ case AHB_WHITE:
+ maxPriceWhite = value;
+ break;
+ case AHB_GREEN:
+ maxPriceGreen = value;
+ break;
+ case AHB_BLUE:
+ maxPriceBlue = value;
+ break;
+ case AHB_PURPLE:
+ maxPricePurple = value;
+ break;
+ case AHB_ORANGE:
+ maxPriceOrange = value;
+ break;
+ case AHB_YELLOW:
+ maxPriceYellow = value;
+ break;
+ default:
+ break;
+ }
+ }
+ uint32 GetMaxPrice(uint32 color)
+ {
+ switch(color)
+ {
+ case AHB_GREY:
+ {
+ if (maxPriceGrey == 0)
+ return 150;
+ else
+ return maxPriceGrey;
+ break;
+ }
+ case AHB_WHITE:
+ {
+ if (maxPriceWhite == 0)
+ return 250;
+ else
+ return maxPriceWhite;
+ break;
+ }
+ case AHB_GREEN:
+ {
+ if (maxPriceGreen == 0)
+ return 300;
+ else
+ return maxPriceGreen;
+ break;
+ }
+ case AHB_BLUE:
+ {
+ if (maxPriceBlue == 0)
+ return 350;
+ else
+ return maxPriceBlue;
+ break;
+ }
+ case AHB_PURPLE:
+ {
+ if (maxPricePurple == 0)
+ return 450;
+ else
+ return maxPricePurple;
+ break;
+ }
+ case AHB_ORANGE:
+ {
+ if (maxPriceOrange == 0)
+ return 550;
+ else
+ return maxPriceOrange;
+ break;
+ }
+ case AHB_YELLOW:
+ {
+ if (maxPriceYellow == 0)
+ return 650;
+ else
+ return maxPriceYellow;
+ break;
+ }
+ default:
+ {
+ return 0;
+ break;
+ }
+ }
+ }
<