mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-21 02:20:00 +01:00
Allow bot to talk in guild when they loot nice item, levelup, kill unique monsters
This commit is contained in:
parent
00844985eb
commit
1fbd312d58
@ -6,6 +6,7 @@
|
|||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "PlayerbotFactory.h"
|
#include "PlayerbotFactory.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
#include "GuildMgr.h"
|
||||||
|
|
||||||
bool AutoLearnSpellAction::Execute(Event event)
|
bool AutoLearnSpellAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
@ -27,7 +28,6 @@ bool AutoLearnSpellAction::Execute(Event event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AutoLearnSpellAction::LearnSpells(std::ostringstream* out)
|
void AutoLearnSpellAction::LearnSpells(std::ostringstream* out)
|
||||||
{
|
{
|
||||||
if (sPlayerbotAIConfig->autoLearnTrainerSpells && sRandomPlayerbotMgr->IsRandomBot(bot))// || (!botAI->GetMaster() && sRandomPlayerbotMgr->IsRandomBot(bot)))
|
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)))
|
if (sPlayerbotAIConfig->autoLearnQuestSpells && sRandomPlayerbotMgr->IsRandomBot(bot))// || (!botAI->GetMaster() && sRandomPlayerbotMgr->IsRandomBot(bot)))
|
||||||
LearnQuestSpells(out);
|
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)
|
void AutoLearnSpellAction::LearnTrainerSpells(std::ostringstream* out)
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
#include "PlayerbotAIConfig.h"
|
#include "PlayerbotAIConfig.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
#include "ServerFacade.h"
|
#include "ServerFacade.h"
|
||||||
|
#include "GuildMgr.h"
|
||||||
|
|
||||||
bool LootAction::Execute(Event event)
|
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))
|
if (proto->Quality >= ITEM_QUALITY_RARE && !urand(0, 1) && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT))
|
||||||
botAI->PlayEmote(TEXT_EMOTE_CHEER);
|
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;
|
// std::ostringstream out;
|
||||||
// out << "Looting " << chat->FormatItem(proto);
|
// out << "Looting " << chat->FormatItem(proto);
|
||||||
// botAI->TellMasterNoFacing(out.str());
|
// 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...
|
// if we're just commanding bots around, don't respond...
|
||||||
// first one is for exact word matches
|
// first one is for exact word matches
|
||||||
if (noReplyMsgs.find(msg) != noReplyMsgs.end()) {
|
if (noReplyMsgs.find(msg) != noReplyMsgs.end()) {
|
||||||
std::ostringstream out;
|
/*std::ostringstream out;
|
||||||
out << "DEBUG ChatReplyDo decided to ignore exact blocklist match" << msg;
|
out << "DEBUG ChatReplyDo decided to ignore exact blocklist match" << msg;
|
||||||
bot->Say(out.str(), LANG_UNIVERSAL);
|
bot->Say(out.str(), LANG_UNIVERSAL);*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// second one is for partial matches like + or - where we change strats
|
// 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; })) {
|
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;
|
out << "DEBUG ChatReplyDo decided to ignore partial blocklist match" << msg;
|
||||||
bot->Say(out.str(), LANG_UNIVERSAL);
|
bot->Say(out.str(), LANG_UNIVERSAL);*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::any_of(noReplyMsgStarts.begin(), noReplyMsgStarts.end(), [&msg](const std::string& start) {
|
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
|
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;
|
out << "DEBUG ChatReplyDo decided to ignore start blocklist match" << msg;
|
||||||
bot->Say(out.str(), LANG_UNIVERSAL);
|
bot->Say(out.str(), LANG_UNIVERSAL);*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "PlayerbotAIConfig.h"
|
#include "PlayerbotAIConfig.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
#include "GuildMgr.h"
|
||||||
|
|
||||||
bool XpGainAction::Execute(Event event)
|
bool XpGainAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
@ -32,6 +33,25 @@ bool XpGainAction::Execute(Event event)
|
|||||||
p >> groupBonus; // 8 group bonus
|
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;
|
Unit* victim = nullptr;
|
||||||
if (guid)
|
if (guid)
|
||||||
victim = botAI->GetUnit(guid);
|
victim = botAI->GetUnit(guid);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user