mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-13 01:08:37 +00:00
Make AuctionHouseBot completely driven by config
This commit is contained in:
@@ -36,6 +36,34 @@ AuctionHouseBot.Account = 14
|
||||
AuctionHouseBot.GUID = 3
|
||||
AuctionHouseBot.ItemsPerCycle = 50
|
||||
|
||||
###############################################################################
|
||||
# AuctionHouseBot.<faction>.MinItems
|
||||
# AuctionHouseBot.<faction>.MaxItems
|
||||
# The minimum and maximum number of items to post on that auction house
|
||||
# Default: 15000 for both
|
||||
#
|
||||
# AuctionHouseBot.<faction>.BidInterval
|
||||
# How long to wait between bidding
|
||||
# Default: 1
|
||||
#
|
||||
# AuctionHouseBot.<faction>.BidInterval
|
||||
# How many to bid on at a time
|
||||
# Default: 1
|
||||
###############################################################################
|
||||
|
||||
AuctionHouseBot.Alliance.MinItems = 20000
|
||||
AuctionHouseBot.Alliance.MaxItems = 20000
|
||||
AuctionHouseBot.Alliance.BidInterval = 1
|
||||
AuctionHouseBot.Alliance.BidsPerInterval = 1
|
||||
AuctionHouseBot.Horde.MinItems = 20000
|
||||
AuctionHouseBot.Horde.MaxItems = 20000
|
||||
AuctionHouseBot.Horde.BidInterval = 1
|
||||
AuctionHouseBot.Horde.BidsPerInterval = 1
|
||||
AuctionHouseBot.Neutral.MinItems = 20000
|
||||
AuctionHouseBot.Neutral.MaxItems = 20000
|
||||
AuctionHouseBot.Neutral.BidInterval = 1
|
||||
AuctionHouseBot.Neutral.BidsPerInterval = 1
|
||||
|
||||
###############################################################################
|
||||
# AuctionHouseBot.RandomStackRatio.*
|
||||
# Used to determine how often a stack of the class will be single or randomly-size stacked when posted
|
||||
@@ -76,6 +104,12 @@ AuctionHouseBot.RandomStackRatio.Key = 10
|
||||
AuctionHouseBot.RandomStackRatio.Misc = 100
|
||||
AuctionHouseBot.RandomStackRatio.Glyph = 0
|
||||
|
||||
###############################################################################
|
||||
# AuctionHouseBot.PrimaryProfTradeGoodRelativeMultiplier
|
||||
# This is
|
||||
# Default: 15000 for both
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# AuctionHouseBot.DisabledItemTextFilter
|
||||
# If true, this will hide items with bad names like "OLD" and "D'Sak"
|
||||
@@ -84,6 +118,7 @@ AuctionHouseBot.RandomStackRatio.Glyph = 0
|
||||
# AuctionHouseBot.DisabledItemIDs
|
||||
# Comma separated list of itemIDs to exclude from listing by the seller
|
||||
# Ranges using a dash (-) can also be used
|
||||
#
|
||||
# AuctionHouseBot.DisabledCraftedItemIDs
|
||||
# Additional Comma separated list of itemIDs to exclude from listing by the seller
|
||||
# Ranges using a dash (-) can also be used
|
||||
|
||||
@@ -1,17 +1 @@
|
||||
DROP TABLE IF EXISTS `mod_auctionhousebot`;
|
||||
CREATE TABLE `mod_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.',
|
||||
`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=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
-- AHBot auctionhouse configuration
|
||||
INSERT INTO `mod_auctionhousebot` (`auctionhouse`, `name`, `minitems`, `maxitems`, `buyerbiddinginterval`, `buyerbidsperinterval`)
|
||||
VALUES
|
||||
(2,'Alliance',10000,10000,1,1),
|
||||
(6,'Horde',10000,10000,1,1),
|
||||
(7,'Neutral',10000,10000,1,1);
|
||||
DROP TABLE IF EXISTS `mod_auctionhousebot`;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- Add More Items
|
||||
UPDATE mod_auctionhousebot SET minitems = 15000, maxitems = 15000;
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
* Copyright (C) 2023+ Nathan Handley <https://github.com/NathanHandley>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -182,7 +183,7 @@ void AuctionHouseBot::populateItemClassSeedList()
|
||||
uint32 itemClassSeedWeightArmor = 6;
|
||||
uint32 itemClassSeedWeightReagent = 1;
|
||||
uint32 itemClassSeedWeightProjectile = 2;
|
||||
uint32 itemClassSeedWeightTradeGoods = 14;
|
||||
uint32 itemClassSeedWeightTradeGoods = 22;
|
||||
uint32 itemClassSeedWeightGeneric = 1;
|
||||
uint32 itemClassSeedWeightRecipe = 3;
|
||||
uint32 itemClassSeedWeightQuiver = 1;
|
||||
@@ -248,6 +249,10 @@ void AuctionHouseBot::populateItemCandidateList()
|
||||
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
|
||||
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
|
||||
{
|
||||
// Never store itemID zero
|
||||
if (itr->second.ItemId == 0)
|
||||
continue;
|
||||
|
||||
// Always store items that are exceptions
|
||||
if (includeItemIDExecptions.find(itr->second.ItemId) != includeItemIDExecptions.end())
|
||||
{
|
||||
@@ -394,6 +399,14 @@ void AuctionHouseBot::populateItemCandidateList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (debug_Out)
|
||||
{
|
||||
for (auto& itemCandidatesInClass : itemCandidatesByItemClass)
|
||||
{
|
||||
LOG_INFO("module", "Item count in class {} is {}", itemCandidatesInClass.first, itemCandidatesInClass.second.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
|
||||
@@ -703,14 +716,6 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AuctionHouseBot::addProducedItemsToDisabledItems()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AuctionHouseBot::Update()
|
||||
@@ -761,38 +766,9 @@ void AuctionHouseBot::Update()
|
||||
|
||||
void AuctionHouseBot::Initialize()
|
||||
{
|
||||
//End Filters
|
||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
||||
{
|
||||
LoadValues(&AllianceConfig);
|
||||
LoadValues(&HordeConfig);
|
||||
}
|
||||
LoadValues(&NeutralConfig);
|
||||
|
||||
//
|
||||
// check if the AHBot account/GUID in the config actually exists
|
||||
//
|
||||
|
||||
if ((AHBplayerAccount != 0) || (AHBplayerGUID != 0))
|
||||
{
|
||||
QueryResult result = CharacterDatabase.Query("SELECT 1 FROM characters WHERE account = {} AND guid = {}", AHBplayerAccount, AHBplayerGUID);
|
||||
if (!result)
|
||||
{
|
||||
LOG_ERROR("module", "AuctionHouseBot: The account/GUID-information set for your AHBot is incorrect (account: {} guid: {})", AHBplayerAccount, AHBplayerGUID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (AHBSeller)
|
||||
{
|
||||
// Build a list of items that can be pulled from for auction
|
||||
populateItemClassSeedList();
|
||||
populateItemCandidateList();
|
||||
|
||||
LOG_INFO("module", "AuctionHouseBot:");
|
||||
}
|
||||
|
||||
LOG_INFO("module", "AuctionHouseBot and AuctionHouseBuyer have been loaded.");
|
||||
// Build a list of items that can be pulled from for auction
|
||||
populateItemClassSeedList();
|
||||
populateItemCandidateList();
|
||||
}
|
||||
|
||||
void AuctionHouseBot::InitializeConfiguration()
|
||||
@@ -829,6 +805,33 @@ void AuctionHouseBot::InitializeConfiguration()
|
||||
DisabledItems.clear();
|
||||
AddDisabledItems(sConfigMgr->GetOption<std::string>("AuctionHouseBot.DisabledItemIDs", ""));
|
||||
AddDisabledItems(sConfigMgr->GetOption<std::string>("AuctionHouseBot.DisabledCraftedItemIDs", ""));
|
||||
|
||||
if ((AHBplayerAccount != 0) || (AHBplayerGUID != 0))
|
||||
{
|
||||
QueryResult result = CharacterDatabase.Query("SELECT 1 FROM characters WHERE account = {} AND guid = {}", AHBplayerAccount, AHBplayerGUID);
|
||||
if (!result)
|
||||
{
|
||||
LOG_ERROR("module", "AuctionHouseBot: The account/GUID-information set for your AHBot is incorrect (account: {} guid: {})", AHBplayerAccount, AHBplayerGUID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
||||
{
|
||||
AllianceConfig.SetMinItems(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Alliance.MinItems", 15000));
|
||||
AllianceConfig.SetMaxItems(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Alliance.MaxItems", 15000));
|
||||
AllianceConfig.SetBiddingInterval(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Alliance.BidInterval", 1));
|
||||
AllianceConfig.SetBidsPerInterval(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Alliance.BidsPerInterval", 1));
|
||||
|
||||
HordeConfig.SetMinItems(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Horde.MinItems", 15000));
|
||||
HordeConfig.SetMaxItems(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Horde.MaxItems", 15000));
|
||||
HordeConfig.SetBiddingInterval(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Horde.BidInterval", 1));
|
||||
HordeConfig.SetBidsPerInterval(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Horde.BidsPerInterval", 1));
|
||||
}
|
||||
NeutralConfig.SetMinItems(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Neutral.MinItems", 15000));
|
||||
NeutralConfig.SetMaxItems(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Neutral.MaxItems", 15000));
|
||||
NeutralConfig.SetBiddingInterval(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Neutral.BidInterval", 1));
|
||||
NeutralConfig.SetBidsPerInterval(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Neutral.BidsPerInterval", 1));
|
||||
}
|
||||
|
||||
uint32 AuctionHouseBot::GetRandomStackValue(std::string configKeyString, uint32 defaultValue)
|
||||
@@ -893,111 +896,3 @@ void AuctionHouseBot::AddDisabledItems(std::string disabledItemIdString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, char* args)
|
||||
{
|
||||
AHBConfig *config = NULL;
|
||||
switch (ahMapID)
|
||||
{
|
||||
case 2:
|
||||
config = &AllianceConfig;
|
||||
break;
|
||||
case 6:
|
||||
config = &HordeConfig;
|
||||
break;
|
||||
case 7:
|
||||
config = &NeutralConfig;
|
||||
break;
|
||||
}
|
||||
switch (command)
|
||||
{
|
||||
case 0: //ahexpire
|
||||
{
|
||||
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
|
||||
|
||||
AuctionHouseObject::AuctionEntryMap::iterator itr;
|
||||
itr = auctionHouse->GetAuctionsBegin();
|
||||
|
||||
while (itr != auctionHouse->GetAuctionsEnd())
|
||||
{
|
||||
if (itr->second->owner.GetCounter() == AHBplayerGUID)
|
||||
{
|
||||
itr->second->expire_time = GameTime::GetGameTime().count();
|
||||
uint32 id = itr->second->Id;
|
||||
uint32 expire_time = itr->second->expire_time;
|
||||
CharacterDatabase.Execute("UPDATE auctionhouse SET time = '{}' WHERE id = '{}'", expire_time, id);
|
||||
}
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1: //min items
|
||||
{
|
||||
char * param1 = strtok(args, " ");
|
||||
uint32 minItems = (uint32) strtoul(param1, NULL, 0);
|
||||
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET minitems = '{}' WHERE auctionhouse = '{}'", minItems, ahMapID);
|
||||
config->SetMinItems(minItems);
|
||||
}
|
||||
break;
|
||||
case 2: //max items
|
||||
{
|
||||
char * param1 = strtok(args, " ");
|
||||
uint32 maxItems = (uint32) strtoul(param1, NULL, 0);
|
||||
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET maxitems = '{}' WHERE auctionhouse = '{}'", maxItems, ahMapID);
|
||||
config->SetMaxItems(maxItems);
|
||||
}
|
||||
break;
|
||||
case 12: //buyer bidding interval
|
||||
{
|
||||
char * param1 = strtok(args, " ");
|
||||
uint32 bidInterval = (uint32) strtoul(param1, NULL, 0);
|
||||
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET buyerbiddinginterval = '{}' WHERE auctionhouse = '{}'", bidInterval, ahMapID);
|
||||
config->SetBiddingInterval(bidInterval);
|
||||
}
|
||||
break;
|
||||
case 13: //buyer bids per interval
|
||||
{
|
||||
char * param1 = strtok(args, " ");
|
||||
uint32 bidsPerInterval = (uint32) strtoul(param1, NULL, 0);
|
||||
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET buyerbidsperinterval = '{}' WHERE auctionhouse = '{}'", bidsPerInterval, ahMapID);
|
||||
config->SetBidsPerInterval(bidsPerInterval);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AuctionHouseBot::LoadValues(AHBConfig *config)
|
||||
{
|
||||
if (debug_Out)
|
||||
LOG_ERROR("module", "Start Settings for {} Auctionhouses:", WorldDatabase.Query("SELECT name FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<std::string_view>());
|
||||
|
||||
if (AHBSeller)
|
||||
{
|
||||
//load min and max items
|
||||
config->SetMinItems(WorldDatabase.Query("SELECT minitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
||||
config->SetMaxItems(WorldDatabase.Query("SELECT maxitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
||||
if (debug_Out)
|
||||
{
|
||||
LOG_ERROR("module", "minItems = {}", config->GetMinItems());
|
||||
LOG_ERROR("module", "maxItems = {}", config->GetMaxItems());
|
||||
}
|
||||
}
|
||||
|
||||
if (AHBBuyer)
|
||||
{
|
||||
//load bidding interval
|
||||
config->SetBiddingInterval(WorldDatabase.Query("SELECT buyerbiddinginterval FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
||||
//load bids per interval
|
||||
config->SetBidsPerInterval(WorldDatabase.Query("SELECT buyerbidsperinterval FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
||||
if (debug_Out)
|
||||
{
|
||||
LOG_ERROR("module", "buyerBiddingInterval = {}", config->GetBiddingInterval());
|
||||
LOG_ERROR("module", "buyerBidsPerInterval = {}", config->GetBidsPerInterval());
|
||||
}
|
||||
}
|
||||
|
||||
if (debug_Out)
|
||||
LOG_ERROR("module", "End Settings for {} Auctionhouses:", WorldDatabase.Query("SELECT name FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<std::string>());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
* Copyright (C) 2023+ Nathan Handley <https://github.com/NathanHandley>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -169,7 +170,6 @@ private:
|
||||
void populateItemCandidateList();
|
||||
void addNewAuctions(Player *AHBplayer, AHBConfig *config);
|
||||
void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session);
|
||||
void addProducedItemsToDisabledItems();
|
||||
|
||||
AuctionHouseBot();
|
||||
|
||||
@@ -184,11 +184,9 @@ public:
|
||||
void Update();
|
||||
void Initialize();
|
||||
void InitializeConfiguration();
|
||||
void LoadValues(AHBConfig*);
|
||||
uint32 GetRandomStackValue(std::string configKeyString, uint32 defaultValue);
|
||||
void AddToDisabledItems(std::set<uint32>& workingDisabledItemIDs, uint32 disabledItemID);
|
||||
void AddDisabledItems(std::string disabledItemIdString);
|
||||
void Commands(uint32 command, uint32 ahMapID, char* args);
|
||||
ObjectGuid::LowType GetAHBplayerGUID() { return AHBplayerGUID; };
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class AHBot_WorldScript : public WorldScript
|
||||
public:
|
||||
AHBot_WorldScript() : WorldScript("AHBot_WorldScript") { }
|
||||
|
||||
void OnBeforeConfigLoad(bool /*reload*/) override
|
||||
void OnAfterConfigLoad(bool /*reload*/) override
|
||||
{
|
||||
auctionbot->InitializeConfiguration();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
* Copyright (C) 2021+ WarheadCore <https://github.com/WarheadCore>
|
||||
* Copyright (C) 2023+ Nathan Handley <https://github.com/NathanHandley>
|
||||
*/
|
||||
|
||||
// From SC
|
||||
void AddAHBotCommandScripts();
|
||||
void AddAHBotScripts();
|
||||
|
||||
// Add all
|
||||
void Addmod_ah_botScripts()
|
||||
{
|
||||
AddAHBotCommandScripts();
|
||||
AddAHBotScripts();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user