mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Allow bot to talk in guild when they loot nice item, levelup, kill unique monsters
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "Event.h"
|
||||
#include "PlayerbotFactory.h"
|
||||
#include "Playerbots.h"
|
||||
#include "GuildMgr.h"
|
||||
|
||||
bool AutoLearnSpellAction::Execute(Event event)
|
||||
{
|
||||
@@ -27,7 +28,6 @@ bool AutoLearnSpellAction::Execute(Event event)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void AutoLearnSpellAction::LearnSpells(std::ostringstream* out)
|
||||
{
|
||||
if (sPlayerbotAIConfig->autoLearnTrainerSpells && sRandomPlayerbotMgr->IsRandomBot(bot))// || (!botAI->GetMaster() && sRandomPlayerbotMgr->IsRandomBot(bot)))
|
||||
@@ -35,6 +35,21 @@ void AutoLearnSpellAction::LearnSpells(std::ostringstream* out)
|
||||
|
||||
if (sPlayerbotAIConfig->autoLearnQuestSpells && sRandomPlayerbotMgr->IsRandomBot(bot))// || (!botAI->GetMaster() && sRandomPlayerbotMgr->IsRandomBot(bot)))
|
||||
LearnQuestSpells(out);
|
||||
|
||||
if (sPlayerbotAIConfig->randomBotTalk)
|
||||
{
|
||||
Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId());
|
||||
if (guild)
|
||||
{
|
||||
std::map<std::string, std::string> placeholders;
|
||||
placeholders["%level"] = std::to_string(bot->GetLevel());
|
||||
|
||||
if (urand(0, 3))
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, BOT_TEXT2("Ding!", placeholders), LANG_UNIVERSAL);
|
||||
else
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, BOT_TEXT2("Yay level %level!", placeholders), LANG_UNIVERSAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AutoLearnSpellAction::LearnTrainerSpells(std::ostringstream* out)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "PlayerbotAIConfig.h"
|
||||
#include "Playerbots.h"
|
||||
#include "ServerFacade.h"
|
||||
#include "GuildMgr.h"
|
||||
|
||||
bool LootAction::Execute(Event event)
|
||||
{
|
||||
@@ -416,6 +417,22 @@ bool StoreLootAction::Execute(Event event)
|
||||
if (proto->Quality >= ITEM_QUALITY_RARE && !urand(0, 1) && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT))
|
||||
botAI->PlayEmote(TEXT_EMOTE_CHEER);
|
||||
|
||||
if (sPlayerbotAIConfig->randomBotTalk && bot->GetGuildId() && urand(0, 10) && proto->Quality >= ITEM_QUALITY_RARE)
|
||||
{
|
||||
Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId());
|
||||
|
||||
if (guild)
|
||||
{
|
||||
std::map<std::string, std::string> placeholders;
|
||||
placeholders["%name"] = chat->FormatItem(proto);
|
||||
|
||||
if (urand(0, 3))
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, BOT_TEXT2("Yay I looted %name!", placeholders), LANG_UNIVERSAL);
|
||||
else
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, BOT_TEXT2("Guess who got a %name? Me!", placeholders), LANG_UNIVERSAL);
|
||||
}
|
||||
}
|
||||
|
||||
// std::ostringstream out;
|
||||
// out << "Looting " << chat->FormatItem(proto);
|
||||
// botAI->TellMasterNoFacing(out.str());
|
||||
|
||||
@@ -130,26 +130,26 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32
|
||||
// if we're just commanding bots around, don't respond...
|
||||
// first one is for exact word matches
|
||||
if (noReplyMsgs.find(msg) != noReplyMsgs.end()) {
|
||||
std::ostringstream out;
|
||||
/*std::ostringstream out;
|
||||
out << "DEBUG ChatReplyDo decided to ignore exact blocklist match" << msg;
|
||||
bot->Say(out.str(), LANG_UNIVERSAL);
|
||||
bot->Say(out.str(), LANG_UNIVERSAL);*/
|
||||
return;
|
||||
}
|
||||
|
||||
// second one is for partial matches like + or - where we change strats
|
||||
if (std::any_of(noReplyMsgParts.begin(), noReplyMsgParts.end(), [&msg](const std::string& part) { return msg.find(part) != std::string::npos; })) {
|
||||
std::ostringstream out;
|
||||
/*std::ostringstream out;
|
||||
out << "DEBUG ChatReplyDo decided to ignore partial blocklist match" << msg;
|
||||
bot->Say(out.str(), LANG_UNIVERSAL);
|
||||
bot->Say(out.str(), LANG_UNIVERSAL);*/
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::any_of(noReplyMsgStarts.begin(), noReplyMsgStarts.end(), [&msg](const std::string& start) {
|
||||
return msg.find(start) == 0; // Check if the start matches the beginning of msg
|
||||
})) {
|
||||
std::ostringstream out;
|
||||
/*std::ostringstream out;
|
||||
out << "DEBUG ChatReplyDo decided to ignore start blocklist match" << msg;
|
||||
bot->Say(out.str(), LANG_UNIVERSAL);
|
||||
bot->Say(out.str(), LANG_UNIVERSAL);*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "Event.h"
|
||||
#include "PlayerbotAIConfig.h"
|
||||
#include "Playerbots.h"
|
||||
#include "GuildMgr.h"
|
||||
|
||||
bool XpGainAction::Execute(Event event)
|
||||
{
|
||||
@@ -32,6 +33,25 @@ bool XpGainAction::Execute(Event event)
|
||||
p >> groupBonus; // 8 group bonus
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->randomBotTalk && bot->GetGuildId() && urand(0, 10))
|
||||
{
|
||||
Creature* creature = botAI->GetCreature(guid);
|
||||
if (creature && (creature->isElite() || creature->isWorldBoss() || creature->GetLevel() > 61 || creature->GetLevel() > bot->GetLevel() + 4))
|
||||
{
|
||||
Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId());
|
||||
if (guild)
|
||||
{
|
||||
std::map<std::string, std::string> placeholders;
|
||||
placeholders["%name"] = creature->GetName();
|
||||
|
||||
if (urand(0, 3))
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, BOT_TEXT2("Wow I just killed %name!", placeholders), LANG_UNIVERSAL);
|
||||
else
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, BOT_TEXT2("Awesome that %name went down quickly!", placeholders), LANG_UNIVERSAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Unit* victim = nullptr;
|
||||
if (guid)
|
||||
victim = botAI->GetUnit(guid);
|
||||
|
||||
Reference in New Issue
Block a user