First Commit
This commit is contained in:
1476
modules/mod-ah-bot/src/AuctionHouseBot.cpp
Normal file
1476
modules/mod-ah-bot/src/AuctionHouseBot.cpp
Normal file
File diff suppressed because it is too large
Load Diff
80
modules/mod-ah-bot/src/AuctionHouseBot.h
Normal file
80
modules/mod-ah-bot/src/AuctionHouseBot.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef AUCTION_HOUSE_BOT_H
|
||||
#define AUCTION_HOUSE_BOT_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "AuctionHouseMgr.h"
|
||||
|
||||
#include "AuctionHouseBotCommon.h"
|
||||
#include "AuctionHouseBotConfig.h"
|
||||
|
||||
struct AuctionEntry;
|
||||
class Player;
|
||||
class WorldSession;
|
||||
|
||||
#define AUCTION_HOUSE_BOT_LOOP_BREAKER 32
|
||||
|
||||
class AuctionHouseBot
|
||||
{
|
||||
private:
|
||||
uint32 _account;
|
||||
uint32 _id;
|
||||
|
||||
AHBConfig* _allianceConfig;
|
||||
AHBConfig* _hordeConfig;
|
||||
AHBConfig* _neutralConfig;
|
||||
|
||||
time_t _lastrun_a_sec;
|
||||
time_t _lastrun_h_sec;
|
||||
time_t _lastrun_n_sec;
|
||||
|
||||
//
|
||||
// Main operations
|
||||
//
|
||||
|
||||
void Sell(Player *AHBplayer, AHBConfig *config);
|
||||
void Buy (Player *AHBplayer, AHBConfig *config, WorldSession *session);
|
||||
|
||||
//
|
||||
// Utilities
|
||||
//
|
||||
|
||||
inline uint32 minValue(uint32 a, uint32 b) { return a <= b ? a : b; };
|
||||
|
||||
uint32 getNofAuctions(AHBConfig* config, AuctionHouseObject* auctionHouse, ObjectGuid guid);
|
||||
uint32 getStackCount(AHBConfig* config, uint32 max);
|
||||
uint32 getElapsedTime(uint32 timeClass);
|
||||
uint32 getElement(std::set<uint32> set, int index, uint32 botId, uint32 maxDup, AuctionHouseObject* auctionHouse);
|
||||
|
||||
public:
|
||||
AuctionHouseBot(uint32 account, uint32 id);
|
||||
~AuctionHouseBot();
|
||||
|
||||
void Initialize(AHBConfig* allianceConfig, AHBConfig* hordeConfig, AHBConfig* neutralConfig);
|
||||
void Update();
|
||||
|
||||
void Commands(AHBotCommand command, uint32 ahMapID, uint32 col, char* args);
|
||||
|
||||
ObjectGuid::LowType GetAHBplayerGUID() { return _id; };
|
||||
};
|
||||
|
||||
#endif // AUCTION_HOUSE_BOT_H
|
||||
288
modules/mod-ah-bot/src/AuctionHouseBotAuctionHouseScript.cpp
Normal file
288
modules/mod-ah-bot/src/AuctionHouseBotAuctionHouseScript.cpp
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#include "AuctionHouseMgr.h"
|
||||
#include "GameTime.h"
|
||||
|
||||
#include "AuctionHouseBot.h"
|
||||
#include "AuctionHouseBotCommon.h"
|
||||
#include "AuctionHouseBotAuctionHouseScript.h"
|
||||
|
||||
AHBot_AuctionHouseScript::AHBot_AuctionHouseScript() : AuctionHouseScript("AHBot_AuctionHouseScript", {
|
||||
AUCTIONHOUSEHOOK_ON_BEFORE_AUCTIONHOUSEMGR_SEND_AUCTION_SUCCESSFUL_MAIL,
|
||||
AUCTIONHOUSEHOOK_ON_BEFORE_AUCTIONHOUSEMGR_SEND_AUCTION_EXPIRED_MAIL,
|
||||
AUCTIONHOUSEHOOK_ON_BEFORE_AUCTIONHOUSEMGR_SEND_AUCTION_OUTBIDDED_MAIL,
|
||||
AUCTIONHOUSEHOOK_ON_AUCTION_ADD,
|
||||
AUCTIONHOUSEHOOK_ON_AUCTION_REMOVE,
|
||||
AUCTIONHOUSEHOOK_ON_AUCTION_SUCCESSFUL,
|
||||
AUCTIONHOUSEHOOK_ON_AUCTION_EXPIRE,
|
||||
AUCTIONHOUSEHOOK_ON_BEFORE_AUCTIONHOUSEMGR_UPDATE
|
||||
})
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(
|
||||
AuctionHouseMgr*, /*auctionHouseMgr*/
|
||||
AuctionEntry*, /*auction*/
|
||||
Player* owner,
|
||||
uint32&, /*owner_accId*/
|
||||
uint32&, /*profit*/
|
||||
bool& sendNotification,
|
||||
bool& updateAchievementCriteria,
|
||||
bool& /*sendMail*/)
|
||||
{
|
||||
if (owner && gBotsId.find(owner->GetGUID().GetCounter()) != gBotsId.end())
|
||||
{
|
||||
sendNotification = false;
|
||||
updateAchievementCriteria = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrSendAuctionExpiredMail(
|
||||
AuctionHouseMgr*, /* auctionHouseMgr */
|
||||
AuctionEntry*, /* auction */
|
||||
Player* owner,
|
||||
uint32&, /* owner_accId */
|
||||
bool& sendNotification,
|
||||
bool& /* sendMail */)
|
||||
{
|
||||
if (owner && gBotsId.find(owner->GetGUID().GetCounter()) != gBotsId.end())
|
||||
{
|
||||
sendNotification = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(
|
||||
AuctionHouseMgr*, /* auctionHouseMgr */
|
||||
AuctionEntry* auction,
|
||||
Player* oldBidder,
|
||||
uint32&, /* oldBidder_accId */
|
||||
Player* newBidder,
|
||||
uint32& newPrice,
|
||||
bool&, /* sendNotification */
|
||||
bool& /* sendMail */)
|
||||
{
|
||||
if (oldBidder && !newBidder)
|
||||
{
|
||||
if (gBotsId.size() > 0)
|
||||
{
|
||||
//
|
||||
// Use a random bot id
|
||||
//
|
||||
|
||||
uint32 randBot = urand(0, gBotsId.size() - 1);
|
||||
std::set<uint32>::iterator it = gBotsId.begin();
|
||||
std::advance(it, randBot);
|
||||
|
||||
oldBidder->GetSession()->SendAuctionBidderNotification(
|
||||
(uint32)auction->GetHouseId(),
|
||||
auction->Id,
|
||||
ObjectGuid::Create<HighGuid::Player>(*it),
|
||||
newPrice,
|
||||
auction->GetAuctionOutBid(),
|
||||
auction->item_template);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AHBot_AuctionHouseScript::OnAuctionAdd(AuctionHouseObject* /*ah*/, AuctionEntry* auction)
|
||||
{
|
||||
//
|
||||
// The the configuration for the auction house
|
||||
//
|
||||
|
||||
AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntryFromHouse(auction->GetHouseId());
|
||||
AHBConfig* config = gNeutralConfig;
|
||||
|
||||
if (ahEntry)
|
||||
{
|
||||
if (AuctionHouseId(ahEntry->houseId) == AuctionHouseId::Alliance)
|
||||
{
|
||||
config = gAllianceConfig;
|
||||
}
|
||||
else if (AuctionHouseId(ahEntry->houseId) == AuctionHouseId::Horde)
|
||||
{
|
||||
config = gHordeConfig;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Consider only those auctions handled by the bots
|
||||
//
|
||||
|
||||
if (config->ConsiderOnlyBotAuctions)
|
||||
{
|
||||
if (gBotsId.find(auction->owner.GetCounter()) != gBotsId.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Verify if we can operate on the item
|
||||
//
|
||||
|
||||
Item* pItem = sAuctionMgr->GetAItem(auction->item_guid);
|
||||
|
||||
if (!pItem)
|
||||
{
|
||||
if (config->DebugOut)
|
||||
{
|
||||
LOG_ERROR("module", "AHBot: Item {} for entryiD={} doesn't exist, perhaps bought already?", auction->item_guid.ToString(), auction->Id);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Keeps updated the amount of items in the auction
|
||||
//
|
||||
|
||||
ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(auction->item_template);
|
||||
|
||||
config->IncItemCounts(prototype->Class, prototype->Quality);
|
||||
|
||||
if (config->DebugOut)
|
||||
{
|
||||
LOG_INFO("module", "AHBot: Auction Added ah={}, auctionId={}, totalAHItems = {}", AuctionHouseId(ahEntry->houseId), auction->Id, config->TotalItemCounts());
|
||||
}
|
||||
}
|
||||
|
||||
// this is called after the auction has been removed from the DB
|
||||
void AHBot_AuctionHouseScript::OnAuctionRemove(AuctionHouseObject* /*ah*/, AuctionEntry* auction)
|
||||
{
|
||||
//
|
||||
// Get the configuration for the auction house
|
||||
//
|
||||
AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntryFromHouse(auction->GetHouseId());
|
||||
AHBConfig* config = gNeutralConfig;
|
||||
|
||||
if (ahEntry)
|
||||
{
|
||||
if (AuctionHouseId(ahEntry->houseId) == AuctionHouseId::Alliance)
|
||||
{
|
||||
config = gAllianceConfig;
|
||||
}
|
||||
else if (AuctionHouseId(ahEntry->houseId) == AuctionHouseId::Horde)
|
||||
{
|
||||
config = gHordeConfig;
|
||||
}
|
||||
}
|
||||
|
||||
// Consider only those auctions handled by the bots
|
||||
if (config->ConsiderOnlyBotAuctions)
|
||||
{
|
||||
if (gBotsId.find(auction->owner.GetCounter()) != gBotsId.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// only get the prototype as actual item has already been removed from server AH in this callback
|
||||
ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(auction->item_template);
|
||||
|
||||
if (prototype)
|
||||
{
|
||||
config->DecItemCounts(prototype->Class, prototype->Quality);
|
||||
if (config->DebugOut)
|
||||
{
|
||||
LOG_INFO("module", "AHBot: Auction removed ah={}, auctionId={}, Bot totalAHItems={}", AuctionHouseId(ahEntry->houseId), auction->Id, config->TotalItemCounts());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// should never happen
|
||||
if (config->DebugOut)
|
||||
{
|
||||
LOG_ERROR("module", "AHBot: Item was removed but no prototype was found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AHBot_AuctionHouseScript::OnAuctionSuccessful(AuctionHouseObject* /*ah*/, AuctionEntry* auction)
|
||||
{
|
||||
//
|
||||
// Get the configuration for the auction house
|
||||
//
|
||||
|
||||
AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntryFromHouse(auction->GetHouseId());
|
||||
AHBConfig* config = gNeutralConfig;
|
||||
|
||||
if (ahEntry)
|
||||
{
|
||||
if (AuctionHouseId(ahEntry->houseId) == AuctionHouseId::Alliance)
|
||||
{
|
||||
config = gAllianceConfig;
|
||||
}
|
||||
else if (AuctionHouseId(ahEntry->houseId) == AuctionHouseId::Horde)
|
||||
{
|
||||
config = gHordeConfig;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If the auction has been won, it means that it has been accepted by the market.
|
||||
// Use the buyout as a reference since the price for the bid is downgraded during selling.
|
||||
//
|
||||
|
||||
if (config->DebugOut)
|
||||
{
|
||||
LOG_INFO("module", "AHBot: Auction successful ah={}, auctionId={}, Bot totalAHItems={}", AuctionHouseId(ahEntry->houseId), auction->Id, config->TotalItemCounts());
|
||||
}
|
||||
|
||||
config->UpdateItemStats(auction->item_template, auction->itemCount, auction->buyout);
|
||||
|
||||
}
|
||||
|
||||
void AHBot_AuctionHouseScript::OnAuctionExpire(AuctionHouseObject* /*ah*/, AuctionEntry* auction)
|
||||
{
|
||||
//
|
||||
// Get the configuration for the auction house
|
||||
//
|
||||
|
||||
if (!auction)
|
||||
{
|
||||
LOG_ERROR("module", "AHBot: AHBot_AuctionHouseScript::OnAuctionExpire invalid AuctionEntry");
|
||||
}
|
||||
|
||||
AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntryFromHouse(auction->GetHouseId());
|
||||
AHBConfig* config = gNeutralConfig;
|
||||
|
||||
if (ahEntry)
|
||||
{
|
||||
if (AuctionHouseId(ahEntry->houseId) == AuctionHouseId::Alliance)
|
||||
{
|
||||
config = gAllianceConfig;
|
||||
}
|
||||
else if (AuctionHouseId(ahEntry->houseId) == AuctionHouseId::Horde)
|
||||
{
|
||||
config = gHordeConfig;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If the auction expired, then it means that the bid was unwanted by the market.
|
||||
// Bid price is usually less or equal to the buyout, so this likely will bring the price down.
|
||||
//
|
||||
|
||||
config->UpdateItemStats(auction->item_template, auction->itemCount, auction->bid);
|
||||
|
||||
if (config->DebugOut)
|
||||
{
|
||||
LOG_INFO("module", "AHBot: Auction Expired ah={}, auctionId={} Bot totalAHItems={}", AuctionHouseId(ahEntry->houseId), auction->Id, config->TotalItemCounts());
|
||||
}
|
||||
}
|
||||
|
||||
void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrUpdate()
|
||||
{
|
||||
//
|
||||
// For every registered bot, perform an update
|
||||
//
|
||||
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Update();
|
||||
}
|
||||
}
|
||||
32
modules/mod-ah-bot/src/AuctionHouseBotAuctionHouseScript.h
Normal file
32
modules/mod-ah-bot/src/AuctionHouseBotAuctionHouseScript.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#ifndef AUCTION_HOUSE_BOT_AUCTION_HOUSE_SCRIPT_H
|
||||
#define AUCTION_HOUSE_BOT_AUCTION_HOUSE_SCRIPT_H
|
||||
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
// =============================================================================
|
||||
// Interaction with the auction house core mechanisms
|
||||
// =============================================================================
|
||||
|
||||
class AHBot_AuctionHouseScript : public AuctionHouseScript
|
||||
{
|
||||
public:
|
||||
AHBot_AuctionHouseScript();
|
||||
|
||||
void OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, uint32& profit, bool& sendNotification, bool& updateAchievementCriteria, bool& sendMail) override;
|
||||
void OnBeforeAuctionHouseMgrSendAuctionExpiredMail (AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, bool& sendNotification, bool& sendMail) override;
|
||||
void OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail (AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* oldBidder, uint32& oldBidder_accId, Player* newBidder, uint32& newPrice, bool& sendNotification, bool& sendMail) override;
|
||||
|
||||
void OnAuctionAdd (AuctionHouseObject* ah, AuctionEntry* auction) override;
|
||||
void OnAuctionRemove (AuctionHouseObject* ah, AuctionEntry* auction) override;
|
||||
void OnAuctionSuccessful(AuctionHouseObject* ah, AuctionEntry* auction) override;
|
||||
void OnAuctionExpire (AuctionHouseObject* ah, AuctionEntry* auction) override;
|
||||
|
||||
void OnBeforeAuctionHouseMgrUpdate() override;
|
||||
};
|
||||
|
||||
#endif /* AUCTION_HOUSE_BOT_AUCTION_HOUSE_SCRIPT_H */
|
||||
22
modules/mod-ah-bot/src/AuctionHouseBotCommon.cpp
Normal file
22
modules/mod-ah-bot/src/AuctionHouseBotCommon.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#include "AuctionHouseBot.h"
|
||||
#include "AuctionHouseBotCommon.h"
|
||||
#include "AuctionHouseBotConfig.h"
|
||||
|
||||
//
|
||||
// Configuration used globally by all the bots instances
|
||||
//
|
||||
|
||||
AHBConfig* gAllianceConfig = new AHBConfig(2);
|
||||
AHBConfig* gHordeConfig = new AHBConfig(6);
|
||||
AHBConfig* gNeutralConfig = new AHBConfig(7);
|
||||
|
||||
//
|
||||
// Active bots
|
||||
//
|
||||
|
||||
std::set<uint32> gBotsId;
|
||||
std::set<AuctionHouseBot*> gBots;
|
||||
107
modules/mod-ah-bot/src/AuctionHouseBotCommon.h
Normal file
107
modules/mod-ah-bot/src/AuctionHouseBotCommon.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef AUCTION_HOUSE_BOT_COMMON_H
|
||||
#define AUCTION_HOUSE_BOT_COMMON_H
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
class AuctionHouseBot;
|
||||
|
||||
//
|
||||
// Item quality
|
||||
//
|
||||
|
||||
#define AHB_GREY ITEM_QUALITY_POOR
|
||||
#define AHB_WHITE ITEM_QUALITY_NORMAL
|
||||
#define AHB_GREEN ITEM_QUALITY_UNCOMMON
|
||||
#define AHB_BLUE ITEM_QUALITY_RARE
|
||||
#define AHB_PURPLE ITEM_QUALITY_EPIC
|
||||
#define AHB_ORANGE ITEM_QUALITY_LEGENDARY
|
||||
#define AHB_YELLOW ITEM_QUALITY_ARTIFACT
|
||||
#define AHB_MAX_QUALITY ITEM_QUALITY_ARTIFACT
|
||||
|
||||
#define AHB_CLASS_WARRIOR 1
|
||||
#define AHB_CLASS_PALADIN 2
|
||||
#define AHB_CLASS_HUNTER 4
|
||||
#define AHB_CLASS_ROGUE 8
|
||||
#define AHB_CLASS_PRIEST 16
|
||||
#define AHB_CLASS_DK 32
|
||||
#define AHB_CLASS_SHAMAN 64
|
||||
#define AHB_CLASS_MAGE 128
|
||||
#define AHB_CLASS_WARLOCK 256
|
||||
#define AHB_CLASS_UNUSED 512
|
||||
#define AHB_CLASS_DRUID 1024
|
||||
|
||||
//
|
||||
// Items classification
|
||||
//
|
||||
|
||||
#define AHB_GREY_TG 0
|
||||
#define AHB_WHITE_TG 1
|
||||
#define AHB_GREEN_TG 2
|
||||
#define AHB_BLUE_TG 3
|
||||
#define AHB_PURPLE_TG 4
|
||||
#define AHB_ORANGE_TG 5
|
||||
#define AHB_YELLOW_TG 6
|
||||
|
||||
#define AHB_GREY_I 7
|
||||
#define AHB_WHITE_I 8
|
||||
#define AHB_GREEN_I 9
|
||||
#define AHB_BLUE_I 10
|
||||
#define AHB_PURPLE_I 11
|
||||
#define AHB_ORANGE_I 12
|
||||
#define AHB_YELLOW_I 13
|
||||
|
||||
#define AHB_ITEM_TYPE_OFFSET 7
|
||||
|
||||
//
|
||||
// Chat GM commands
|
||||
//
|
||||
|
||||
enum class AHBotCommand : uint32
|
||||
{
|
||||
buyer,
|
||||
seller,
|
||||
useMarketPrice,
|
||||
|
||||
ahexpire,
|
||||
minitems,
|
||||
maxitems,
|
||||
percentages,
|
||||
minprice,
|
||||
maxprice,
|
||||
minbidprice,
|
||||
maxbidprice,
|
||||
maxstack,
|
||||
buyerprice,
|
||||
bidinterval,
|
||||
bidsperinterval
|
||||
};
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
extern std::set<uint32> gBotsId; // Active bots players ids
|
||||
extern std::set<AuctionHouseBot*> gBots; // Active bots
|
||||
|
||||
#endif // AUCTION_HOUSE_BOT_COMMON_H
|
||||
3460
modules/mod-ah-bot/src/AuctionHouseBotConfig.cpp
Normal file
3460
modules/mod-ah-bot/src/AuctionHouseBotConfig.cpp
Normal file
File diff suppressed because it is too large
Load Diff
374
modules/mod-ah-bot/src/AuctionHouseBotConfig.h
Normal file
374
modules/mod-ah-bot/src/AuctionHouseBotConfig.h
Normal file
@@ -0,0 +1,374 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef AUCTION_HOUSE_BOT_CONFIG_H
|
||||
#define AUCTION_HOUSE_BOT_CONFIG_H
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "ObjectMgr.h"
|
||||
|
||||
class AHBConfig
|
||||
{
|
||||
private:
|
||||
uint32 AHID; // Id
|
||||
uint32 AHFID; // Faction id
|
||||
|
||||
uint32 minItems;
|
||||
uint32 maxItems;
|
||||
|
||||
uint32 percentGreyTradeGoods;
|
||||
uint32 percentWhiteTradeGoods;
|
||||
uint32 percentGreenTradeGoods;
|
||||
uint32 percentBlueTradeGoods;
|
||||
uint32 percentPurpleTradeGoods;
|
||||
uint32 percentOrangeTradeGoods;
|
||||
uint32 percentYellowTradeGoods;
|
||||
|
||||
uint32 percentGreyItems;
|
||||
uint32 percentWhiteItems;
|
||||
uint32 percentGreenItems;
|
||||
uint32 percentBlueItems;
|
||||
uint32 percentPurpleItems;
|
||||
uint32 percentOrangeItems;
|
||||
uint32 percentYellowItems;
|
||||
|
||||
uint32 minPriceGrey;
|
||||
uint32 maxPriceGrey;
|
||||
uint32 minBidPriceGrey;
|
||||
uint32 maxBidPriceGrey;
|
||||
uint32 maxStackGrey;
|
||||
|
||||
uint32 minPriceWhite;
|
||||
uint32 maxPriceWhite;
|
||||
uint32 minBidPriceWhite;
|
||||
uint32 maxBidPriceWhite;
|
||||
uint32 maxStackWhite;
|
||||
|
||||
uint32 minPriceGreen;
|
||||
uint32 maxPriceGreen;
|
||||
uint32 minBidPriceGreen;
|
||||
uint32 maxBidPriceGreen;
|
||||
uint32 maxStackGreen;
|
||||
|
||||
uint32 minPriceBlue;
|
||||
uint32 maxPriceBlue;
|
||||
uint32 minBidPriceBlue;
|
||||
uint32 maxBidPriceBlue;
|
||||
uint32 maxStackBlue;
|
||||
|
||||
uint32 minPricePurple;
|
||||
uint32 maxPricePurple;
|
||||
uint32 minBidPricePurple;
|
||||
uint32 maxBidPricePurple;
|
||||
uint32 maxStackPurple;
|
||||
|
||||
uint32 minPriceOrange;
|
||||
uint32 maxPriceOrange;
|
||||
uint32 minBidPriceOrange;
|
||||
uint32 maxBidPriceOrange;
|
||||
uint32 maxStackOrange;
|
||||
|
||||
uint32 minPriceYellow;
|
||||
uint32 maxPriceYellow;
|
||||
uint32 minBidPriceYellow;
|
||||
uint32 maxBidPriceYellow;
|
||||
uint32 maxStackYellow;
|
||||
|
||||
uint32 buyerPriceGrey;
|
||||
uint32 buyerPriceWhite;
|
||||
uint32 buyerPriceGreen;
|
||||
uint32 buyerPriceBlue;
|
||||
uint32 buyerPricePurple;
|
||||
uint32 buyerPriceOrange;
|
||||
uint32 buyerPriceYellow;
|
||||
uint32 buyerBiddingInterval;
|
||||
uint32 buyerBidsPerInterval;
|
||||
|
||||
//
|
||||
// Amount of items to be sold in absolute values
|
||||
//
|
||||
|
||||
uint32 greytgp;
|
||||
uint32 whitetgp;
|
||||
uint32 greentgp;
|
||||
uint32 bluetgp;
|
||||
uint32 purpletgp;
|
||||
uint32 orangetgp;
|
||||
uint32 yellowtgp;
|
||||
|
||||
uint32 greyip;
|
||||
uint32 whiteip;
|
||||
uint32 greenip;
|
||||
uint32 blueip;
|
||||
uint32 purpleip;
|
||||
uint32 orangeip;
|
||||
uint32 yellowip;
|
||||
|
||||
//
|
||||
// Situation of the auction house
|
||||
//
|
||||
|
||||
uint32 greyTGoods;
|
||||
uint32 whiteTGoods;
|
||||
uint32 greenTGoods;
|
||||
uint32 blueTGoods;
|
||||
uint32 purpleTGoods;
|
||||
uint32 orangeTGoods;
|
||||
uint32 yellowTGoods;
|
||||
|
||||
uint32 greyItems;
|
||||
uint32 whiteItems;
|
||||
uint32 greenItems;
|
||||
uint32 blueItems;
|
||||
uint32 purpleItems;
|
||||
uint32 orangeItems;
|
||||
uint32 yellowItems;
|
||||
|
||||
//
|
||||
// Per-item statistics
|
||||
//
|
||||
|
||||
std::map<uint32, uint32> itemsCount;
|
||||
std::map<uint32, uint64> itemsSum;
|
||||
std::map<uint32, uint64> itemsPrice;
|
||||
|
||||
void InitializeFromFile();
|
||||
void InitializeFromSql(std::set<uint32> botsIds);
|
||||
|
||||
std::set<uint32> getCommaSeparatedIntegers(std::string text);
|
||||
|
||||
void DecItemCounts(uint32 ahbotItemType);
|
||||
void IncItemCounts(uint32 ahbotItemType);
|
||||
|
||||
public:
|
||||
//
|
||||
// Debugging
|
||||
//
|
||||
|
||||
bool DebugOut;
|
||||
bool DebugOutConfig;
|
||||
bool DebugOutFilters;
|
||||
bool DebugOutBuyer;
|
||||
bool DebugOutSeller;
|
||||
|
||||
//
|
||||
// Tracing
|
||||
//
|
||||
|
||||
bool TraceSeller;
|
||||
bool TraceBuyer;
|
||||
|
||||
//
|
||||
// Setup
|
||||
//
|
||||
|
||||
bool AHBSeller;
|
||||
bool AHBBuyer;
|
||||
bool UseBuyPriceForBuyer;
|
||||
bool UseBuyPriceForSeller;
|
||||
bool SellAtMarketPrice;
|
||||
uint32 MarketResetThreshold;
|
||||
bool ConsiderOnlyBotAuctions;
|
||||
uint32 ItemsPerCycle;
|
||||
|
||||
//
|
||||
// Filters
|
||||
//
|
||||
|
||||
bool Vendor_Items;
|
||||
bool Loot_Items;
|
||||
bool Other_Items;
|
||||
bool Vendor_TGs;
|
||||
bool Loot_TGs;
|
||||
bool Other_TGs;
|
||||
bool Profession_Items;
|
||||
|
||||
bool No_Bind;
|
||||
bool Bind_When_Picked_Up;
|
||||
bool Bind_When_Equipped;
|
||||
bool Bind_When_Use;
|
||||
bool Bind_Quest_Item;
|
||||
|
||||
uint32 DuplicatesCount;
|
||||
uint32 ElapsingTimeClass;
|
||||
|
||||
bool DivisibleStacks;
|
||||
bool DisablePermEnchant;
|
||||
bool DisableConjured;
|
||||
bool DisableGems;
|
||||
bool DisableMoney;
|
||||
bool DisableMoneyLoot;
|
||||
bool DisableLootable;
|
||||
bool DisableKeys;
|
||||
bool DisableDuration;
|
||||
bool DisableBOP_Or_Quest_NoReqLevel;
|
||||
|
||||
bool DisableWarriorItems;
|
||||
bool DisablePaladinItems;
|
||||
bool DisableHunterItems;
|
||||
bool DisableRogueItems;
|
||||
bool DisablePriestItems;
|
||||
bool DisableDKItems;
|
||||
bool DisableShamanItems;
|
||||
bool DisableMageItems;
|
||||
bool DisableWarlockItems;
|
||||
bool DisableUnusedClassItems;
|
||||
bool DisableDruidItems;
|
||||
|
||||
uint32 DisableItemsBelowLevel;
|
||||
uint32 DisableItemsAboveLevel;
|
||||
|
||||
uint32 DisableTGsBelowLevel;
|
||||
uint32 DisableTGsAboveLevel;
|
||||
|
||||
uint32 DisableItemsBelowGUID;
|
||||
uint32 DisableItemsAboveGUID;
|
||||
|
||||
uint32 DisableTGsBelowGUID;
|
||||
uint32 DisableTGsAboveGUID;
|
||||
|
||||
uint32 DisableItemsBelowReqLevel;
|
||||
uint32 DisableItemsAboveReqLevel;
|
||||
|
||||
uint32 DisableTGsBelowReqLevel;
|
||||
uint32 DisableTGsAboveReqLevel;
|
||||
|
||||
uint32 DisableItemsBelowReqSkillRank;
|
||||
uint32 DisableItemsAboveReqSkillRank;
|
||||
|
||||
uint32 DisableTGsBelowReqSkillRank;
|
||||
uint32 DisableTGsAboveReqSkillRank;
|
||||
|
||||
//
|
||||
// Items validity for selling purposes
|
||||
//
|
||||
|
||||
std::set<uint32> NpcItems;
|
||||
std::set<uint32> LootItems;
|
||||
std::set<uint32> DisableItemStore;
|
||||
std::set<uint32> SellerWhiteList;
|
||||
|
||||
//
|
||||
// Bins for trade goods.
|
||||
//
|
||||
|
||||
std::set<uint32> GreyTradeGoodsBin;
|
||||
std::set<uint32> WhiteTradeGoodsBin;
|
||||
std::set<uint32> GreenTradeGoodsBin;
|
||||
std::set<uint32> BlueTradeGoodsBin;
|
||||
std::set<uint32> PurpleTradeGoodsBin;
|
||||
std::set<uint32> OrangeTradeGoodsBin;
|
||||
std::set<uint32> YellowTradeGoodsBin;
|
||||
|
||||
//
|
||||
// Bins for items
|
||||
//
|
||||
|
||||
std::set<uint32> GreyItemsBin;
|
||||
std::set<uint32> WhiteItemsBin;
|
||||
std::set<uint32> GreenItemsBin;
|
||||
std::set<uint32> BlueItemsBin;
|
||||
std::set<uint32> PurpleItemsBin;
|
||||
std::set<uint32> OrangeItemsBin;
|
||||
std::set<uint32> YellowItemsBin;
|
||||
|
||||
//
|
||||
// Constructors/destructors
|
||||
//
|
||||
|
||||
AHBConfig(uint32 ahid, AHBConfig* conf);
|
||||
AHBConfig(uint32 ahid);
|
||||
AHBConfig();
|
||||
~AHBConfig();
|
||||
|
||||
//
|
||||
// Ruotines
|
||||
//
|
||||
|
||||
void Initialize(std::set<uint32> botsIds);
|
||||
void InitializeBins();
|
||||
void Reset();
|
||||
|
||||
uint32 GetAHID();
|
||||
uint32 GetAHFID();
|
||||
|
||||
void SetMinItems (uint32 value);
|
||||
uint32 GetMinItems ();
|
||||
|
||||
void SetMaxItems (uint32 value);
|
||||
uint32 GetMaxItems ();
|
||||
|
||||
void SetPercentages (uint32 greytg, uint32 whitetg, uint32 greentg, uint32 bluetg, uint32 purpletg, uint32 orangetg, uint32 yellowtg,
|
||||
uint32 greyi , uint32 whitei , uint32 greeni , uint32 bluei , uint32 purplei , uint32 orangei , uint32 yellowi);
|
||||
uint32 GetPercentages (uint32 color);
|
||||
|
||||
void SetMinPrice (uint32 color, uint32 value);
|
||||
uint32 GetMinPrice (uint32 color);
|
||||
|
||||
void SetMaxPrice (uint32 color, uint32 value);
|
||||
uint32 GetMaxPrice (uint32 color);
|
||||
|
||||
void SetMinBidPrice (uint32 color, uint32 value);
|
||||
uint32 GetMinBidPrice (uint32 color);
|
||||
|
||||
void SetMaxBidPrice (uint32 color, uint32 value);
|
||||
uint32 GetMaxBidPrice (uint32 color);
|
||||
|
||||
void SetMaxStack (uint32 color, uint32 value);
|
||||
uint32 GetMaxStack (uint32 color);
|
||||
|
||||
void SetBuyerPrice (uint32 color, uint32 value);
|
||||
uint32 GetBuyerPrice (uint32 color);
|
||||
|
||||
void SetBiddingInterval(uint32 value);
|
||||
uint32 GetBiddingInterval();
|
||||
|
||||
void SetBidsPerInterval(uint32 value);
|
||||
uint32 GetBidsPerInterval();
|
||||
|
||||
void CalculatePercents ();
|
||||
// max number of items of type in AH based on maxItems
|
||||
uint32 GetMaximum (uint32 ahbotItemType);
|
||||
|
||||
void DecItemCounts (uint32 Class, uint32 Quality);
|
||||
|
||||
void IncItemCounts (uint32 Class, uint32 Quality);
|
||||
|
||||
|
||||
void ResetItemCounts ();
|
||||
uint32 TotalItemCounts ();
|
||||
|
||||
uint32 GetItemCounts (uint32 color);
|
||||
|
||||
void UpdateItemStats (uint32 id, uint32 stackSize, uint64 buyout);
|
||||
uint64 GetItemPrice (uint32 id);
|
||||
};
|
||||
|
||||
//
|
||||
// Globally defined configurations
|
||||
//
|
||||
|
||||
extern AHBConfig* gAllianceConfig;
|
||||
extern AHBConfig* gHordeConfig;
|
||||
extern AHBConfig* gNeutralConfig;
|
||||
|
||||
#endif // AUCTION_HOUSE_BOT_CONFIG_H
|
||||
39
modules/mod-ah-bot/src/AuctionHouseBotMailScript.cpp
Normal file
39
modules/mod-ah-bot/src/AuctionHouseBotMailScript.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#include "AuctionHouseBot.h"
|
||||
#include "AuctionHouseBotCommon.h"
|
||||
#include "AuctionHouseBotMailScript.h"
|
||||
|
||||
AHBot_MailScript::AHBot_MailScript() : MailScript("AHBot_MailScript", {
|
||||
MAILHOOK_ON_BEFORE_MAIL_DRAFT_SEND_MAIL_TO
|
||||
})
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AHBot_MailScript::OnBeforeMailDraftSendMailTo(
|
||||
MailDraft*, /* mailDraft */
|
||||
MailReceiver const& receiver,
|
||||
MailSender const& sender,
|
||||
MailCheckMask&, /* checked */
|
||||
uint32&, /* deliver_delay */
|
||||
uint32&, /* custom_expiration */
|
||||
bool& deleteMailItemsFromDB,
|
||||
bool& sendMail)
|
||||
{
|
||||
//
|
||||
// If the mail is for the bot, then remove it and delete the items bought
|
||||
//
|
||||
|
||||
if (gBotsId.find(receiver.GetPlayerGUIDLow()) != gBotsId.end())
|
||||
{
|
||||
if (sender.GetMailMessageType() == MAIL_AUCTION)
|
||||
{
|
||||
deleteMailItemsFromDB = true;
|
||||
}
|
||||
|
||||
sendMail = false;
|
||||
}
|
||||
}
|
||||
23
modules/mod-ah-bot/src/AuctionHouseBotMailScript.h
Normal file
23
modules/mod-ah-bot/src/AuctionHouseBotMailScript.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#ifndef AUCTION_HOUSE_BOT_MAIL_SCRIPT_H
|
||||
#define AUCTION_HOUSE_BOT_MAIL_SCRIPT_H
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "Mail.h"
|
||||
|
||||
// =============================================================================
|
||||
// Interaction with the mailing systems
|
||||
// =============================================================================
|
||||
|
||||
class AHBot_MailScript : public MailScript
|
||||
{
|
||||
public:
|
||||
AHBot_MailScript();
|
||||
|
||||
void OnBeforeMailDraftSendMailTo(MailDraft* mailDraft, MailReceiver const& receiver, MailSender const& sender, MailCheckMask& checked, uint32& deliver_delay, uint32& custom_expiration, bool& deleteMailItemsFromDB, bool& sendMail) override;
|
||||
};
|
||||
|
||||
#endif /* AUCTION_HOUSE_BOT_MAIL_SCRIPT_H */
|
||||
19
modules/mod-ah-bot/src/AuctionHouseBotScript.cpp
Normal file
19
modules/mod-ah-bot/src/AuctionHouseBotScript.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#include "AuctionHouseBot.h"
|
||||
#include "AuctionHouseBotAuctionHouseScript.h"
|
||||
#include "AuctionHouseBotMailScript.h"
|
||||
#include "AuctionHouseBotWorldScript.h"
|
||||
|
||||
// =============================================================================
|
||||
// This provides the effective startup of the module by istanciating the scripts
|
||||
// =============================================================================
|
||||
|
||||
void AddAHBotScripts()
|
||||
{
|
||||
new AHBot_WorldScript();
|
||||
new AHBot_AuctionHouseScript();
|
||||
new AHBot_MailScript();
|
||||
}
|
||||
194
modules/mod-ah-bot/src/AuctionHouseBotWorldScript.cpp
Normal file
194
modules/mod-ah-bot/src/AuctionHouseBotWorldScript.cpp
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include "AuctionHouseBot.h"
|
||||
#include "AuctionHouseBotCommon.h"
|
||||
#include "AuctionHouseBotWorldScript.h"
|
||||
|
||||
// =============================================================================
|
||||
// Initialization of the bot during the world startup
|
||||
// =============================================================================
|
||||
|
||||
AHBot_WorldScript::AHBot_WorldScript() : WorldScript("AHBot_WorldScript", {
|
||||
WORLDHOOK_ON_BEFORE_CONFIG_LOAD,
|
||||
WORLDHOOK_ON_STARTUP
|
||||
})
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AHBot_WorldScript::OnBeforeConfigLoad(bool reload)
|
||||
{
|
||||
//
|
||||
// Retrieve how many bots shall be operating on the auction market
|
||||
//
|
||||
|
||||
bool debug = sConfigMgr->GetOption<bool> ("AuctionHouseBot.DEBUG" , false);
|
||||
uint32 account = sConfigMgr->GetOption<uint32>("AuctionHouseBot.Account", 0);
|
||||
uint32 player = sConfigMgr->GetOption<uint32>("AuctionHouseBot.GUID" , 0);
|
||||
|
||||
//
|
||||
// All the bots bound to the provided account will be used for auctioning, if GUID is zero.
|
||||
// Otherwise only the specified character is used.
|
||||
//
|
||||
|
||||
if (account == 0 && player == 0)
|
||||
{
|
||||
LOG_ERROR("server.loading", "AHBot: Account id and player id missing from configuration; is that the right file?");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
QueryResult result = CharacterDatabase.Query("SELECT guid FROM characters WHERE account = {}", account);
|
||||
|
||||
if (result)
|
||||
{
|
||||
gBotsId.clear();
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 botId = fields[0].Get<uint32>();
|
||||
|
||||
if (player == 0)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
LOG_INFO("server.loading", "AHBot: New bot to start, account={} character={}", account, botId);
|
||||
}
|
||||
|
||||
gBotsId.insert(botId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player == botId)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
LOG_INFO("server.loading", "AHBot: Starting only one bot, account={} character={}", account, botId);
|
||||
}
|
||||
|
||||
gBotsId.insert(botId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("server.loading", "AHBot: Could not query the database for characters of account {}", account);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gBotsId.size() == 0)
|
||||
{
|
||||
LOG_ERROR("server.loading", "AHBot: no characters registered for account {}", account);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Start the bots only if the operation is a reload, otherwise let the OnStartup do the job
|
||||
//
|
||||
|
||||
if (reload)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
LOG_INFO("module", "AHBot: Reloading the bots");
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the bots array; this way they wont be used anymore during the initialization stage.
|
||||
//
|
||||
|
||||
DeleteBots();
|
||||
|
||||
//
|
||||
// Reload the configuration for the auction houses
|
||||
//
|
||||
|
||||
gAllianceConfig->Initialize(gBotsId);
|
||||
gHordeConfig->Initialize (gBotsId);
|
||||
gNeutralConfig->Initialize (gBotsId);
|
||||
|
||||
//
|
||||
// Start again the bots
|
||||
//
|
||||
|
||||
PopulateBots();
|
||||
}
|
||||
}
|
||||
|
||||
void AHBot_WorldScript::OnStartup()
|
||||
{
|
||||
LOG_INFO("server.loading", "Initialize AuctionHouseBot...");
|
||||
|
||||
//
|
||||
// Initialize the configuration (done only once at startup)
|
||||
//
|
||||
|
||||
gAllianceConfig->Initialize(gBotsId);
|
||||
gHordeConfig->Initialize (gBotsId);
|
||||
gNeutralConfig->Initialize (gBotsId);
|
||||
|
||||
//
|
||||
// Starts the bots
|
||||
//
|
||||
|
||||
PopulateBots();
|
||||
}
|
||||
|
||||
void AHBot_WorldScript::DeleteBots()
|
||||
{
|
||||
//
|
||||
// Save the old bots references.
|
||||
//
|
||||
|
||||
std::set<AuctionHouseBot*> oldBots;
|
||||
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
oldBots.insert(bot);
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the bot list
|
||||
//
|
||||
|
||||
gBots.clear();
|
||||
|
||||
//
|
||||
// Free the resources used up by the old bots
|
||||
//
|
||||
|
||||
for (AuctionHouseBot* bot: oldBots)
|
||||
{
|
||||
delete bot;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AHBot_WorldScript::PopulateBots()
|
||||
{
|
||||
uint32 account = sConfigMgr->GetOption<uint32>("AuctionHouseBot.Account", 0);
|
||||
|
||||
//
|
||||
// Insert the bot in the list used for auction house iterations
|
||||
//
|
||||
|
||||
gBots.clear();
|
||||
|
||||
for (uint32 id: gBotsId)
|
||||
{
|
||||
AuctionHouseBot* bot = new AuctionHouseBot(account, id);
|
||||
bot->Initialize(gAllianceConfig, gHordeConfig, gNeutralConfig);
|
||||
|
||||
gBots.insert(bot);
|
||||
}
|
||||
}
|
||||
27
modules/mod-ah-bot/src/AuctionHouseBotWorldScript.h
Normal file
27
modules/mod-ah-bot/src/AuctionHouseBotWorldScript.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#ifndef AUCTION_HOUSE_BOT_WORLD_SCRIPT_H
|
||||
#define AUCTION_HOUSE_BOT_WORLD_SCRIPT_H
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
// =============================================================================
|
||||
// Interaction with the world core mechanisms
|
||||
// =============================================================================
|
||||
|
||||
class AHBot_WorldScript : public WorldScript
|
||||
{
|
||||
private:
|
||||
void DeleteBots();
|
||||
void PopulateBots();
|
||||
|
||||
public:
|
||||
AHBot_WorldScript();
|
||||
|
||||
void OnBeforeConfigLoad(bool reload) override;
|
||||
void OnStartup() override;
|
||||
};
|
||||
|
||||
#endif /* AUCTION_HOUSE_BOT_WORLD_SCRIPT_H */
|
||||
15
modules/mod-ah-bot/src/ah_bot_loader.cpp
Normal file
15
modules/mod-ah-bot/src/ah_bot_loader.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE
|
||||
* Copyright (C) 2021+ WarheadCore <https://github.com/WarheadCore>
|
||||
*/
|
||||
|
||||
// From SC
|
||||
void AddAHBotCommandScripts();
|
||||
void AddAHBotScripts();
|
||||
|
||||
// Add all
|
||||
void Addmod_ah_botScripts()
|
||||
{
|
||||
AddAHBotCommandScripts();
|
||||
AddAHBotScripts();
|
||||
}
|
||||
580
modules/mod-ah-bot/src/cs_ah_bot.cpp
Normal file
580
modules/mod-ah-bot/src/cs_ah_bot.cpp
Normal file
@@ -0,0 +1,580 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* 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 the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* ScriptData
|
||||
Name: ah_bot_commandscript
|
||||
%Complete: 100
|
||||
Comment: All ah_bot related commands
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "AuctionHouseBot.h"
|
||||
#include "Config.h"
|
||||
|
||||
#if AC_COMPILER == AC_COMPILER_GNU
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
using namespace Acore::ChatCommands;
|
||||
|
||||
class ah_bot_commandscript : public CommandScript
|
||||
{
|
||||
private:
|
||||
static ItemQualities stringToItemQualities(const char* name, int length)
|
||||
{
|
||||
//
|
||||
// Translates a string into ItemQualities enum
|
||||
//
|
||||
|
||||
if (strncmp(name, "grey", length) == 0)
|
||||
{
|
||||
return ITEM_QUALITY_POOR;
|
||||
}
|
||||
|
||||
if (strncmp(name, "white", length) == 0)
|
||||
{
|
||||
return ITEM_QUALITY_NORMAL;
|
||||
}
|
||||
|
||||
if (strncmp(name, "green", length) == 0)
|
||||
{
|
||||
return ITEM_QUALITY_UNCOMMON;
|
||||
}
|
||||
|
||||
if (strncmp(name, "blue", length) == 0)
|
||||
{
|
||||
return ITEM_QUALITY_RARE;
|
||||
}
|
||||
|
||||
if (strncmp(name, "purple", length) == 0)
|
||||
{
|
||||
return ITEM_QUALITY_EPIC;
|
||||
}
|
||||
|
||||
if (strncmp(name, "orange", length) == 0)
|
||||
{
|
||||
return ITEM_QUALITY_LEGENDARY;
|
||||
}
|
||||
|
||||
if (strncmp(name, "yellow", length) == 0)
|
||||
{
|
||||
return ITEM_QUALITY_ARTIFACT;
|
||||
}
|
||||
|
||||
return static_cast<ItemQualities>(-1); // Invalid
|
||||
}
|
||||
|
||||
public:
|
||||
ah_bot_commandscript() : CommandScript("ah_bot_commandscript")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<ChatCommand> GetCommands() const override
|
||||
{
|
||||
static std::vector<ChatCommand> commandTable =
|
||||
{
|
||||
{ "ahbotoptions", HandleAHBotOptionsCommand, SEC_GAMEMASTER, Console::Yes }
|
||||
};
|
||||
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleAHBotOptionsCommand(ChatHandler* handler, const char*args)
|
||||
{
|
||||
uint32 ahMapID = 0;
|
||||
char* opt = strtok((char*)args, " ");
|
||||
|
||||
if (!opt)
|
||||
{
|
||||
handler->PSendSysMessage("Invalid syntax");
|
||||
handler->PSendSysMessage("Try ahbotoptions help to see a list of options.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Commands which does not requires an AH
|
||||
//
|
||||
|
||||
int l = strlen(opt);
|
||||
|
||||
if (strncmp(opt, "buyer", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
|
||||
if (!param1)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions buyer $state (0 off 1 on)");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::buyer, 0, 0, param1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (strncmp(opt, "seller", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
|
||||
if (!param1)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions seller $state (0 off 1 on)");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::seller, 0, 0, param1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (strncmp(opt, "usemarketprice", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
|
||||
if (!param1)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions useMarketPrice $state (0 off 1 on)");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AuctionHouseBot* bot : gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::useMarketPrice, 0, 0, param1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the auction house type
|
||||
//
|
||||
|
||||
char* ahMapIdStr = strtok(NULL, " ");
|
||||
|
||||
if (ahMapIdStr)
|
||||
{
|
||||
ahMapID = uint32(strtoul(ahMapIdStr, NULL, 0));
|
||||
|
||||
switch (ahMapID)
|
||||
{
|
||||
case 2:
|
||||
case 6:
|
||||
case 7:
|
||||
break;
|
||||
default:
|
||||
opt = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Syntax check
|
||||
//
|
||||
|
||||
if (!opt)
|
||||
{
|
||||
handler->PSendSysMessage("Invalid syntax; the auction house id must be 2, 6 or 7");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Commands that do requires an AH id to be performed
|
||||
//
|
||||
|
||||
if (strncmp(opt, "help", l) == 0)
|
||||
{
|
||||
handler->PSendSysMessage("AHBot commands:");
|
||||
handler->PSendSysMessage("buyer - enable/disable buyer");
|
||||
handler->PSendSysMessage("seller - enable/disabler seller");
|
||||
handler->PSendSysMessage("usemarketprice - enable/disabler selling at market price");
|
||||
handler->PSendSysMessage("ahexpire - remove all bot auctions");
|
||||
handler->PSendSysMessage("minitems - set min auctions");
|
||||
handler->PSendSysMessage("maxitems - set max auctions");
|
||||
handler->PSendSysMessage("percentages - set selling percentages");
|
||||
handler->PSendSysMessage("minprice - set min price");
|
||||
handler->PSendSysMessage("maxprice - set max price");
|
||||
handler->PSendSysMessage("minbidprice - set min bid price for buyer");
|
||||
handler->PSendSysMessage("maxbidprice - set max bid price for buyer");
|
||||
handler->PSendSysMessage("maxstack - set max stack");
|
||||
handler->PSendSysMessage("buyerprice - set the buyer price policy");
|
||||
handler->PSendSysMessage("bidinterval - set the bid interval for buyer");
|
||||
handler->PSendSysMessage("bidsperinterval - set the bid amount for buyer");
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (strncmp(opt, "ahexpire", l) == 0)
|
||||
{
|
||||
if (!ahMapIdStr)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions ahexpire $ahMapID (2, 6 or 7)");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::ahexpire, ahMapID, 0, NULL);
|
||||
}
|
||||
}
|
||||
else if (strncmp(opt, "minitems", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param1)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions minitems $ahMapID (2, 6 or 7) $minItems");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AuctionHouseBot* bot : gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::minitems, ahMapID, 0, param1);
|
||||
}
|
||||
}
|
||||
else if (strncmp(opt, "maxitems", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param1)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions maxitems $ahMapID (2, 6 or 7) $maxItems");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::maxitems, ahMapID, 0, 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, " ");
|
||||
char* param9 = strtok(NULL, " ");
|
||||
char* param10 = strtok(NULL, " ");
|
||||
char* param11 = strtok(NULL, " ");
|
||||
char* param12 = strtok(NULL, " ");
|
||||
char* param13 = strtok(NULL, " ");
|
||||
char* param14 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param14)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14");
|
||||
handler->PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods");
|
||||
handler->PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems");
|
||||
handler->PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 greytg = uint32(strtoul(param1 , NULL, 0));
|
||||
uint32 whitetg = uint32(strtoul(param2 , NULL, 0));
|
||||
uint32 greentg = uint32(strtoul(param3 , NULL, 0));
|
||||
uint32 bluetg = uint32(strtoul(param4 , NULL, 0));
|
||||
uint32 purpletg = uint32(strtoul(param5 , NULL, 0));
|
||||
uint32 orangetg = uint32(strtoul(param6 , NULL, 0));
|
||||
uint32 yellowtg = uint32(strtoul(param7 , NULL, 0));
|
||||
uint32 greyi = uint32(strtoul(param8 , NULL, 0));
|
||||
uint32 whitei = uint32(strtoul(param9 , NULL, 0));
|
||||
uint32 greeni = uint32(strtoul(param10, NULL, 0));
|
||||
uint32 bluei = uint32(strtoul(param11, NULL, 0));
|
||||
uint32 purplei = uint32(strtoul(param12, NULL, 0));
|
||||
uint32 orangei = uint32(strtoul(param13, NULL, 0));
|
||||
uint32 yellowi = uint32(strtoul(param14, NULL, 0));
|
||||
|
||||
uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi;
|
||||
|
||||
if (totalPercent == 0 || totalPercent != 100)
|
||||
{
|
||||
handler->PSendSysMessage("The total must add up to 100%%");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
char param[100] = { 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);
|
||||
strcat(param, " ");
|
||||
strcat(param, param9);
|
||||
strcat(param, " ");
|
||||
strcat(param, param10);
|
||||
strcat(param, " ");
|
||||
strcat(param, param11);
|
||||
strcat(param, " ");
|
||||
strcat(param, param12);
|
||||
strcat(param, " ");
|
||||
strcat(param, param13);
|
||||
strcat(param, " ");
|
||||
strcat(param, param14);
|
||||
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::percentages, ahMapID, 0, param);
|
||||
}
|
||||
}
|
||||
else if (strncmp(opt, "minprice", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
char* param2 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param1 || !param2)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto quality = stringToItemQualities(param1, l);
|
||||
|
||||
if (quality != static_cast<ItemQualities>(-1))
|
||||
{
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::minprice, ahMapID, quality, param2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (strncmp(opt, "maxprice", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
char* param2 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param1 || !param2)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto quality = stringToItemQualities(param1, l);
|
||||
|
||||
if (quality != static_cast<ItemQualities>(-1))
|
||||
{
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::maxprice, ahMapID, quality, param2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (strncmp(opt, "minbidprice", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
char* param2 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param2 || !param2)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 minBidPrice = uint32(strtoul(param2, NULL, 0));
|
||||
|
||||
if (minBidPrice < 1 || minBidPrice > 100)
|
||||
{
|
||||
handler->PSendSysMessage("The min bid price multiplier must be between 1 and 100");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto quality = stringToItemQualities(param1, l);
|
||||
|
||||
if (quality != static_cast<ItemQualities>(-1))
|
||||
{
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::minbidprice, ahMapID, quality, param2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (strncmp(opt, "maxbidprice", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
char* param2 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param1 || !param2)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions maxbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 maxBidPrice = uint32(strtoul(param2, NULL, 0));
|
||||
|
||||
if (maxBidPrice < 1 || maxBidPrice > 100)
|
||||
{
|
||||
handler->PSendSysMessage("The max bid price multiplier must be between 1 and 100");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto quality = stringToItemQualities(param1, l);
|
||||
|
||||
if (quality != static_cast<ItemQualities>(-1))
|
||||
{
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::maxbidprice, ahMapID, quality, param2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions max bidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (strncmp(opt, "maxstack",l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
char* param2 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param1 || !param2)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value");
|
||||
return false;
|
||||
}
|
||||
|
||||
// uint32 maxStack = uint32(strtoul(param2, NULL, 0));
|
||||
// if (maxStack < 0)
|
||||
// {
|
||||
// handler->PSendSysMessage("maxstack can't be a negative number.");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
auto quality = stringToItemQualities(param1, l);
|
||||
|
||||
if (quality != static_cast<ItemQualities>(-1))
|
||||
{
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::maxstack, ahMapID, quality, param2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (strncmp(opt, "buyerprice", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
char* param2 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param1 || !param2)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto quality = stringToItemQualities(param1, l);
|
||||
|
||||
if (quality != static_cast<ItemQualities>(-1))
|
||||
{
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::buyerprice, ahMapID, quality, param2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->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)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions bidinterval $ahMapID (2, 6 or 7) $interval(in minutes)");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::bidinterval, ahMapID, 0, param1);
|
||||
}
|
||||
}
|
||||
else if (strncmp(opt, "bidsperinterval", l) == 0)
|
||||
{
|
||||
char* param1 = strtok(NULL, " ");
|
||||
|
||||
if (!ahMapIdStr || !param1)
|
||||
{
|
||||
handler->PSendSysMessage("Syntax is: ahbotoptions bidsperinterval $ahMapID (2, 6 or 7) $bids");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AuctionHouseBot* bot: gBots)
|
||||
{
|
||||
bot->Commands(AHBotCommand::bidsperinterval, ahMapID, 0, param1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("Invalid syntax");
|
||||
handler->PSendSysMessage("Try ahbotoptions help to see a list of options.");
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("Done");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddAHBotCommandScripts()
|
||||
{
|
||||
new ah_bot_commandscript();
|
||||
}
|
||||
Reference in New Issue
Block a user