From 50ebd0b35e0d75b8c4fb5cdd5c0ea5703d84c700 Mon Sep 17 00:00:00 2001 From: Blaymoira Date: Tue, 20 Jan 2009 16:50:19 +0100 Subject: *Fix a typo --HG-- branch : trunk --- src/trinitycore/Master.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/trinitycore') diff --git a/src/trinitycore/Master.cpp b/src/trinitycore/Master.cpp index 938f1753c0b..75fea010337 100644 --- a/src/trinitycore/Master.cpp +++ b/src/trinitycore/Master.cpp @@ -459,7 +459,7 @@ bool Master::_StartDB() clearOnlineAccounts(); ///- Insert version info into DB - WorldDatabase.PExecute("UPDATE `version` SET `core_version` = '%s', `core_rev` = '%s'", _FULLVERSION, _REVISION); + WorldDatabase.PExecute("UPDATE `version` SET `core_version` = '%s', `core_revision` = '%s'", _FULLVERSION, _REVISION); sWorld.LoadDBVersion(); -- cgit v1.2.3 From e1f765a972f3039cd4e7d80b1dfd7b0e20acdd88 Mon Sep 17 00:00:00 2001 From: KingPin Date: Tue, 20 Jan 2009 16:44:05 -0600 Subject: AuctionHouseBot patch added. thanx to everyone who worked on it especially Paradox. Only apply 930_characters.sql if you dont already have AHBot installed. AHBot requires an account ID and a character ID to work with, set them in trinitycore.conf and also login atleast once to this character. --HG-- branch : trunk --- README.AHBOT | 175 +++++ sql/characters.sql | 59 ++ sql/updates/CMakeLists.txt | 1 + sql/updates/XXX_characters.sql | 56 ++ src/game/AuctionHouse.cpp | 6 +- src/game/AuctionHouseBot.cpp | 1198 +++++++++++++++++++++++++++++++++ src/game/AuctionHouseBot.h | 687 +++++++++++++++++++ src/game/CMakeLists.txt | 2 + src/game/Chat.cpp | 1 + src/game/Chat.h | 1 + src/game/Level3.cpp | 373 ++++++++++ src/game/Mail.cpp | 18 +- src/game/World.cpp | 7 +- src/trinitycore/trinitycore.conf.dist | 73 ++ win/VC71/game.vcproj | 16 + win/VC80/game.vcproj | 16 + win/VC90/game.vcproj | 10 + 17 files changed, 2696 insertions(+), 3 deletions(-) create mode 100644 README.AHBOT create mode 100644 sql/updates/XXX_characters.sql create mode 100644 src/game/AuctionHouseBot.cpp create mode 100644 src/game/AuctionHouseBot.h (limited to 'src/trinitycore') diff --git a/README.AHBOT b/README.AHBOT new file mode 100644 index 00000000000..ef96d1f0fe8 --- /dev/null +++ b/README.AHBOT @@ -0,0 +1,175 @@ +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: a value of 0 will disable the bot. +AuctionHouseBot.GUID is the GUID (in characters->characters table) of the player you want to run as the auction bot. Note: a value of 0 will disable the bot. +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 +MaxItems = 0 +MinTime = 8 +MaxTime = 24 + +PercentWhiteTradeGoods = 27 +PercentGreenTradeGoods = 12 +PercentBlueTradeGoods = 10 +PercentPurpleTradeGoods = 1 + +PercentWhiteItems = 10 +PercentGreenItems = 30 +PercentBlueItems = 8 +PercentPurpleItems = 2 + +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 + +BuyerPriceGrey = 1 +BuyerPriceWhite = 1 +BuyerPriceGreen = 5 +BuyerPriceBlue = 12 +BuyerPricePurple = 15 +BuyerBiddingInterval = 1 +BuyerBidsPerInterval = 1 + +MaxItems is the number of items you want to keep in the auction houses. +MinItems Minimum items in auctionhouses (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. +MinTime is the minimum number of hours for an auction. +MaxTime is the maximum number of hours for an auction. + +#These must add up to 100 +PercentWhiteTradeGoods is the percentage of the auction items that should be trade goods of white quality. A value of 0 will disable. +PercentGreenTradeGoods is the percentage of the auction items that should be trade goods of green quality. A value of 0 will disable. +PercentBlueTradeGoods is the percentage of the auction items that should be trade goods of blue quality. A value of 0 will disable. +PercentPurpleTradeGoods is the percentage of the auction items that should be trade goods of purple quality. A value of 0 will disable. +PercentWhiteItems is the percentage of the auction items that should be items of white quality. A value of 0 will disable. +PercentGreenItems is the percentage of the auction items that should be items of green quality. A value of 0 will disable. +PercentBlueItems is the percentage of the auction items that should be items of blue quality. A value of 0 will disable. +PercentPurpleItems is the percentage of the auction items that should be items of purple quality. A value of 0 will disable. + +MinPriceWhite is the minimum price adjustment for white 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. +MaxPriceWhite is the maximum price adjustment for white items. +MinBidPriceWhite 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. +MaxBidPriceWhite 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. +MaxStackWhite 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. + +MinPriceGreen - see above +MaxPriceGreen - see above +MinBidPriceGreen - see above +MaxBidPriceGreen - see above +MaxStackGreen - see above +MinPriceBlue - see above +MaxPriceBlue - see above +MinBidPriceBlue - see above +MaxBidPriceBlue - see above +MaxStackBlue - see above +MinPricePurple - see above +MaxPricePurple - see above +MinBidPricePurple - see above +MaxBidPricePurple - see above +MaxStackPurple - see above + +#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 +BuyerPriceWhite +BuyerPriceGreen +BuyerPriceBlue +BuyerPricePurple + +BuyerBiddingInterval is the time (in minutes) between bids. +BuyerBidsPerInterval is the number of bids the buyer will make in a cycle + +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 \ No newline at end of file diff --git a/sql/characters.sql b/sql/characters.sql index 576208ffce5..2414e73a4a5 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -122,6 +122,65 @@ LOCK TABLES `auctionhouse` WRITE; /*!40000 ALTER TABLE `auctionhouse` ENABLE KEYS */; UNLOCK TABLES; +-- +-- 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.', + `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', + `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', + `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).', + `minbidpricewhite` int(11) default '70' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `maxbidpricewhite` int(11) default '100' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `minbidpricegreen` int(11) default '80' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `maxbidpricegreen` int(11) default '100' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `minbidpriceblue` int(11) default '75' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `maxbidpriceblue` int(11) default '100' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `minbidpricepurple` int(11) default '80' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `maxbidpricepurple` int(11) default '100' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `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.', + `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', + `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 table `auctionhousebot` +-- + +insert into `auctionhousebot`(`auctionhouse`,`name`,`minitems`,`maxitems`,`mintime`,`maxtime`,`percentwhitetradegoods`,`percentgreentradegoods`,`percentbluetradegoods`,`percentpurpletradegoods`,`percentwhiteitems`,`percentgreenitems`,`percentblueitems`,`percentpurpleitems`,`minpricewhite`,`maxpricewhite`,`minpricegreen`,`maxpricegreen`,`minpriceblue`,`maxpriceblue`,`minpricepurple`,`maxpricepurple`,`minbidpricewhite`,`maxbidpricewhite`,`minbidpricegreen`,`maxbidpricegreen`,`minbidpriceblue`,`maxbidpriceblue`,`minbidpricepurple`,`maxbidpricepurple`,`maxstackwhite`,`maxstackgreen`,`maxstackblue`,`maxstackpurple`,`buyerpricegrey`,`buyerpricewhite`,`buyerpricegreen`,`buyerpriceblue`,`buyerpricepurple`,`buyerbiddinginterval`,`buyerbidsperinterval`) values +(2,'Alliance',0,0,8,24,27,12,10,1,10,30,8,2,150,250,800,1400,1250,1750,2250,4550,70,100,80,100,75,100,80,100,0,3,2,1,1,1,5,12,15,1,1), +(6,'Horde',0,0,8,24,27,12,10,1,10,30,8,2,150,250,800,1400,1250,1750,2250,4550,70,100,80,100,75,100,80,100,0,3,2,1,1,1,5,12,15,1,1), +(7,'Neutral',0,0,8,24,27,12,10,1,10,30,8,2,150,250,800,1400,1250,1750,2250,4550,70,100,80,100,75,100,80,100,0,3,2,1,1,1,5,12,15,1,1); + -- -- Table structure for table `bugreport` -- diff --git a/sql/updates/CMakeLists.txt b/sql/updates/CMakeLists.txt index dc983f8c14d..dd9c1aad10b 100644 --- a/sql/updates/CMakeLists.txt +++ b/sql/updates/CMakeLists.txt @@ -1,4 +1,5 @@ INSTALL(FILES +XXX_characters.sql 11_characters.sql 45_characters.sql 54_world.sql diff --git a/sql/updates/XXX_characters.sql b/sql/updates/XXX_characters.sql new file mode 100644 index 00000000000..f0ec58c2dc6 --- /dev/null +++ b/sql/updates/XXX_characters.sql @@ -0,0 +1,56 @@ +-- +-- Table structure for table `auctionhousebot` +-- + +CREATE TABLE IF NOT EXISTS `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.', + `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', + `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', + `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).', + `minbidpricewhite` int(11) default '70' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `maxbidpricewhite` int(11) default '100' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `minbidpricegreen` int(11) default '80' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `maxbidpricegreen` int(11) default '100' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `minbidpriceblue` int(11) default '75' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `maxbidpriceblue` int(11) default '100' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `minbidpricepurple` int(11) default '80' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `maxbidpricepurple` int(11) default '100' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)', + `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.', + `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', + `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 table `auctionhousebot` +-- +insert into `auctionhousebot` (`auctionhouse`,`name`,`minitems`,`maxitems`,`mintime`,`maxtime`,`percentwhitetradegoods`,`percentgreentradegoods`,`percentbluetradegoods`,`percentpurpletradegoods`,`percentwhiteitems`,`percentgreenitems`,`percentblueitems`,`percentpurpleitems`,`minpricewhite`,`maxpricewhite`,`minpricegreen`,`maxpricegreen`,`minpriceblue`,`maxpriceblue`,`minpricepurple`,`maxpricepurple`,`minbidpricewhite`,`maxbidpricewhite`,`minbidpricegreen`,`maxbidpricegreen`,`minbidpriceblue`,`maxbidpriceblue`,`minbidpricepurple`,`maxbidpricepurple`,`maxstackwhite`,`maxstackgreen`,`maxstackblue`,`maxstackpurple`,`buyerpricegrey`,`buyerpricewhite`,`buyerpricegreen`,`buyerpriceblue`,`buyerpricepurple`,`buyerbiddinginterval`,`buyerbidsperinterval`) values +(2,'Alliance',0,0,8,24,27,12,10,1,10,30,8,2,150,250,800,1400,1250,1750,2250,4550,70,100,80,100,75,100,80,100,0,3,2,1,1,1,5,12,15,1,1), +(6,'Horde',0,0,8,24,27,12,10,1,10,30,8,2,150,250,800,1400,1250,1750,2250,4550,70,100,80,100,75,100,80,100,0,3,2,1,1,1,5,12,15,1,1), +(7,'Neutral',0,0,8,24,27,12,10,1,10,30,8,2,150,250,800,1400,1250,1750,2250,4550,70,100,80,100,75,100,80,100,0,3,2,1,1,1,5,12,15,1,1); diff --git a/src/game/AuctionHouse.cpp b/src/game/AuctionHouse.cpp index 71a8bb495b4..c200c9751a6 100644 --- a/src/game/AuctionHouse.cpp +++ b/src/game/AuctionHouse.cpp @@ -28,6 +28,7 @@ #include "UpdateMask.h" #include "AuctionHouseObject.h" #include "Util.h" +#include "AuctionHouseBot.h" //please DO NOT use iterator++, because it is slower than ++iterator!!! //post-incrementation is always slower than pre-incrementation ! @@ -171,7 +172,10 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPri std::ostringstream msgAuctionOutbiddedSubject; msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED; - if (oldBidder) + if (oldBidder && !_player) + oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, AHBplayerGUID, newPrice, objmgr.GetAuctionOutBid(auction->bid), auction->item_template); + + if (oldBidder && _player) oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, _player->GetGUID(), newPrice, objmgr.GetAuctionOutBid(auction->bid), auction->item_template); WorldSession::SendMailTo(oldBidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->bidder, msgAuctionOutbiddedSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE); diff --git a/src/game/AuctionHouseBot.cpp b/src/game/AuctionHouseBot.cpp new file mode 100644 index 00000000000..f05d31abb41 --- /dev/null +++ b/src/game/AuctionHouseBot.cpp @@ -0,0 +1,1198 @@ +#include "AuctionHouseBot.h" +#include "Bag.h" +#include "Config/ConfigEnv.h" +#include "Database/DatabaseEnv.h" +#include "Item.h" +#include "Log.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "World.h" +#include "WorldSession.h" +#include "time.h" +#include +#include + +using namespace std; + +static bool debug_Out = sConfig.GetIntDefault("AuctionHouseBot.DEBUG", 0); + +static vector npcItems; +static vector lootItems; +static vector whiteTradeGoods; +static vector greenTradeGoods; +static vector blueTradeGoods; +static vector purpleTradeGoods; +static vector whiteItems; +static vector greenItems; +static vector blueItems; +static vector purpleItems; + +static bool AHBSeller = 0; +static bool AHBBuyer = 0; + +static bool Vendor_Items = 0; +static bool Loot_Items = 0; +static bool Other_Items = 0; + +static bool No_Bind = 0; +static bool Bind_When_Picked_Up = 0; +static bool Bind_When_Equipped = 0; +static bool Bind_When_Use = 0; +static bool Bind_Quest_Item = 0; + +static AHBConfig AllianceConfig = AHBConfig(2); +static AHBConfig HordeConfig = AHBConfig(6); +static AHBConfig NeutralConfig = AHBConfig(7); +time_t _lastrun_a; +time_t _lastrun_h; +time_t _lastrun_n; + +/////////////////////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////////////////////// +static inline uint32 minValue(uint32 a, uint32 b) +{ + return a <= b ? a : b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////////////////////// +static void addNewAuctions(Player *AHBplayer, AHBConfig *config) +{ + if (!AHBSeller) + return; + AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(config->GetAHID()); + uint32 items = 0; + uint32 minItems = config->GetMinItems(); + uint32 maxItems = config->GetMaxItems(); + uint32 auctions = auctionHouse->Getcount(); + + if (auctions >= minItems) + return; + if (auctions <= maxItems) + { + if ((maxItems - auctions) > ItemsPerCycle) + items = ItemsPerCycle; + else + items = (maxItems - auctions); + } + uint32 wtgbin = config->GetPercents(AHB_WHITE_TG); + uint32 gtgbin = config->GetPercents(AHB_GREEN_TG); + uint32 btgbin = config->GetPercents(AHB_BLUE_TG); + uint32 ptgbin = config->GetPercents(AHB_PURPLE_TG); + uint32 wibin = config->GetPercents(AHB_WHITE_I); + uint32 gibin = config->GetPercents(AHB_GREEN_I); + uint32 bibin = config->GetPercents(AHB_BLUE_I); + uint32 pibin = config->GetPercents(AHB_PURPLE_I); + uint32 total = wtgbin + gtgbin + btgbin + ptgbin + wibin + gibin + bibin + pibin; + + uint32 pItems = 0; + uint32 bItems = 0; + uint32 gItems = 0; + uint32 wItems = 0; + uint32 pTGoods = 0; + uint32 bTGoods = 0; + uint32 gTGoods = 0; + uint32 wTGoods = 0; + for (AuctionHouseObject::AuctionEntryMap::iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr) + { + AuctionEntry *Aentry = itr->second; + Item *item = objmgr.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) + wTGoods = wTGoods + 1; + else + wItems = wItems + 1; + break; + + case 1: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + wTGoods = wTGoods + 1; + else + wItems = wItems + 1; + break; + + case 2: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + gTGoods = gTGoods + 1; + else + gItems = gItems + 1; + break; + + case 3: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + bTGoods = bTGoods + 1; + else + bItems = bItems + 1; + break; + + case 4: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + pTGoods = pTGoods + 1; + else + pItems = pItems + 1; + 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; + while (itemID == 0) + { + uint32 choice = urand(1, 8); + switch (choice) + { + case 1: + { + if ((purpleItems.size() > 0) && (pItems < pibin)) + { + itemID = purpleItems[urand(0, purpleItems.size() - 1)]; + pItems = pItems + 1; + break; + } + } + case 2: + { + if ((blueItems.size() > 0) && (bItems < bibin)) + { + itemID = blueItems[urand(0, blueItems.size() - 1)]; + bItems = bItems + 1; + break; + } + } + case 3: + { + if ((greenItems.size() > 0) && (gItems < gibin)) + { + itemID = greenItems[urand(0, greenItems.size() - 1)]; + gItems = gItems + 1; + break; + } + } + case 4: + { + if ((whiteItems.size() > 0) && (wItems < wibin)) + { + itemID = whiteItems[urand(0, whiteItems.size() - 1)]; + wItems = wItems + 1; + break; + } + } + case 5: + { + if ((purpleTradeGoods.size() > 0) && (pTGoods < ptgbin)) + { + itemID = purpleTradeGoods[urand(0, purpleTradeGoods.size() - 1)]; + pTGoods = pTGoods + 1; + break; + } + } + case 6: + { + if ((blueTradeGoods.size() > 0) && (bTGoods < btgbin)) + { + itemID = blueTradeGoods[urand(0, blueTradeGoods.size() - 1)]; + bTGoods = bTGoods + 1; + break; + } + } + case 7: + { + if ((greenTradeGoods.size() > 0) && (gTGoods < gtgbin)) + { + itemID = greenTradeGoods[urand(0, greenTradeGoods.size() - 1)]; + gTGoods = gTGoods + 1; + break; + } + } + case 8: + { + if ((whiteTradeGoods.size() > 0) && (wTGoods < wtgbin)) + { + itemID = whiteTradeGoods[urand(0, whiteTradeGoods.size() - 1)]; + wTGoods = wTGoods + 1; + break; + } + } + default: + { + break; + } + } + } + + ItemPrototype const* prototype = objmgr.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 (SellMethod) + { + case 0: + buyoutPrice = prototype->SellPrice * item->GetCount(); + break; + case 1: + buyoutPrice = prototype->BuyPrice * item->GetCount(); + break; + default: + buyoutPrice = 0; + break; + } + + switch (prototype->Quality) + { + 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; + } + + item->SetCount(stackCount); + + AuctionEntry* auctionEntry = new AuctionEntry; + auctionEntry->Id = objmgr.GenerateAuctionID(); + auctionEntry->auctioneer = 0; + auctionEntry->item_guidlow = item->GetGUIDLow(); + auctionEntry->item_template = item->GetEntry(); + auctionEntry->owner = AHBplayer->GetGUIDLow(); + auctionEntry->startbid = bidPrice; + auctionEntry->buyout = buyoutPrice; + auctionEntry->bidder = 0; + auctionEntry->bid = 0; + auctionEntry->deposit = 0; + auctionEntry->location = config->GetAHID(); + auctionEntry->time = (time_t) (urand(config->GetMinTime(), config->GetMaxTime()) * 60 * 60 + time(NULL)); + item->SaveToDB(); + item->RemoveFromUpdateQueueOf(AHBplayer); + objmgr.AddAItem(item); + auctionHouse->AddAuction(auctionEntry); + + CharacterDatabase.PExecute("INSERT INTO `auctionhouse` (`id`," + "`auctioneerguid`,`itemguid`,`item_template`," + "`itemowner`,`buyoutprice`,`time`,`buyguid`," + "`lastbid`,`startbid`,`deposit`,`location`) " + "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', " + "'" I64FMTD "', '%u', '%u', '%u', '%u', '%u')", + auctionEntry->Id, + auctionEntry->auctioneer, + auctionEntry->item_guidlow, + auctionEntry->item_template, + auctionEntry->owner, + auctionEntry->buyout, + (uint64) auctionEntry->time, + auctionEntry->bidder, + auctionEntry->bid, + auctionEntry->startbid, + auctionEntry->deposit, + auctionEntry->location); + } +} + +static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session) +{ + if (!AHBBuyer) + return; + + // Fetches content of selected AH + AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(config->GetAHID()); + AuctionHouseObject::AuctionEntryMap::iterator itr; + + itr = auctionHouse->GetAuctionsBegin(); + vector possibleBids; + + while (itr != auctionHouse->GetAuctionsEnd()) + { + AuctionHouseObject::AuctionEntryMap::iterator tmp = itr; + ++itr; + // Check if the auction is ours + // if it is, we skip this iteration. + if(tmp->second->owner == AHBplayerGUID) + { + continue; + } + // Check that we haven't bidded in this auction already. + if(tmp->second->bidder != AHBplayerGUID) + { + uint32 tmpdata = tmp->second->Id; + possibleBids.push_back(tmpdata); + } + } + + // Do we have anything to bid? If not, stop here. + if(possibleBids.empty()) + { + return; + } + + // Choose random auction from possible auctions + uint32 auctionID = possibleBids[urand(0, possibleBids.size() - 1)]; + + // from auctionhouse.cpp, creates auction pointer & player pointer + AuctionEntry* auction = auctionHouse->GetAuction(auctionID); + + // get exact item information + Item *pItem = objmgr.GetAItem(auction->item_guidlow); + if (!pItem) + { + sLog.outError("Item doesn't exists, perhaps bought already?"); + return; + } + + // get item prototype + ItemPrototype const* prototype = objmgr.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);} + if(debug_Out) + {sLog.outError("Item Template: %u", auction->item_template);} + if(debug_Out) + {sLog.outError("Buy Price: %u", prototype->BuyPrice);} + if(debug_Out) + {sLog.outError("Sell Price: %u", prototype->SellPrice);} + if(debug_Out) + {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(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; + + // 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 < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY)) + { + bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY); + } + break; + case 1: + if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE)) + { + bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE); + } + break; + case 2: + if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN)) + { + bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN); + } + break; + case 3: + if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE)) + { + bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE); + } + break; + case 4: + if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE)) + { + bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE); + } + break; + default: + // quality is something it shouldn't be, let's get out of here + if(debug_Out) + {sLog.outError("bidMax(fail): %f", bidMax);} + return; + break; + } + break; + case 1: + switch (prototype->Quality) + { + case 0: + if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY)) + { + bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY); + } + break; + case 1: + if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE)) + { + bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE); + } + break; + case 2: + if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN)) + { + bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN); + } + break; + case 3: + if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE)) + { + bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE); + } + break; + case 4: + if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE)) + { + bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE); + } + break; + default: + // quality is something it shouldn't be, let's get out of here + if(debug_Out) + {sLog.outError("bidMax(fail): %f", bidMax);} + return; + break; + } + break; + default: + bidMax = 0; + 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 + return; + } + + // Calculate our bid + long double bidvalue = currentprice + ( (bidMax - currentprice) * bidrate); + if(debug_Out) + {sLog.outError("bidvalue: %f", bidvalue);} + // Convert to uint32 + bidprice = static_cast(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 + objmgr.GetAuctionOutBid(currentprice)) > bidprice) + { + bidprice = currentprice + objmgr.GetAuctionOutBid(currentprice); + 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 + objmgr.SendAuctionSuccessfulMail( auction ); + objmgr.SendAuctionWonMail( auction ); + + // Remove item from auctionhouse + objmgr.RemoveAItem(auction->item_guidlow); + // Remove auction + auctionHouse->RemoveAuction(auction->Id); + // Remove from database + CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id); + + delete auction; + } +} +/////////////////////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////////////////////// +void AuctionHouseBot() +{ + time_t _newrun = time(NULL); + if ((!AHBSeller) && (!AHBBuyer)) + return; + + WorldSession _session(AHBplayerAccount, NULL, 0, true, 0, LOCALE_enUS); + Player _AHBplayer(&_session); + _AHBplayer.MinimalLoadFromDB(NULL, AHBplayerGUID); + ObjectAccessor::Instance().AddObject(&_AHBplayer); + + if(sConfig.GetIntDefault("AllowTwoSide.Interaction.Auction",0) == 0) + { + addNewAuctions(&_AHBplayer, &AllianceConfig); + if (((_newrun - _lastrun_a) > (AllianceConfig.GetBiddingInterval() * 60)) && (AllianceConfig.GetBidsPerInterval() > 0)) + { + uint32 bids = AllianceConfig.GetBidsPerInterval(); + for (uint32 count = 1;count <= bids;count++) + { + addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig, &_session); + _lastrun_a = _newrun; + } + } + addNewAuctions(&_AHBplayer, &HordeConfig); + if (((_newrun - _lastrun_h) > (HordeConfig.GetBiddingInterval() *60)) && (HordeConfig.GetBidsPerInterval() > 0)) + { + uint32 bids = HordeConfig.GetBidsPerInterval(); + for (uint32 count = 1;count <= bids;count++) + { + addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig, &_session); + _lastrun_h = _newrun; + } + } + } + addNewAuctions(&_AHBplayer, &NeutralConfig); + if (((_newrun - _lastrun_n) > (NeutralConfig.GetBiddingInterval() * 60)) && (NeutralConfig.GetBidsPerInterval() > 0)) + { + uint32 bids = NeutralConfig.GetBidsPerInterval(); + for (uint32 count = 1;count <= bids;count++) + { + addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig, &_session); + _lastrun_n = _newrun; + } + } + ObjectAccessor::Instance().RemoveObject(&_AHBplayer); +} +/////////////////////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////////////////////// +void AuctionHouseBotInit() +{ + AHBSeller = sConfig.GetBoolDefault("AuctionHouseBot.EnableSeller", 0); + AHBBuyer = sConfig.GetBoolDefault("AuctionHouseBot.EnableBuyer", 0); + No_Bind = sConfig.GetBoolDefault("AuctionHouseBot.No_Bind", 1); + Bind_When_Picked_Up = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Picked_Up", 0); + Bind_When_Equipped = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Equipped", 1); + Bind_When_Use = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Use", 1); + Bind_Quest_Item = sConfig.GetBoolDefault("AuctionHouseBot.Bind_Quest_Item", 0); + + if(sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",0) == 0) + { + AuctionHouseBotLoadValues(&AllianceConfig); + AuctionHouseBotLoadValues(&HordeConfig); + } + AuctionHouseBotLoadValues(&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 `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 = objmgr.GetItemPrototype(itemID); + + if (prototype == NULL) + continue; + + switch (prototype->Bonding) + { + case 0: + if (!No_Bind) + continue; + break; + case 1: + if (!Bind_When_Picked_Up) + continue; + break; + case 2: + if (!Bind_When_Equipped) + continue; + break; + case 3: + if (!Bind_When_Use) + continue; + break; + case 4: + if (!Bind_Quest_Item) + continue; + break; + default: + continue; + break; + } + + switch (SellMethod) + { + case 0: + if (prototype->SellPrice == 0) + continue; + break; + case 1: + if (prototype->BuyPrice == 0) + continue; + break; + default: + continue; + break; + } + + if ((prototype->Quality < 1) || (prototype->Quality > 4)) + 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 1: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + whiteTradeGoods.push_back(itemID); + else + whiteItems.push_back(itemID); + break; + + case 2: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + greenTradeGoods.push_back(itemID); + else + greenItems.push_back(itemID); + break; + + case 3: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + blueTradeGoods.push_back(itemID); + else + blueItems.push_back(itemID); + break; + + case 4: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + purpleTradeGoods.push_back(itemID); + else + purpleItems.push_back(itemID); + break; + } + } + + if ((whiteTradeGoods.size() == 0) && + (greenTradeGoods.size() == 0) && + (blueTradeGoods.size() == 0) && + (purpleTradeGoods.size() == 0) && + (whiteItems.size() == 0) && + (greenItems.size() == 0) && + (blueItems.size() == 0) && + (purpleItems.size() == 0)) + { + sLog.outString("AuctionHouseBot: No items"); + AHBSeller = 0; + } + + sLog.outString("AuctionHouseBot:"); + sLog.outString("loaded %d white trade goods", whiteTradeGoods.size()); + sLog.outString("loaded %d green trade goods", greenTradeGoods.size()); + sLog.outString("loaded %d blue trade goods", blueTradeGoods.size()); + sLog.outString("loaded %d purple trade goods", purpleTradeGoods.size()); + sLog.outString("loaded %d white items", whiteItems.size()); + sLog.outString("loaded %d green items", greenItems.size()); + sLog.outString("loaded %d blue items", blueItems.size()); + sLog.outString("loaded %d purple items", purpleItems.size()); + } + sLog.outString("AuctionHouseBot by Paradox (original by ChrisK) has been loaded."); + sLog.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox"); + +} +void AuctionHouseBotCommands(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; + default: + break; + } + switch (command) + { + case 0: //ahexpire + { + AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID); + + AuctionHouseObject::AuctionEntryMap::iterator itr; + itr = auctionHouse->GetAuctionsBegin(); + + while (itr != auctionHouse->GetAuctionsEnd()) + { + if (itr->second->owner == AHBplayerGUID) + itr->second->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, " "); + uint32 wtg = (uint32) strtoul(param1, NULL, 0); + uint32 gtg = (uint32) strtoul(param2, NULL, 0); + uint32 btg = (uint32) strtoul(param3, NULL, 0); + uint32 ptg = (uint32) strtoul(param4, NULL, 0); + uint32 wi = (uint32) strtoul(param5, NULL, 0); + uint32 gi = (uint32) strtoul(param6, NULL, 0); + uint32 bi = (uint32) strtoul(param7, NULL, 0); + uint32 pi = (uint32) strtoul(param8, NULL, 0); + + CharacterDatabase.BeginTransaction(); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", wtg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", gtg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", btg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", ptg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", wi, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", gi, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bi, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", pi, ahMapID); + CharacterDatabase.CommitTransaction(); + config->SetPercentages(wtg, gtg, btg, ptg, wi, gi, bi, pi); + }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 AuctionHouseBotLoadValues(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 wtg = CharacterDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 gtg = CharacterDatabase.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 btg = CharacterDatabase.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 ptg = CharacterDatabase.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 wi = CharacterDatabase.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 gi = CharacterDatabase.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 bi = CharacterDatabase.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 pi = CharacterDatabase.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + config->SetPercentages(wtg, gtg, btg, ptg, wi, gi, bi, pi); + if(debug_Out) + {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("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));} + //load min and max prices + 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));} + //load min and max bid prices + 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));} + //load max stacks + 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));} + } + 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()); + 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));} + //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());} + } +} diff --git a/src/game/AuctionHouseBot.h b/src/game/AuctionHouseBot.h new file mode 100644 index 00000000000..71b14d17a4a --- /dev/null +++ b/src/game/AuctionHouseBot.h @@ -0,0 +1,687 @@ +#ifndef AUCTION_HOUSE_BOT_H +#define AUCTION_HOUSE_BOT_H +#include "Common.h" +#include "Log.h" +#include "Config/ConfigEnv.h" +#define AHB_GREY 0 +#define AHB_WHITE 1 +#define AHB_GREEN 2 +#define AHB_BLUE 3 +#define AHB_PURPLE 4 +#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_GREY_I 5 +#define AHB_WHITE_I 6 +#define AHB_GREEN_I 7 +#define AHB_BLUE_I 8 +#define AHB_PURPLE_I 9 +#define AHBplayerAccount sConfig.GetIntDefault("AuctionHouseBot.Account", 0) +#define AHBplayerGUID sConfig.GetIntDefault("AuctionHouseBot.GUID", 0) +#define ItemsPerCycle sConfig.GetIntDefault("AuctionHouseBot.ItemsPerCycle", 200) +#define SellMethod sConfig.GetIntDefault("AuctionHouseBot.UseBuyPriceForSeller", 1) +#define BuyMethod sConfig.GetIntDefault("AuctionHouseBot.UseBuyPriceForBuyer", 0) + +class AHBConfig +{ + private: + uint32 AHID; + uint32 minItems; + uint32 maxItems; + uint32 minTime; + uint32 maxTime; + uint32 percentWhiteTradeGoods; + uint32 percentGreenTradeGoods; + uint32 percentBlueTradeGoods; + uint32 percentPurpleTradeGoods; + uint32 percentWhiteItems; + uint32 percentGreenItems; + uint32 percentBlueItems; + uint32 percentPurpleItems; + 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 buyerPriceGrey; + uint32 buyerPriceWhite; + uint32 buyerPriceGreen; + uint32 buyerPriceBlue; + uint32 buyerPricePurple; + uint32 buyerBiddingInterval; + uint32 buyerBidsPerInterval; + + uint32 wtgp; + uint32 gtgp; + uint32 btgp; + uint32 ptgp; + uint32 wip; + uint32 gip; + uint32 bip; + uint32 pip; + public: + AHBConfig(uint32 ahid) + { + AHID = ahid; + } + AHBConfig() + { + } + uint32 GetAHID() + { + return AHID; + } + 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 wtg, uint32 gtg, uint32 btg, uint32 ptg, uint32 wi, uint32 gi, uint32 bi, uint32 pi) + { + uint32 totalPercent = wtg + gtg + btg + ptg + wi + gi + bi + pi; + + if (totalPercent == 0) + { + maxItems = 0; + } + else if (totalPercent != 100) + { + double scale = (double) 100 / (double) totalPercent; + + wtg = (uint32) (scale * (double) pi); + gtg = (uint32) (scale * (double) gtg); + btg = (uint32) (scale * (double) btg); + ptg = (uint32) (scale * (double) ptg); + wi = (uint32) (scale * (double) wi); + gi = (uint32) (scale * (double) gi); + bi = (uint32) (scale * (double) bi); + pi = 100 - wtg - gtg - btg - ptg - wi - gi - bi; + + } + percentWhiteTradeGoods = wtg; + percentGreenTradeGoods = gtg; + percentBlueTradeGoods = btg; + percentPurpleTradeGoods = ptg; + percentWhiteItems = wi; + percentGreenItems = gi; + percentBlueItems = bi; + percentPurpleItems = pi; + CalculatePercents(); + } + uint32 GetPercentages(uint32 color) + { + switch(color) + { + case AHB_GREY_TG: + return 0; + 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_GREY_I: + return 0; + 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; + default: + return 0; + break; + } + } + void SetMinPrice(uint32 color, uint32 value) + { + switch(color) + { + case AHB_GREY: + 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; + default: + break; + } + } + uint32 GetMinPrice(uint32 color) + { + switch(color) + { + case AHB_GREY: + { + return 0; + 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; + } + default: + { + return 0; + break; + } + } + } + void SetMaxPrice(uint32 color, uint32 value) + { + switch(color) + { + case AHB_GREY: + 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; + default: + break; + } + } + uint32 GetMaxPrice(uint32 color) + { + switch(color) + { + case AHB_GREY: + { + return 0; + 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; + } + default: + { + return 0; + break; + } + } + } + void SetMinBidPrice(uint32 color, uint32 value) + { + switch(color) + { + case AHB_GREY: + break; + case AHB_WHITE: + minBidPriceWhite = value; + break; + case AHB_GREEN: + minBidPriceGreen = value; + break; + case AHB_BLUE: + minBidPriceBlue = value; + break; + case AHB_PURPLE: + minBidPricePurple = value; + break; + default: + break; + } + } + uint32 GetMinBidPrice(uint32 color) + { + switch(color) + { + case AHB_GREY: + { + return 0; + break; + } + case AHB_WHITE: + { + if (minBidPriceWhite > 100) + return 100; + else + return minBidPriceWhite; + break; + } + case AHB_GREEN: + { + if (minBidPriceGreen > 100) + return 100; + else + return minBidPriceGreen; + break; + } + case AHB_BLUE: + { + if (minBidPriceBlue > 100) + return 100; + else + return minBidPriceBlue; + break; + } + case AHB_PURPLE: + { + if (minBidPricePurple > 100) + return 100; + else + return minBidPricePurple; + break; + } + default: + { + return 0; + break; + } + } + } + void SetMaxBidPrice(uint32 color, uint32 value) + { + switch(color) + { + case AHB_GREY: + break; + case AHB_WHITE: + maxBidPriceWhite = value; + break; + case AHB_GREEN: + maxBidPriceGreen = value; + break; + case AHB_BLUE: + maxBidPriceBlue = value; + break; + case AHB_PURPLE: + maxBidPricePurple = value; + break; + default: + break; + } + } + uint32 GetMaxBidPrice(uint32 color) + { + switch(color) + { + case AHB_GREY: + { + return 0; + break; + } + case AHB_WHITE: + { + if (maxBidPriceWhite > 100) + return 100; + else + return maxBidPriceWhite; + break; + } + case AHB_GREEN: + { + if (maxBidPriceGreen > 100) + return 100; + else + return maxBidPriceGreen; + break; + } + case AHB_BLUE: + { + if (maxBidPriceBlue > 100) + return 100; + else + return maxBidPriceBlue; + break; + } + case AHB_PURPLE: + { + if (maxBidPricePurple > 100) + return 100; + else + return maxBidPricePurple; + break; + } + default: + { + return 0; + break; + } + } + } + void SetMaxStack(uint32 color, uint32 value) + { + switch(color) + { + case AHB_GREY: + break; + case AHB_WHITE: + maxStackWhite = value; + break; + case AHB_GREEN: + maxStackGreen = value; + break; + case AHB_BLUE: + maxStackBlue = value; + break; + case AHB_PURPLE: + maxStackPurple = value; + break; + default: + break; + } + } + uint32 GetMaxStack(uint32 color) + { + switch(color) + { + case AHB_GREY: + { + return 0; + break; + } + case AHB_WHITE: + { + return maxStackWhite; + break; + } + case AHB_GREEN: + { + return maxStackGreen; + break; + } + case AHB_BLUE: + { + return maxStackBlue; + break; + } + case AHB_PURPLE: + { + return maxStackPurple; + break; + } + default: + { + return 0; + break; + } + } + } + void SetBuyerPrice(uint32 color, uint32 value) + { + switch(color) + { + case AHB_GREY: + buyerPriceGrey = value; + break; + case AHB_WHITE: + buyerPriceWhite = value; + break; + case AHB_GREEN: + buyerPriceGreen = value; + break; + case AHB_BLUE: + buyerPriceBlue = value; + break; + case AHB_PURPLE: + buyerPricePurple = value; + break; + default: + break; + } + } + uint32 GetBuyerPrice(uint32 color) + { + switch(color) + { + case AHB_GREY: + return buyerPriceGrey; + break; + case AHB_WHITE: + return buyerPriceWhite; + break; + case AHB_GREEN: + return buyerPriceGreen; + break; + case AHB_BLUE: + return buyerPriceBlue; + break; + case AHB_PURPLE: + return buyerPricePurple; + break; + default: + return 0; + break; + } + } + void SetBiddingInterval(uint32 value) + { + buyerBiddingInterval = value; + } + uint32 GetBiddingInterval() + { + return buyerBiddingInterval; + } + void CalculatePercents() + { + wtgp = (uint32) (((double)percentWhiteTradeGoods / 100.0) * maxItems); + gtgp = (uint32) (((double)percentGreenTradeGoods / 100.0) * maxItems); + btgp = (uint32) (((double)percentBlueTradeGoods / 100.0) * maxItems); + ptgp = (uint32) (((double)percentPurpleTradeGoods / 100.0) * maxItems); + wip = (uint32) (((double)percentWhiteItems / 100.0) * maxItems); + gip = (uint32) (((double)percentGreenItems / 100.0) * maxItems); + bip = (uint32) (((double)percentBlueItems / 100.0) * maxItems); + pip = (uint32) (((double)percentPurpleItems / 100.0) * maxItems); + uint32 total = wtgp + gtgp + btgp + ptgp + wip + gip + bip + pip; + if (total != maxItems) + { + wtgp = (uint32) (maxItems * (double) wtgp); + gtgp = (uint32) (maxItems * (double) gtgp); + btgp = (uint32) (maxItems * (double) btgp); + ptgp = (uint32) (maxItems * (double) ptgp); + wip = (uint32) (maxItems * (double) wip); + gip = (uint32) (maxItems * (double) gip); + bip = (uint32) (maxItems * (double) bip); + pip = (maxItems - (wtgp + gtgp + btgp + ptgp + wip + gip + bip)); + total = wtgp + gtgp + btgp + ptgp + wip + gip + bip + pip; + } + //sLog.outString("%u %u %u %u %u %u %u %u", wtgp, gtgp, btgp, ptgp, wip, gip, bip, pip); + } + uint32 GetPercents(uint32 color) + { + switch(color) + { + case AHB_GREY_TG: + return 0; + break; + case AHB_WHITE_TG: + return wtgp; + break; + case AHB_GREEN_TG: + return gtgp; + break; + case AHB_BLUE_TG: + return btgp; + break; + case AHB_PURPLE_TG: + return ptgp; + break; + case AHB_GREY_I: + return 0; + break; + case AHB_WHITE_I: + return wip; + break; + case AHB_GREEN_I: + return gip; + break; + case AHB_BLUE_I: + return bip; + break; + case AHB_PURPLE_I: + return pip; + break; + default: + return 0; + break; + } + } + void SetBidsPerInterval(uint32 value) + { + buyerBidsPerInterval = value; + } + uint32 GetBidsPerInterval() + { + return buyerBidsPerInterval; + } + ~AHBConfig() + { + } +}; +void AuctionHouseBot(); +void AuctionHouseBotInit(); +void AuctionHouseBotLoadValues(AHBConfig*); +void AuctionHouseBotCommands(uint32, uint32, uint32, char*); +#endif diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index db1e31f2414..8cee1325205 100644 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -13,6 +13,8 @@ SET(game_STAT_SRCS ArenaTeam.h ArenaTeamHandler.cpp AuctionHouse.cpp + AuctionHouseBot.cpp + AuctionHouseBot.h AuctionHouseObject.h Bag.cpp Bag.h diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index fc25216a55e..d6cdde47a8c 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -616,6 +616,7 @@ ChatCommand * ChatHandler::getCommandTable() { "cometome", SEC_ADMINISTRATOR, false, &ChatHandler::HandleComeToMeCommand, "", NULL }, { "damage", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDamageCommand, "", NULL }, { "combatstop", SEC_GAMEMASTER, false, &ChatHandler::HandleCombatStopCommand, "", NULL }, + { "ahbotoptions", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotOptionsCommand, "", NULL }, { "flusharenapoints", SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL }, { "chardelete", SEC_CONSOLE, true, &ChatHandler::HandleCharacterDeleteCommand, "", NULL }, { "sendmessage", SEC_ADMINISTRATOR, true, &ChatHandler::HandleSendMessageCommand, "", NULL }, diff --git a/src/game/Chat.h b/src/game/Chat.h index 1b7224c3f0d..90936c9ac91 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -100,6 +100,7 @@ class ChatHandler bool HandleAccountSetPasswordCommand(const char* args); bool HandleHelpCommand(const char* args); + bool HandleAHBotOptionsCommand(const char * args); bool HandleCommandsCommand(const char* args); bool HandleStartCommand(const char* args); bool HandleDismountCommand(const char* args); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index b896164cade..c7289269540 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -52,6 +52,379 @@ #include "BattleGroundMgr.h" #include "InstanceSaveMgr.h" #include "InstanceData.h" +#include "AuctionHouseBot.h" + +bool ChatHandler::HandleAHBotOptionsCommand(const char* args) +{ + uint32 ahMapID = 0; + char * opt = strtok((char*)args, " "); + char * ahMapIdStr = strtok(NULL, " "); + if (ahMapIdStr) + { + ahMapID = (uint32) strtoul(ahMapIdStr, NULL, 0); + } + if (!opt) + { + PSendSysMessage("Syntax is: ahbotoptions $option $ahMapID (2, 6 or 7) $parameter"); + PSendSysMessage("Try ahbotoptions help to see a list of options."); + return false; + } + int l = strlen(opt); + + if (strncmp(opt,"help",l) == 0) + { + PSendSysMessage("AHBot commands:"); + PSendSysMessage("ahexpire"); + PSendSysMessage("minitems"); + PSendSysMessage("maxitems"); + PSendSysMessage("mintime"); + PSendSysMessage("maxtime"); + PSendSysMessage("percentages"); + PSendSysMessage("minprice"); + PSendSysMessage("maxprice"); + PSendSysMessage("minbidprice"); + PSendSysMessage("maxbidprice"); + PSendSysMessage("maxstack"); + PSendSysMessage("buyerprice"); + PSendSysMessage("bidinterval"); + PSendSysMessage("bidsperinterval"); + return true; + } + else if (strncmp(opt,"ahexpire",l) == 0) + { + if (!ahMapIdStr) + { + PSendSysMessage("Syntax is: ahbotoptions ahexpire $ahMapID (2, 6 or 7)"); + return false; + } + AuctionHouseBotCommands(0, ahMapID, NULL, NULL); + } + else if (strncmp(opt,"minitems",l) == 0) + { + char * param1 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1)) + { + PSendSysMessage("Syntax is: ahbotoptions minitems $ahMapID (2, 6 or 7) $minItems"); + return false; + } + AuctionHouseBotCommands(1, ahMapID, NULL, param1); + } + else if (strncmp(opt,"maxitems",l) == 0) + { + char * param1 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1)) + { + PSendSysMessage("Syntax is: ahbotoptions maxitems $ahMapID (2, 6 or 7) $maxItems"); + return false; + } + AuctionHouseBotCommands(2, ahMapID, NULL, param1); + } + else if (strncmp(opt,"mintime",l) == 0) + { + char * param1 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1)) + { + PSendSysMessage("Syntax is: ahbotoptions mintime $ahMapID (2, 6 or 7) $mintime"); + return false; + } + AuctionHouseBotCommands(3, ahMapID, NULL, param1); + } + else if (strncmp(opt,"maxtime",l) == 0) + { + char * param1 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1)) + { + PSendSysMessage("Syntax is: ahbotoptions maxtime $ahMapID (2, 6 or 7) $maxtime"); + return false; + } + AuctionHouseBotCommands(4, ahMapID, NULL, param1); + } + else if (strncmp(opt,"percentages",l) == 0) + { + char * param1 = strtok(NULL, " "); + 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, " "); + if ((!ahMapIdStr) || (!param1) || (!param2) || (!param3) || (!param4) || (!param5) || (!param6) || (!param7) || (!param8)) + { + PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8"); + PSendSysMessage("1 WhiteTradeGoods 2 GreenTradeGoods 3 BlueTradeGoods 4 PurpleTradeGoods"); + PSendSysMessage("5 WhiteItems 6 GreenItems 7 BlueItems 8 PurpleItems"); + PSendSysMessage("The total must add up to 100%"); + return false; + } + uint32 wtg = (uint32) strtoul(param1, NULL, 0); + uint32 gtg = (uint32) strtoul(param2, NULL, 0); + uint32 btg = (uint32) strtoul(param3, NULL, 0); + uint32 ptg = (uint32) strtoul(param4, NULL, 0); + uint32 wi = (uint32) strtoul(param5, NULL, 0); + uint32 gi = (uint32) strtoul(param6, NULL, 0); + uint32 bi = (uint32) strtoul(param7, NULL, 0); + uint32 pi = (uint32) strtoul(param8, NULL, 0); + uint32 totalPercent = wtg + gtg + btg + ptg + wi + gi + bi + pi; + if ((totalPercent == 0) || (totalPercent != 100)) + { + PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8"); + PSendSysMessage("1 WhiteTradeGoods 2 GreenTradeGoods 3 BlueTradeGoods 4 PurpleTradeGoods"); + PSendSysMessage("5 WhiteItems 6 GreenItems 7 BlueItems 8 PurpleItems"); + PSendSysMessage("The total must add up to 100%"); + return false; + } + char param[100]; + param[0] = '\0'; + strcat(param, param1); + strcat(param, " "); + strcat(param, param2); + strcat(param, " "); + strcat(param, param3); + strcat(param, " "); + strcat(param, param4); + strcat(param, " "); + strcat(param, param5); + strcat(param, " "); + strcat(param, param6); + strcat(param, " "); + strcat(param, param7); + strcat(param, " "); + strcat(param, param8); + AuctionHouseBotCommands(5, ahMapID, NULL, param); + } + else if (strncmp(opt,"minprice",l) == 0) + { + char * param1 = strtok(NULL, " "); + char * param2 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1) || (!param2)) + { + PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + return false; + } + if (strncmp(param1,"white",l) == 0) + { + AuctionHouseBotCommands(6, ahMapID, AHB_WHITE, param2); + } + else if (strncmp(param1,"green",l) == 0) + { + AuctionHouseBotCommands(6, ahMapID, AHB_GREEN, param2); + } + else if (strncmp(param1,"blue",l) == 0) + { + AuctionHouseBotCommands(6, ahMapID, AHB_BLUE, param2); + } + else if (strncmp(param1,"purple",l) == 0) + { + AuctionHouseBotCommands(6, ahMapID, AHB_PURPLE, param2); + } + else + { + PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + return false; + } + } + else if (strncmp(opt,"maxprice",l) == 0) + { + char * param1 = strtok(NULL, " "); + char * param2 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1) || (!param2)) + { + PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + return false; + } + if (strncmp(param1,"white",l) == 0) + { + AuctionHouseBotCommands(7, ahMapID, AHB_WHITE, param2); + } + else if (strncmp(param1,"green",l) == 0) + { + AuctionHouseBotCommands(7, ahMapID, AHB_GREEN, param2); + } + else if (strncmp(param1,"blue",l) == 0) + { + AuctionHouseBotCommands(7, ahMapID, AHB_BLUE, param2); + } + else if (strncmp(param1,"purple",l) == 0) + { + AuctionHouseBotCommands(7, ahMapID, AHB_PURPLE, param2); + } + else + { + PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + return false; + } + } + else if (strncmp(opt,"minbidprice",l) == 0) + { + char * param1 = strtok(NULL, " "); + char * param2 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1) || (!param2)) + { + PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + return false; + } + uint32 minBidPrice = (uint32) strtoul(param2, NULL, 0); + if ((minBidPrice < 1) || (minBidPrice > 100)) + { + PSendSysMessage("The min bid price multiplier must be between 1 and 100"); + return false; + } + if (strncmp(param1,"white",l) == 0) + { + AuctionHouseBotCommands(8, ahMapID, AHB_WHITE, param2); + } + else if (strncmp(param1,"green",l) == 0) + { + AuctionHouseBotCommands(8, ahMapID, AHB_GREEN, param2); + } + else if (strncmp(param1,"blue",l) == 0) + { + AuctionHouseBotCommands(8, ahMapID, AHB_BLUE, param2); + } + else if (strncmp(param1,"purple",l) == 0) + { + AuctionHouseBotCommands(8, ahMapID, AHB_PURPLE, param2); + } + else + { + PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + return false; + } + } + else if (strncmp(opt,"maxbidprice",l) == 0) + { + char * param1 = strtok(NULL, " "); + char * param2 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1) || (!param2)) + { + PSendSysMessage("Syntax is: ahbotoptions maxbidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + return false; + } + uint32 maxBidPrice = (uint32) strtoul(param2, NULL, 0); + if ((maxBidPrice < 1) || (maxBidPrice > 100)) + { + PSendSysMessage("The max bid price multiplier must be between 1 and 100"); + return false; + } + if (strncmp(param1,"white",l) == 0) + { + AuctionHouseBotCommands(9, ahMapID, AHB_WHITE, param2); + } + else if (strncmp(param1,"green",l) == 0) + { + AuctionHouseBotCommands(9, ahMapID, AHB_GREEN, param2); + } + else if (strncmp(param1,"blue",l) == 0) + { + AuctionHouseBotCommands(9, ahMapID, AHB_BLUE, param2); + } + else if (strncmp(param1,"purple",l) == 0) + { + AuctionHouseBotCommands(9, ahMapID, AHB_PURPLE, param2); + } + else + { + PSendSysMessage("Syntax is: ahbotoptions max bidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + return false; + } + } + else if (strncmp(opt,"maxstack",l) == 0) + { + char * param1 = strtok(NULL, " "); + char * param2 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1) || (!param2)) + { + PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $value"); + return false; + } + uint32 maxStack = (uint32) strtoul(param2, NULL, 0); + if (maxStack < 0) + { + PSendSysMessage("maxstack can't be a negative number."); + return false; + } + if (strncmp(param1,"white",l) == 0) + { + AuctionHouseBotCommands(10, ahMapID, AHB_WHITE, param2); + } + else if (strncmp(param1,"green",l) == 0) + { + AuctionHouseBotCommands(10, ahMapID, AHB_GREEN, param2); + } + else if (strncmp(param1,"blue",l) == 0) + { + AuctionHouseBotCommands(10, ahMapID, AHB_BLUE, param2); + } + else if (strncmp(param1,"purple",l) == 0) + { + AuctionHouseBotCommands(10, ahMapID, AHB_PURPLE, param2); + } + else + { + PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $value"); + return false; + } + } + else if (strncmp(opt,"buyerprice",l) == 0) + { + char * param1 = strtok(NULL, " "); + char * param2 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1) || (!param2)) + { + PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price"); + return false; + } + if (strncmp(param1,"white",l) == 0) + { + AuctionHouseBotCommands(11, ahMapID, AHB_WHITE, param2); + } + else if (strncmp(param1,"green",l) == 0) + { + AuctionHouseBotCommands(11, ahMapID, AHB_GREEN, param2); + } + else if (strncmp(param1,"blue",l) == 0) + { + AuctionHouseBotCommands(11, ahMapID, AHB_BLUE, param2); + } + else if (strncmp(param1,"purple",l) == 0) + { + AuctionHouseBotCommands(11, ahMapID, AHB_PURPLE, param2); + } + else + { + PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price"); + return false; + } + } + else if (strncmp(opt,"bidinterval",l) == 0) + { + char * param1 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1)) + { + PSendSysMessage("Syntax is: ahbotoptions bidinterval $ahMapID (2, 6 or 7) $interval(in minutes)"); + return false; + } + AuctionHouseBotCommands(12, ahMapID, NULL, param1); + } + else if (strncmp(opt,"bidsperinterval",l) == 0) + { + char * param1 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param1)) + { + PSendSysMessage("Syntax is: ahbotoptions bidsperinterval $ahMapID (2, 6 or 7) $bids"); + return false; + } + AuctionHouseBotCommands(13, ahMapID, NULL, param1); + } + else + { + PSendSysMessage("Syntax is: ahbotoptions $option $ahMapID (2, 6 or 7) $parameter"); + PSendSysMessage("Try ahbotoptions help to see a list of options."); + return false; + } + return true; +} //reload commands bool ChatHandler::HandleReloadCommand(const char* arg) diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 00211094d4e..48bf94c4411 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -30,6 +30,7 @@ #include "Unit.h" #include "Language.h" #include "Database/DBCStores.h" +#include "AuctionHouseBot.h" void MailItem::deleteItem( bool inDB ) { @@ -348,7 +349,14 @@ void WorldSession::HandleReturnToSender(WorldPacket & recv_data ) } } - SendReturnToSender(MAIL_NORMAL, GetAccountId(), m->receiver, m->sender, m->subject, m->itemTextId, &mi, m->money, m->mailTemplateId); + if (m->sender == AHBplayerGUID) + { + SendReturnToSender(MAIL_CREATURE, GetAccountId(), m->receiver, m->sender, m->subject, m->itemTextId, &mi, m->money, m->mailTemplateId); + } + else + { + SendReturnToSender(MAIL_NORMAL, GetAccountId(), m->receiver, m->sender, m->subject, m->itemTextId, &mi, m->money, m->mailTemplateId); + } delete m; //we can deallocate old mail pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, 0); @@ -765,6 +773,14 @@ void WorldSession::HandleMsgQueryNextMailtime(WorldPacket & /*recv_data*/ ) void WorldSession::SendMailTo(Player* receiver, uint8 messageType, uint8 stationery, uint32 sender_guidlow_or_entry, uint32 receiver_guidlow, std::string subject, uint32 itemTextId, MailItemsInfo* mi, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay, uint16 mailTemplateId) { + if (receiver_guidlow == AHBplayerGUID) + { + if(messageType == MAIL_AUCTION && mi) // auction mail with items + { + mi->deleteIncludedItems(true); + } + return; + } uint32 mailId = objmgr.GenerateMailID(); time_t deliver_time = time(NULL) + deliver_delay; diff --git a/src/game/World.cpp b/src/game/World.cpp index 6865421a326..6aeed36f0f7 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -50,6 +50,7 @@ #include "BattleGroundMgr.h" #include "OutdoorPvPMgr.h" #include "TemporarySummon.h" +#include "AuctionHouseBot.h" #include "WaypointMovementGenerator.h" #include "VMapFactory.h" #include "GlobalEvents.h" @@ -1379,6 +1380,9 @@ void World::SetInitialWorldSettings() uint32 nextGameEvent = gameeventmgr.Initialize(); m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event + sLog.outString("Initialize AuctionHouseBot..."); + AuctionHouseBotInit(); + sLog.outString( "WORLD: World initialized" ); } @@ -1489,7 +1493,8 @@ void World::Update(time_t diff) ///
  • Handle auctions when the timer has passed if (m_timers[WUPDATE_AUCTIONS].Passed()) { - m_timers[WUPDATE_AUCTIONS].Reset(); + AuctionHouseBot(); + m_timers[WUPDATE_AUCTIONS].Reset(); ///- Update mails (return old mails with item, or delete them) //(tested... works on win) diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist index 7da04b0bdf6..e9f673d59cf 100644 --- a/src/trinitycore/trinitycore.conf.dist +++ b/src/trinitycore/trinitycore.conf.dist @@ -1188,6 +1188,79 @@ Network.OutKBuff = -1 Network.OutUBuff = 65536 Network.TcpNodelay = 1 +################################################################################################################### +# AUCTION HOUSE BOT SETTINGS +# +# AuctionHouseBot.EnableSeller +# Enable/Disable the part of AHBot that puts items up for auction +# Default 0 (disabled) +# +# AuctionHouseBot.EnableBuyer +# Enable/Disable the part of AHBot that buys items from players +# Default 0 (disabled) +# +# Auction House Bot character data +# AuctionHouseBot.Account is the account number (in realmd->account table) of the player you want to run as the auction bot. +# AuctionHouseBot.GUID is the GUID (in characters->characters table) of the player you want to run as the auction bot. +# Default: 0 (Auction House Bot disabled) +# +# AuctionHouseBot.VendorItems +# Include items that can be bought from vendors. +# Default 0 +# +# AuctionHouseBot.LootItems +# Include items that can be looted or fished for. +# Default 1 +# +# AuctionHouseBot.OtherItems +# Include misc. items. +# Default 0 +# +# AuctionHouseBot.Bonding_types +# Indicates which bonding types to allow seller to put up for auction +# No_Bind +# Default 1 +# Bind_When_Picked_Up +# Default 0 +# Bind_When_Equipped +# Default 1 +# Bind_When_Use +# Default 1 +# Bind_Quest_Item +# Default 0 +# +# AuctionHouseBot.ItemsPerCycle +# Number of Items to Add/Remove from the AH during mass operations +# Default 200 +# +# AuctionHouseBot.UseBuyPriceForSeller +# Should the Seller use BuyPrice or SellPrice to determine Bid Prices +# Default 0 (use SellPrice) +# +# AuctionHouseBot.UseBuyPriceForBuyer +# Should the Buyer use BuyPrice or SellPrice to determine Bid Prices +# Default 0 (use SellPrice) +# +# All other settings have been moved to sql +# +################################################################################################################### + +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 + ################################################################################################################### # CONSOLE AND REMOTE ACCESS # diff --git a/win/VC71/game.vcproj b/win/VC71/game.vcproj index e31da7f78f8..624c8faf90c 100644 --- a/win/VC71/game.vcproj +++ b/win/VC71/game.vcproj @@ -199,6 +199,16 @@ > + + + + + + @@ -214,6 +224,12 @@ RelativePath="..\..\src\game\AuctionHouseObject.h" > + + + + diff --git a/win/VC80/game.vcproj b/win/VC80/game.vcproj index 75a9932fe13..94d3b0886ac 100644 --- a/win/VC80/game.vcproj +++ b/win/VC80/game.vcproj @@ -419,6 +419,16 @@ > + + + + + + @@ -430,6 +440,12 @@ RelativePath="..\..\src\game\ArenaTeam.h" > + + + + diff --git a/win/VC90/game.vcproj b/win/VC90/game.vcproj index 9a59a5fa8f6..2f4b29ea3b8 100644 --- a/win/VC90/game.vcproj +++ b/win/VC90/game.vcproj @@ -424,6 +424,16 @@ > + + + + + + -- cgit v1.2.3 From ceb46a8f16dfdc8fff9f37e76ac198bba4fb0516 Mon Sep 17 00:00:00 2001 From: Blaymoira Date: Thu, 22 Jan 2009 21:20:21 +0100 Subject: *Convert text to database in barrens --HG-- branch : trunk --- sql/updates/951_world_scripts.sql | 16 ++ sql/updates/CMakeLists.txt | 1 + .../scripts/scripts/zone/barrens/the_barrens.cpp | 163 ++++++++++++--------- src/trinitycore/trinitycore.conf.dist | 2 +- 4 files changed, 113 insertions(+), 69 deletions(-) create mode 100644 sql/updates/951_world_scripts.sql (limited to 'src/trinitycore') diff --git a/sql/updates/951_world_scripts.sql b/sql/updates/951_world_scripts.sql new file mode 100644 index 00000000000..39208672b32 --- /dev/null +++ b/sql/updates/951_world_scripts.sql @@ -0,0 +1,16 @@ +DELETE FROM script_texts WHERE entry BETWEEN -1000279 and -1000267; +INSERT INTO script_texts (entry, content_default, type, comment) VALUES +(-1000267, 'Ready when you are, warrior.', 1, 'flathead - SAY_BIG_WILL_READY'), +(-1000268, 'The Affray has begun, get ready to fight!', 1, 'flathead - SAY_TWIGGY_FLATHEAD_BEGIN'), +(-1000269, 'You! Enter the fray!', 1, 'flathead - SAY_TWIGGY_FLATHEAD_FRAY'), +(-1000270, 'Challenger is down!', 1, 'flathead - SAY_TWIGGY_FLATHEAD_DOWN'), +(-1000271, 'The Affray is over.', 1, 'flathead - SAY_TWIGGY_FLATHEAD_OVER'), + +(-1000272, 'Alright, alright I think I can figure out how to operate this thing...', 0, 'shredder - SAY_PROGRESS_1'), +(-1000273, 'Arrrgh! This isn\'t right!', 0, 'shredder - SAY_PROGRESS_2'), +(-1000274, 'Okay, I think I\'ve got it, now. Follow me, $N!', 0, 'shredder - SAY_PROGRESS_3'), +(-1000275, 'There\'s the stolen shredder! Stop it or Lugwizzle will have our hides!', 1, 'shredder - SAY_MERCENARY_4'), +(-1000276, 'Looks like we\'re out of woods, eh? Wonder what this does...', 0, 'shredder - SAY_PROGRESS_5'), +(-1000277, 'Come on, don\'t break down on me now!', 0, 'shredder - SAY_PROGRESS_6'), +(-1000278, 'That was a close one! Well, let\'s get going, it\'s still a ways to Ratchet!', 0, 'shredder - SAY_PROGRESS_7'), +(-1000279, 'Hmm... I don\'t think this blinking red light is a good thing...', 0, 'shredder - SAY_PROGRESS_8'); \ No newline at end of file diff --git a/sql/updates/CMakeLists.txt b/sql/updates/CMakeLists.txt index c2531a3df68..538e2f80bff 100644 --- a/sql/updates/CMakeLists.txt +++ b/sql/updates/CMakeLists.txt @@ -150,4 +150,5 @@ INSTALL(FILES 947_world_scripts.sql 948_world_scripts.sql 950_world_scripts.sql +951_world_scripts.sql DESTINATION share/trinity/sql/updates) diff --git a/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp b/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp index 24f4d134464..c7853b37705 100644 --- a/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp +++ b/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp @@ -36,12 +36,14 @@ EndContentData */ ## npc_beaten_corpse ######*/ +#define GOSSIP_CORPSE "Examine corpse in detail..." + bool GossipHello_npc_beaten_corpse(Player *player, Creature *_Creature) { if( player->GetQuestStatus(4921) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(4921) == QUEST_STATUS_COMPLETE) - player->ADD_GOSSIP_ITEM(0,"Examine corpse in detail...",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM(0, GOSSIP_CORPSE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(3557,_Creature->GetGUID()); + player->SEND_GOSSIP_MENU(3557, _Creature->GetGUID()); return true; } @@ -49,7 +51,7 @@ bool GossipSelect_npc_beaten_corpse(Player *player, Creature *_Creature, uint32 { if(action == GOSSIP_ACTION_INFO_DEF +1) { - player->SEND_GOSSIP_MENU(3558,_Creature->GetGUID()); + player->SEND_GOSSIP_MENU(3558, _Creature->GetGUID()); player->KilledMonster( 10668,_Creature->GetGUID() ); } return true; @@ -59,15 +61,17 @@ bool GossipSelect_npc_beaten_corpse(Player *player, Creature *_Creature, uint32 ## npc_sputtervalve ######*/ +#define GOSSIP_SPUTTERVALVE "Can you tell me about this shard?" + bool GossipHello_npc_sputtervalve(Player *player, Creature *_Creature) { if (_Creature->isQuestGiver()) player->PrepareQuestMenu( _Creature->GetGUID() ); if( player->GetQuestStatus(6981) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(0,"Can you tell me about this shard?",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(0, GOSSIP_SPUTTERVALVE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); return true; } @@ -75,7 +79,7 @@ bool GossipSelect_npc_sputtervalve(Player *player, Creature *_Creature, uint32 s { if(action == GOSSIP_ACTION_INFO_DEF) { - player->SEND_GOSSIP_MENU(2013,_Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2013, _Creature->GetGUID()); player->AreaExploredOrEventHappens(6981); } return true; @@ -85,7 +89,7 @@ bool GossipSelect_npc_sputtervalve(Player *player, Creature *_Creature, uint32 s ## npc_taskmaster_fizzule ######*/ -//#define FACTION_HOSTILE_F 430 +//#define FACTION_HOSTILE_F 430 #define FACTION_HOSTILE_F 16 #define FACTION_FRIENDLY_F 35 @@ -173,11 +177,11 @@ bool ReciveEmote_npc_taskmaster_fizzule(Player *player, Creature *_Creature, uin #define BIG_WILL 6238 #define AFFRAY_CHALLENGER 6240 -#define SAY_BIG_WILL_READY "Ready when you are, warrior" -#define SAY_TWIGGY_FLATHEAD_BEGIN "The Affray has begun, get ready to fight!" -#define SAY_TWIGGY_FLATHEAD_FRAY "You! Enter the fray!" -#define SAY_TWIGGY_FLATHEAD_DOWN "Challenger is down!" -#define SAY_TWIGGY_FLATHEAD_OVER "The Affray is over" +#define SAY_BIG_WILL_READY -1000267 +#define SAY_TWIGGY_FLATHEAD_BEGIN -1000268 +#define SAY_TWIGGY_FLATHEAD_FRAY -1000269 +#define SAY_TWIGGY_FLATHEAD_DOWN -1000270 +#define SAY_TWIGGY_FLATHEAD_OVER -1000271 float AffrayChallengerLoc[6][4]= { @@ -214,7 +218,8 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI Wave = 0; PlayerGUID = 0; - for(uint8 i = 0; i < 6; i++) { + for(uint8 i = 0; i < 6; ++i) + { AffrayChallenger[i] = 0; Challenger_down[i] = false; } @@ -249,14 +254,17 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI if(!pWarrior->isAlive() && pWarrior->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE) { EventInProgress = false; - DoYell(SAY_TWIGGY_FLATHEAD_DOWN,LANG_UNIVERSAL,NULL); + DoScriptText(SAY_TWIGGY_FLATHEAD_DOWN, m_creature); pWarrior->FailQuest(1719); - for(uint8 i = 0; i < 6; i++) { - if (AffrayChallenger[i]) { + for(uint8 i = 0; i < 6; ++i) + { + if (AffrayChallenger[i]) + { Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), AffrayChallenger[i]); if(pCreature) { - if(pCreature->isAlive()) { + if(pCreature->isAlive()) + { pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); pCreature->setDeathState(JUST_DIED); @@ -267,7 +275,8 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI Challenger_down[i] = false; } - if (BigWill) { + if (BigWill) + { Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), BigWill); if(pCreature) { if(pCreature->isAlive()) { @@ -280,22 +289,24 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI BigWill = 0; } - if (!EventGrate && EventInProgress) { + if (!EventGrate && EventInProgress) + { float x,y,z; pWarrior->GetPosition(x, y, z); if (x >= -1684 && x <= -1674 && y >= -4334 && y <= -4324) { pWarrior->AreaExploredOrEventHappens(1719); - DoYell(SAY_TWIGGY_FLATHEAD_BEGIN,LANG_UNIVERSAL,NULL); + DoScriptText(SAY_TWIGGY_FLATHEAD_BEGIN, m_creature); - for(uint8 i = 0; i < 6; i++) { + for(uint8 i = 0; i < 6; ++i) + { Creature* pCreature = m_creature->SummonCreature(AFFRAY_CHALLENGER, AffrayChallengerLoc[i][0], AffrayChallengerLoc[i][1], AffrayChallengerLoc[i][2], AffrayChallengerLoc[i][3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); if(!pCreature) continue; pCreature->setFaction(35); pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - pCreature->HandleEmoteCommand(15); + pCreature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); AffrayChallenger[i] = pCreature->GetGUID(); } Wave_Timer = 5000; @@ -303,13 +314,18 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI EventGrate = true; } } - else if (EventInProgress) { - if (Challenger_checker < diff) { - for(uint8 i = 0; i < 6; i++) { - if (AffrayChallenger[i]) { + else if (EventInProgress) + { + if (Challenger_checker < diff) + { + for(uint8 i = 0; i < 6; ++i) + { + if (AffrayChallenger[i]) + { Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), AffrayChallenger[i]); - if((!pCreature || (!pCreature->isAlive())) && !Challenger_down[i]) { - DoYell(SAY_TWIGGY_FLATHEAD_DOWN,LANG_UNIVERSAL,NULL); + if((!pCreature || (!pCreature->isAlive())) && !Challenger_down[i]) + { + DoScriptText(SAY_TWIGGY_FLATHEAD_DOWN, m_creature); Challenger_down[i] = true; } } @@ -317,17 +333,20 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI Challenger_checker = 1000; } else Challenger_checker -= diff; - if(Wave_Timer < diff) { - if (AffrayChallenger[Wave] && Wave < 6 && !EventBigWill) { - DoYell(SAY_TWIGGY_FLATHEAD_FRAY,LANG_UNIVERSAL,NULL); + if(Wave_Timer < diff) + { + if (AffrayChallenger[Wave] && Wave < 6 && !EventBigWill) + { + DoScriptText(SAY_TWIGGY_FLATHEAD_FRAY, m_creature); Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), AffrayChallenger[Wave]); - if(pCreature && (pCreature->isAlive())) { + if(pCreature && (pCreature->isAlive())) + { pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - pCreature->HandleEmoteCommand(15); + pCreature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); pCreature->setFaction(14); ((CreatureAI*)pCreature->AI())->AttackStart(pWarrior); - Wave++; + ++Wave; Wave_Timer = 20000; } } @@ -338,16 +357,18 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI //pCreature->GetMotionMaster()->MovePoint(0, -1693, -4343, 4.32); //pCreature->GetMotionMaster()->MovePoint(1, -1684, -4333, 2.78); pCreature->GetMotionMaster()->MovePoint(2, -1682, -4329, 2.79); - //pCreature->HandleEmoteCommand(15); - pCreature->HandleEmoteCommand(27); + //pCreature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); + pCreature->HandleEmoteCommand(EMOTE_STATE_READYUNARMED); EventBigWill = true; Wave_Timer = 1000; } } - else if (Wave >= 6 && EventBigWill && BigWill) { + else if (Wave >= 6 && EventBigWill && BigWill) + { Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), BigWill); - if (!pCreature || !pCreature->isAlive()) { - DoYell(SAY_TWIGGY_FLATHEAD_OVER,LANG_UNIVERSAL,NULL); + if (!pCreature || !pCreature->isAlive()) + { + DoScriptText(SAY_TWIGGY_FLATHEAD_OVER, m_creature); EventInProgress = false; EventBigWill = false; EventGrate = false; @@ -360,25 +381,26 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI } } }; + CreatureAI* GetAI_npc_twiggy_flathead(Creature *_Creature) { return new npc_twiggy_flatheadAI (_Creature); } /*##### -## npc_wizzlecrank_shredder NOTE: Part2 will be in ACID +## npc_wizzlecrank_shredder #####*/ -#define SAY_PROGRESS_1 "Alright, alright I think I can figure out how to operate this thing..." -#define SAY_PROGRESS_2 "Arrrgh! This isn't right!" -#define SAY_PROGRESS_3 "Okay, I think I've got it, now. Follow me, $N!" +#define SAY_PROGRESS_1 -1000272 +#define SAY_PROGRESS_2 -1000273 +#define SAY_PROGRESS_3 -1000274 -#define SAY_MERCENARY_4 "There's the stolen shredder! Stop it or Lugwizzle will have our hides!" +#define SAY_MERCENARY_4 -1000275 -#define SAY_PROGRESS_5 "Looks like we're out of woods, eh? Wonder what this does..." -#define SAY_PROGRESS_6 "Come on, don't break down on me now!" -#define SAY_PROGRESS_7 "That was a close one! Well, let's get going, it's still a ways to Ratchet!" -#define SAY_PROGRESS_8 "Hmm... I don't think this blinking red light is a good thing..." +#define SAY_PROGRESS_5 -1000276 +#define SAY_PROGRESS_6 -1000277 +#define SAY_PROGRESS_7 -1000278 +#define SAY_PROGRESS_8 -1000279 #define QUEST_ESCAPE 863 #define NPC_PILOT 3451 @@ -388,6 +410,8 @@ struct TRINITY_DLL_DECL npc_wizzlecrank_shredderAI : public npc_escortAI { npc_wizzlecrank_shredderAI(Creature* c) : npc_escortAI(c) {Reset();} + bool Completed; + void WaypointReached(uint32 i) { Unit* player = Unit::GetUnit((*m_creature), PlayerGUID); @@ -397,27 +421,28 @@ struct TRINITY_DLL_DECL npc_wizzlecrank_shredderAI : public npc_escortAI switch(i) { - case 0: DoSay(SAY_PROGRESS_1, LANG_UNIVERSAL, NULL); + case 0: DoScriptText(SAY_PROGRESS_1, m_creature); m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); break; - case 1: DoSay(SAY_PROGRESS_2, LANG_UNIVERSAL, NULL); break; - case 10: DoSay(SAY_PROGRESS_3, LANG_UNIVERSAL, player); + case 1: DoScriptText(SAY_PROGRESS_2, m_creature); break; + case 10: DoScriptText(SAY_PROGRESS_3, m_creature, player); m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); break; case 20:{ Unit* Mercenary = FindCreature(MOB_MERCENARY, 99); if(Mercenary) { - ((Creature*)Mercenary)->Yell(SAY_MERCENARY_4, LANG_UNIVERSAL, NULL); + DoScriptText(SAY_MERCENARY_4, Mercenary); ((Creature*)Mercenary)->AI()->AttackStart(m_creature); AttackStart(Mercenary); } }break; - case 21: DoSay(SAY_PROGRESS_5, LANG_UNIVERSAL, NULL); + case 21: DoScriptText(SAY_PROGRESS_5, m_creature); m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); break; - case 28: DoSay(SAY_PROGRESS_6, LANG_UNIVERSAL, NULL); break; - case 29: DoSay(SAY_PROGRESS_7, LANG_UNIVERSAL, NULL); break; - case 30: DoSay(SAY_PROGRESS_8, LANG_UNIVERSAL, NULL); break; + case 28: DoScriptText(SAY_PROGRESS_6, m_creature); break; + case 29: DoScriptText(SAY_PROGRESS_7, m_creature); break; + case 30: DoScriptText(SAY_PROGRESS_8, m_creature); break; case 31: m_creature->SummonCreature(NPC_PILOT, 1088.77, -2985.39, 91.84, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 300000); m_creature->setDeathState(JUST_DIED); + Completed = true; if (player && player->GetTypeId() == TYPEID_PLAYER) ((Player*)player)->GroupEventHappens(QUEST_ESCAPE, m_creature); break; @@ -427,13 +452,15 @@ struct TRINITY_DLL_DECL npc_wizzlecrank_shredderAI : public npc_escortAI void Reset() { m_creature->setDeathState(ALIVE); + Completed = false; + m_creature->setFaction(69); } void Aggro(Unit* who){} void JustDied(Unit* killer) { - if (PlayerGUID) + if (PlayerGUID && !Completed) { Unit* player = Unit::GetUnit((*m_creature), PlayerGUID); if (player) @@ -461,8 +488,8 @@ CreatureAI* GetAI_npc_wizzlecrank_shredderAI(Creature *_Creature) { npc_wizzlecrank_shredderAI* thisAI = new npc_wizzlecrank_shredderAI(_Creature); - thisAI->AddWaypoint(0, 1109.15, -3104.11, 82.41, 6000);//say1 spw - thisAI->AddWaypoint(1, 1105.39, -3102.86, 82.74, 2000);//say2 crazy running + thisAI->AddWaypoint(0, 1109.15, -3104.11, 82.41, 6000); + thisAI->AddWaypoint(1, 1105.39, -3102.86, 82.74, 2000); thisAI->AddWaypoint(2, 1104.97, -3108.52, 83.10, 1000); thisAI->AddWaypoint(3, 1110.01, -3110.48, 82.81, 1000); thisAI->AddWaypoint(4, 1111.72, -3103.03, 82.21, 1000); @@ -471,7 +498,7 @@ CreatureAI* GetAI_npc_wizzlecrank_shredderAI(Creature *_Creature) thisAI->AddWaypoint(7, 1112.55, -3106.56, 82.31, 1000); thisAI->AddWaypoint(8, 1108.12, -3111.04, 82.99, 1000); thisAI->AddWaypoint(9, 1109.32, -3100.39, 82.08, 1000); - thisAI->AddWaypoint(10, 1109.32, -3100.39, 82.08, 6000);//end of crazy running + thisAI->AddWaypoint(10, 1109.32, -3100.39, 82.08, 6000); thisAI->AddWaypoint(11, 1098.92, -3095.14, 82.97); thisAI->AddWaypoint(12, 1100.94, -3082.60, 82.83); thisAI->AddWaypoint(13, 1101.12, -3068.83, 82.53); @@ -480,19 +507,19 @@ CreatureAI* GetAI_npc_wizzlecrank_shredderAI(Creature *_Creature) thisAI->AddWaypoint(16, 1098.22, -3027.84, 83.79); thisAI->AddWaypoint(17, 1109.51, -3015.92, 85.73); thisAI->AddWaypoint(18, 1119.87, -3007.21, 87.08); - thisAI->AddWaypoint(19, 1130.23, -3002.49, 91.27, 5000);//twice - thisAI->AddWaypoint(20, 1130.23, -3002.49, 91.27, 3000);//mercenary - thisAI->AddWaypoint(21, 1130.23, -3002.49, 91.27, 4000);//say - thisAI->AddWaypoint(22, 1129.73, -2985.89, 92.46);//crazy running + thisAI->AddWaypoint(19, 1130.23, -3002.49, 91.27, 5000); + thisAI->AddWaypoint(20, 1130.23, -3002.49, 91.27, 3000); + thisAI->AddWaypoint(21, 1130.23, -3002.49, 91.27, 4000); + thisAI->AddWaypoint(22, 1129.73, -2985.89, 92.46); thisAI->AddWaypoint(23, 1124.10, -2983.29, 92.81); thisAI->AddWaypoint(24, 1111.74, -2992.38, 91.59); thisAI->AddWaypoint(25, 1111.06, -2976.54, 91.81); thisAI->AddWaypoint(26, 1099.91, -2991.17, 91.67); thisAI->AddWaypoint(27, 1096.32, -2981.55, 91.73); - thisAI->AddWaypoint(28, 1091.28, -2985.82, 91.74, 4000);//6 - thisAI->AddWaypoint(29, 1091.28, -2985.82, 91.74, 3000);//7 - thisAI->AddWaypoint(30, 1091.28, -2985.82, 91.74, 7000);//8 - thisAI->AddWaypoint(31, 1091.28, -2985.82, 91.74, 3000);//justdied summon creature + thisAI->AddWaypoint(28, 1091.28, -2985.82, 91.74, 4000); + thisAI->AddWaypoint(29, 1091.28, -2985.82, 91.74, 3000); + thisAI->AddWaypoint(30, 1091.28, -2985.82, 91.74, 7000); + thisAI->AddWaypoint(31, 1091.28, -2985.82, 91.74, 3000); return (CreatureAI*)thisAI; } diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist index e9f673d59cf..c2e58216a86 100644 --- a/src/trinitycore/trinitycore.conf.dist +++ b/src/trinitycore/trinitycore.conf.dist @@ -1,7 +1,7 @@ ########################################## # Trinity Core worldd configuration file # ########################################## -ConfVersion=2008080101 +ConfVersion=2009010301 ################################################################################################################### # CONNECTIONS AND DIRECTORIES -- cgit v1.2.3