Add additional trading options (#1186)

* Add addclass bots to trading list, differentiate between buying and selling.

* typos

* Try calling playerguid

* point IsAddclassBot to IsRandomBot

* typo

* Fix through IsAddClassbot

* Working Version

* Minor typos.
This commit is contained in:
Paolo
2025-04-16 20:52:14 -07:00
committed by GitHub
parent 2f549295d5
commit 7737f9ab72
6 changed files with 30 additions and 7 deletions

View File

@@ -544,7 +544,8 @@ AiPlayerbot.DisableDeathKnightLogin = 0
# Default: 0 # Default: 0
AiPlayerbot.LimitTalentsExpansion = 0 AiPlayerbot.LimitTalentsExpansion = 0
# Allow random bots to trade # Configure random bots and addClass bot trading (0: Disabled, 1: Enabled, 2: Only buy, 3: Only Sell)
# Default: 1 (Enabled)
AiPlayerbot.EnableRandomBotTrading = 1 AiPlayerbot.EnableRandomBotTrading = 1
# #
# #

View File

@@ -506,7 +506,7 @@ bool PlayerbotAIConfig::Initialize()
limitGearExpansion = sConfigMgr->GetOption<int32>("AiPlayerbot.LimitGearExpansion", 1); limitGearExpansion = sConfigMgr->GetOption<int32>("AiPlayerbot.LimitGearExpansion", 1);
randombotStartingLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.RandombotStartingLevel", 5); randombotStartingLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.RandombotStartingLevel", 5);
enablePeriodicOnlineOffline = sConfigMgr->GetOption<bool>("AiPlayerbot.EnablePeriodicOnlineOffline", false); enablePeriodicOnlineOffline = sConfigMgr->GetOption<bool>("AiPlayerbot.EnablePeriodicOnlineOffline", false);
enableRandomBotTrading = sConfigMgr->GetOption<bool>("AiPlayerbot.EnableRandomBotTrading", true); enableRandomBotTrading = sConfigMgr->GetOption<int32>("AiPlayerbot.EnableRandomBotTrading", 1);
periodicOnlineOfflineRatio = sConfigMgr->GetOption<float>("AiPlayerbot.PeriodicOnlineOfflineRatio", 2.0); periodicOnlineOfflineRatio = sConfigMgr->GetOption<float>("AiPlayerbot.PeriodicOnlineOfflineRatio", 2.0);
gearscorecheck = sConfigMgr->GetOption<bool>("AiPlayerbot.GearScoreCheck", false); gearscorecheck = sConfigMgr->GetOption<bool>("AiPlayerbot.GearScoreCheck", false);
randomBotPreQuests = sConfigMgr->GetOption<bool>("AiPlayerbot.PreQuests", true); randomBotPreQuests = sConfigMgr->GetOption<bool>("AiPlayerbot.PreQuests", true);

View File

@@ -313,7 +313,7 @@ public:
bool autoLearnQuestSpells; bool autoLearnQuestSpells;
bool autoTeleportForLevel; bool autoTeleportForLevel;
bool randomBotGroupNearby; bool randomBotGroupNearby;
bool enableRandomBotTrading; int32 enableRandomBotTrading;
uint32 tweakValue; // Debugging config uint32 tweakValue; // Debugging config
uint32 randomBotArenaTeamCount; uint32 randomBotArenaTeamCount;

View File

@@ -2204,6 +2204,19 @@ bool RandomPlayerbotMgr::IsRandomBot(ObjectGuid::LowType bot)
return true; return true;
return false; return false;
} }
bool RandomPlayerbotMgr::IsAddclassBot(Player* bot)
{
if (bot && GET_PLAYERBOT_AI(bot))
{
if (GET_PLAYERBOT_AI(bot)->IsRealPlayer())
return false;
}
if (bot)
{
return IsAddclassBot(bot->GetGUID().GetCounter());
}
return false;
}
bool RandomPlayerbotMgr::IsAddclassBot(ObjectGuid::LowType bot) bool RandomPlayerbotMgr::IsAddclassBot(ObjectGuid::LowType bot)
{ {

View File

@@ -112,6 +112,7 @@ public:
static bool HandlePlayerbotConsoleCommand(ChatHandler* handler, char const* args); static bool HandlePlayerbotConsoleCommand(ChatHandler* handler, char const* args);
bool IsRandomBot(Player* bot); bool IsRandomBot(Player* bot);
bool IsRandomBot(ObjectGuid::LowType bot); bool IsRandomBot(ObjectGuid::LowType bot);
bool IsAddclassBot(Player* bot);
bool IsAddclassBot(ObjectGuid::LowType bot); bool IsAddclassBot(ObjectGuid::LowType bot);
void Randomize(Player* bot); void Randomize(Player* bot);
void Clear(Player* bot); void Clear(Player* bot);

View File

@@ -32,7 +32,7 @@ bool TradeStatusAction::Execute(Event event)
return false; return false;
} }
if (!sPlayerbotAIConfig->enableRandomBotTrading && sRandomPlayerbotMgr->IsRandomBot(bot)) if (sPlayerbotAIConfig->enableRandomBotTrading == 0 && (sRandomPlayerbotMgr->IsRandomBot(bot)|| sRandomPlayerbotMgr->IsAddclassBot(bot)))
{ {
bot->Whisper("Trading is disabled", LANG_UNIVERSAL, trader); bot->Whisper("Trading is disabled", LANG_UNIVERSAL, trader);
return false; return false;
@@ -171,7 +171,6 @@ bool TradeStatusAction::CheckTrade()
break; break;
} }
} }
bool isGettingItem = false; bool isGettingItem = false;
for (uint32 slot = 0; slot < TRADE_SLOT_TRADED_COUNT; ++slot) for (uint32 slot = 0; slot < TRADE_SLOT_TRADED_COUNT; ++slot)
{ {
@@ -182,7 +181,7 @@ bool TradeStatusAction::CheckTrade()
break; break;
} }
} }
if (isGettingItem) if (isGettingItem)
{ {
if (bot->GetGroup() && bot->GetGroup()->IsMember(bot->GetTrader()->GetGUID()) && if (bot->GetGroup() && bot->GetGroup()->IsMember(bot->GetTrader()->GetGUID()) &&
@@ -215,7 +214,16 @@ bool TradeStatusAction::CheckTrade()
int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney; int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney;
int32 playerItemsMoney = CalculateCost(trader, false); int32 playerItemsMoney = CalculateCost(trader, false);
int32 playerMoney = trader->GetTradeData()->GetMoney() + playerItemsMoney; int32 playerMoney = trader->GetTradeData()->GetMoney() + playerItemsMoney;
if (botItemsMoney > 0 && sPlayerbotAIConfig->enableRandomBotTrading == 2 && (sRandomPlayerbotMgr->IsRandomBot(bot)|| sRandomPlayerbotMgr->IsAddclassBot(bot)))
{
bot->Whisper("Selling is disabled.", LANG_UNIVERSAL, trader);
return false;
}
if (playerItemsMoney && sPlayerbotAIConfig->enableRandomBotTrading == 3 && (sRandomPlayerbotMgr->IsRandomBot(bot)|| sRandomPlayerbotMgr->IsAddclassBot(bot)))
{
bot->Whisper("Buying is disabled.", LANG_UNIVERSAL, trader);
return false;
}
for (uint32 slot = 0; slot < TRADE_SLOT_TRADED_COUNT; ++slot) for (uint32 slot = 0; slot < TRADE_SLOT_TRADED_COUNT; ++slot)
{ {
Item* item = bot->GetTradeData()->GetItem((TradeSlots)slot); Item* item = bot->GetTradeData()->GetItem((TradeSlots)slot);