mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-17 02:40:28 +00:00
Refactoring bot chat and sayaction caused by group crash <NOT FINISHED>
This commit is contained in:
@@ -38,18 +38,9 @@ void AutoLearnSpellAction::LearnSpells(std::ostringstream* out)
|
||||
|
||||
if (sPlayerbotAIConfig->randomBotGuildTalk)
|
||||
{
|
||||
Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId());
|
||||
if (guild)
|
||||
{
|
||||
std::string toSay = "";
|
||||
|
||||
if (urand(0, 3))
|
||||
toSay = "Ding !";
|
||||
else
|
||||
toSay = "Yay level " + std::to_string(bot->GetLevel()) + " !";
|
||||
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, toSay, LANG_UNIVERSAL);
|
||||
}
|
||||
std::map<std::string, std::string> args;
|
||||
args["%my_level"] = std::to_string(bot->GetLevel());
|
||||
botAI->SayToGuild(BOT_TEXT2("broadcast_levelup_generic", args));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -417,21 +417,11 @@ 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->randomBotGuildTalk && bot->GetGuildId() && urand(0, 10) && proto->Quality >= ITEM_QUALITY_RARE)
|
||||
if (sPlayerbotAIConfig->randomBotGuildTalk && urand(0, 10) && proto->Quality >= ITEM_QUALITY_RARE)
|
||||
{
|
||||
Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId());
|
||||
|
||||
if (guild)
|
||||
{
|
||||
std::string toSay = "";
|
||||
|
||||
if (urand(0, 3))
|
||||
toSay = "Yay I looted " + chat->FormatItem(proto) + " !";
|
||||
else
|
||||
toSay = "Guess who got a " + chat->FormatItem(proto) + " ? Me !";
|
||||
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, toSay, LANG_UNIVERSAL);
|
||||
}
|
||||
std::map<std::string, std::string> args;
|
||||
args["%item"] = chat->FormatItem(proto);
|
||||
botAI->SayToGuild(BOT_TEXT2("loot_command", args));
|
||||
}
|
||||
|
||||
// std::ostringstream out;
|
||||
|
||||
@@ -153,11 +153,10 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32
|
||||
return;
|
||||
}
|
||||
|
||||
/*ChatChannelSource chatChannelSource = GET_PLAYERBOT_AI(bot)->GetChatChannelSource(bot, type, chanName);
|
||||
|
||||
ChatChannelSource chatChannelSource = GET_PLAYERBOT_AI(bot)->GetChatChannelSource(bot, type, chanName);
|
||||
if ( (msg.starts_with("LFG") || msg.starts_with("LFM")) && HandleLFGQuestsReply(bot, chatChannelSource, msg, name))
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.starts_with("WTB") && HandleWTBItemsReply(bot, chatChannelSource, msg, name))
|
||||
@@ -180,8 +179,7 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SendGeneralResponse(bot, chatChannelSource, GenerateReplyMessage(bot, msg, guid1, name), name);*/
|
||||
SendGeneralResponse(bot, chatChannelSource, GenerateReplyMessage(bot, msg, guid1, name), name);
|
||||
}
|
||||
|
||||
bool ChatReplyAction::HandleThunderfuryReply(Player* bot, ChatChannelSource chatChannelSource, std::string msg, std::string name)
|
||||
@@ -196,12 +194,12 @@ bool ChatReplyAction::HandleThunderfuryReply(Player* bot, ChatChannelSource chat
|
||||
{
|
||||
case ChatChannelSource::SRC_WORLD:
|
||||
{
|
||||
//GET_PLAYERBOT_AI(bot)->SayToWorld(responseMessage);
|
||||
GET_PLAYERBOT_AI(bot)->SayToWorld(responseMessage);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_GENERAL:
|
||||
{
|
||||
//GET_PLAYERBOT_AI(bot)->SayToGeneral(responseMessage);
|
||||
GET_PLAYERBOT_AI(bot)->SayToChannel(responseMessage, ChatChannelId::GENERAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -265,13 +263,13 @@ bool ChatReplyAction::HandleLFGQuestsReply(Player* bot, ChatChannelSource chatCh
|
||||
//may reply to the same channel or whisper
|
||||
if (urand(0, 1))
|
||||
{
|
||||
//std::string responseMessage = BOT_TEXT2("response_lfg_quests_channel", placeholders);
|
||||
//GET_PLAYERBOT_AI(bot)->SayToWorld(responseMessage);
|
||||
std::string responseMessage = BOT_TEXT2("response_lfg_quests_channel", placeholders);
|
||||
GET_PLAYERBOT_AI(bot)->SayToWorld(responseMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::string responseMessage = BOT_TEXT2("response_lfg_quests_whisper", placeholders);
|
||||
//GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
std::string responseMessage = BOT_TEXT2("response_lfg_quests_whisper", placeholders);
|
||||
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -280,13 +278,13 @@ bool ChatReplyAction::HandleLFGQuestsReply(Player* bot, ChatChannelSource chatCh
|
||||
//may reply to the same channel or whisper
|
||||
if (urand(0, 1))
|
||||
{
|
||||
//std::string responseMessage = BOT_TEXT2("response_lfg_quests_channel", placeholders);
|
||||
//GET_PLAYERBOT_AI(bot)->SayToGeneral(responseMessage);
|
||||
std::string responseMessage = BOT_TEXT2("response_lfg_quests_channel", placeholders);
|
||||
GET_PLAYERBOT_AI(bot)->SayToChannel(responseMessage, ChatChannelId::GENERAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::string responseMessage = BOT_TEXT2("response_lfg_quests_whisper", placeholders);
|
||||
//GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
std::string responseMessage = BOT_TEXT2("response_lfg_quests_whisper", placeholders);
|
||||
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -294,8 +292,8 @@ bool ChatReplyAction::HandleLFGQuestsReply(Player* bot, ChatChannelSource chatCh
|
||||
{
|
||||
//do not reply to the chat
|
||||
//may whisper
|
||||
//std::string responseMessage = BOT_TEXT2("response_lfg_quests_whisper", placeholders);
|
||||
//GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
std::string responseMessage = BOT_TEXT2("response_lfg_quests_whisper", placeholders);
|
||||
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -310,70 +308,70 @@ bool ChatReplyAction::SendGeneralResponse(Player* bot, ChatChannelSource chatCha
|
||||
// send responds
|
||||
switch (chatChannelSource)
|
||||
{
|
||||
case ChatChannelSource::SRC_WORLD:
|
||||
{
|
||||
//may reply to the same channel or whisper
|
||||
//GET_PLAYERBOT_AI(bot)->SayToWorld(responseMessage);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_GENERAL:
|
||||
{
|
||||
//may reply to the same channel or whisper
|
||||
//GET_PLAYERBOT_AI(bot)->SayToGeneral(responseMessage);
|
||||
//GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_TRADE:
|
||||
{
|
||||
//do not reply to the chat
|
||||
//may whisper
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_LOCAL_DEFENSE:
|
||||
{
|
||||
//may reply to the same channel or whisper
|
||||
//GET_PLAYERBOT_AI(bot)->SayToChannel(responseMessage, ChatChannelId::LOCAL_DEFENSE);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_WORLD_DEFENSE:
|
||||
{
|
||||
//may whisper
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_LOOKING_FOR_GROUP:
|
||||
{
|
||||
//do not reply to the chat
|
||||
//may whisper
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_GUILD_RECRUITMENT:
|
||||
{
|
||||
//do not reply to the chat
|
||||
//may whisper
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_WHISPER:
|
||||
{
|
||||
//GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_SAY:
|
||||
{
|
||||
//GET_PLAYERBOT_AI(bot)->Say(responseMessage);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_YELL:
|
||||
{
|
||||
//GET_PLAYERBOT_AI(bot)->Yell(responseMessage);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_GUILD:
|
||||
{
|
||||
//GET_PLAYERBOT_AI(bot)->SayToGuild(responseMessage);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
case ChatChannelSource::SRC_WORLD:
|
||||
{
|
||||
//may reply to the same channel or whisper
|
||||
GET_PLAYERBOT_AI(bot)->SayToWorld(responseMessage);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_GENERAL:
|
||||
{
|
||||
//may reply to the same channel or whisper
|
||||
GET_PLAYERBOT_AI(bot)->SayToChannel(responseMessage, ChatChannelId::GENERAL);
|
||||
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_TRADE:
|
||||
{
|
||||
//do not reply to the chat
|
||||
//may whisper
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_LOCAL_DEFENSE:
|
||||
{
|
||||
//may reply to the same channel or whisper
|
||||
GET_PLAYERBOT_AI(bot)->SayToChannel(responseMessage, ChatChannelId::LOCAL_DEFENSE);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_WORLD_DEFENSE:
|
||||
{
|
||||
//may whisper
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_LOOKING_FOR_GROUP:
|
||||
{
|
||||
//do not reply to the chat
|
||||
//may whisper
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_GUILD_RECRUITMENT:
|
||||
{
|
||||
//do not reply to the chat
|
||||
//may whisper
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_WHISPER:
|
||||
{
|
||||
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_SAY:
|
||||
{
|
||||
GET_PLAYERBOT_AI(bot)->Say(responseMessage);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_YELL:
|
||||
{
|
||||
GET_PLAYERBOT_AI(bot)->Yell(responseMessage);
|
||||
break;
|
||||
}
|
||||
case ChatChannelSource::SRC_GUILD:
|
||||
{
|
||||
GET_PLAYERBOT_AI(bot)->SayToGuild(responseMessage);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<time_t>("last said", "chat")->Set(time(0) + urand(5, 25));
|
||||
|
||||
@@ -856,4 +854,4 @@ std::string ChatReplyAction::GenerateReplyMessage(Player* bot, std::string incom
|
||||
}
|
||||
|
||||
return respondsText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,8 +281,6 @@ void SuggestWhatToDoAction::spam(std::string msg, uint8 flags, bool worldChat, b
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bot->IsInChannel(chn))
|
||||
chn->JoinChannel(bot, "");
|
||||
chn->Say(bot->GetGUID(), msg.c_str(), LANG_UNIVERSAL);
|
||||
}
|
||||
|
||||
@@ -291,9 +289,6 @@ void SuggestWhatToDoAction::spam(std::string msg, uint8 flags, bool worldChat, b
|
||||
std::string randomName = channelNames[urand(0, channelNames.size() - 1)];
|
||||
if (Channel* chn = cMgr->GetChannel(randomName, bot))
|
||||
{
|
||||
if (!bot->IsInChannel(chn))
|
||||
chn->JoinChannel(bot, "");
|
||||
|
||||
chn->Say(bot->GetGUID(), msg.c_str(), LANG_UNIVERSAL);
|
||||
}
|
||||
}
|
||||
@@ -305,11 +300,9 @@ void SuggestWhatToDoAction::spam(std::string msg, uint8 flags, bool worldChat, b
|
||||
}
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->randomBotGuildTalk && guild && bot->GetGuildId())
|
||||
if (sPlayerbotAIConfig->randomBotGuildTalk)
|
||||
{
|
||||
Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId());
|
||||
if (guild)
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, msg.c_str(), LANG_UNIVERSAL);
|
||||
botAI->SayToGuild(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,14 +41,9 @@ bool XpGainAction::Execute(Event event)
|
||||
Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId());
|
||||
if (guild)
|
||||
{
|
||||
std::string toSay = "";
|
||||
|
||||
if (urand(0, 3))
|
||||
toSay = "Wow I just killed " + creature->GetName() + " !";
|
||||
else
|
||||
toSay = "Awesome that " + creature->GetName() + " went down quickly !";
|
||||
|
||||
guild->BroadcastToGuild(bot->GetSession(), false, toSay, LANG_UNIVERSAL);
|
||||
std::map<std::string, std::string> args;
|
||||
args["%victim_name"] = creature->GetName();
|
||||
botAI->SayToGuild(BOT_TEXT2("broadcast_killed_rare", args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user