mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-13 09:07:19 +00:00
Add quest rewards to gear initialization
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "AiFactory.h"
|
||||
#include "BudgetValues.h"
|
||||
#include "ChannelMgr.h"
|
||||
#include "CharacterPackets.h"
|
||||
#include "CreatureAIImpl.h"
|
||||
#include "EmoteAction.h"
|
||||
@@ -45,10 +46,6 @@
|
||||
#include "Unit.h"
|
||||
#include "UpdateTime.h"
|
||||
#include "Vehicle.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "SayAction.h"
|
||||
#include "ChannelMgr.h"
|
||||
|
||||
|
||||
std::vector<std::string> PlayerbotAI::dispel_whitelist = {
|
||||
"mutating injection",
|
||||
@@ -351,11 +348,12 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal
|
||||
return;
|
||||
|
||||
std::string const mapString = WorldPosition(bot).isOverworld() ? std::to_string(bot->GetMapId()) : "I";
|
||||
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_TOTAL, "PlayerbotAI::UpdateAIInternal " + mapString);
|
||||
PerformanceMonitorOperation* pmo =
|
||||
sPerformanceMonitor->start(PERF_MON_TOTAL, "PlayerbotAI::UpdateAIInternal " + mapString);
|
||||
ExternalEventHelper helper(aiObjectContext);
|
||||
|
||||
// chat replies
|
||||
for (auto it = chatReplies.begin(); it != chatReplies.end(); )
|
||||
for (auto it = chatReplies.begin(); it != chatReplies.end();)
|
||||
{
|
||||
time_t checkTime = it->m_time;
|
||||
if (checkTime && time(0) < checkTime)
|
||||
@@ -425,7 +423,7 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal
|
||||
void PlayerbotAI::HandleCommands()
|
||||
{
|
||||
ExternalEventHelper helper(aiObjectContext);
|
||||
for (auto it = chatCommands.begin(); it != chatCommands.end(); )
|
||||
for (auto it = chatCommands.begin(); it != chatCommands.end();)
|
||||
{
|
||||
time_t& checkTime = it->GetTime();
|
||||
if (checkTime && time(0) < checkTime)
|
||||
@@ -438,9 +436,9 @@ void PlayerbotAI::HandleCommands()
|
||||
Player* owner = it->GetOwner();
|
||||
if (!helper.ParseChatCommand(command, owner) && it->GetType() == CHAT_MSG_WHISPER)
|
||||
{
|
||||
//ostringstream out; out << "Unknown command " << command;
|
||||
//TellPlayer(out);
|
||||
//helper.ParseChatCommand("help");
|
||||
// ostringstream out; out << "Unknown command " << command;
|
||||
// TellPlayer(out);
|
||||
// helper.ParseChatCommand("help");
|
||||
}
|
||||
it = chatCommands.erase(it);
|
||||
}
|
||||
@@ -451,15 +449,16 @@ void PlayerbotAI::HandleCommand(uint32 type, const std::string& text, Player& fr
|
||||
{
|
||||
std::string filtered = text;
|
||||
|
||||
if (!IsAllowedCommand(filtered) && !GetSecurity()->CheckLevelFor(PlayerbotSecurityLevel::PLAYERBOT_SECURITY_INVITE, type != CHAT_MSG_WHISPER, &fromPlayer))
|
||||
if (!IsAllowedCommand(filtered) && !GetSecurity()->CheckLevelFor(PlayerbotSecurityLevel::PLAYERBOT_SECURITY_INVITE,
|
||||
type != CHAT_MSG_WHISPER, &fromPlayer))
|
||||
return;
|
||||
|
||||
if (type == CHAT_MSG_ADDON)
|
||||
return;
|
||||
|
||||
if (filtered.find("BOT\t") == 0) //Mangosbot has BOT prefix so we remove that.
|
||||
if (filtered.find("BOT\t") == 0) // Mangosbot has BOT prefix so we remove that.
|
||||
filtered = filtered.substr(4);
|
||||
else if (lang == LANG_ADDON) //Other addon messages should not command bots.
|
||||
else if (lang == LANG_ADDON) // Other addon messages should not command bots.
|
||||
return;
|
||||
|
||||
if (type == CHAT_MSG_SYSTEM)
|
||||
@@ -511,22 +510,26 @@ void PlayerbotAI::HandleCommand(uint32 type, const std::string& text, Player& fr
|
||||
{
|
||||
std::string response = HandleRemoteCommand(filtered.substr(6));
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_ADDON, response.c_str(), LANG_ADDON,
|
||||
CHAT_TAG_NONE, bot->GetGUID(), bot->GetName());
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_ADDON, response.c_str(), LANG_ADDON, CHAT_TAG_NONE, bot->GetGUID(),
|
||||
bot->GetName());
|
||||
sServerFacade->SendPacket(&fromPlayer, &data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsAllowedCommand(filtered) && !GetSecurity()->CheckLevelFor(PlayerbotSecurityLevel::PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, &fromPlayer))
|
||||
if (!IsAllowedCommand(filtered) &&
|
||||
!GetSecurity()->CheckLevelFor(PlayerbotSecurityLevel::PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER,
|
||||
&fromPlayer))
|
||||
return;
|
||||
|
||||
if (type == CHAT_MSG_RAID_WARNING && filtered.find(bot->GetName()) != std::string::npos && filtered.find("award") == std::string::npos)
|
||||
if (type == CHAT_MSG_RAID_WARNING && filtered.find(bot->GetName()) != std::string::npos &&
|
||||
filtered.find("award") == std::string::npos)
|
||||
{
|
||||
chatCommands.push_back(ChatCommandHolder("warning", &fromPlayer, type));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((filtered.size() > 2 && filtered.substr(0, 2) == "d ") || (filtered.size() > 3 && filtered.substr(0, 3) == "do "))
|
||||
if ((filtered.size() > 2 && filtered.substr(0, 2) == "d ") ||
|
||||
(filtered.size() > 3 && filtered.substr(0, 3) == "do "))
|
||||
{
|
||||
Event event("do", "", &fromPlayer);
|
||||
std::string action = filtered.substr(filtered.find(" ") + 1);
|
||||
@@ -590,7 +593,8 @@ void PlayerbotAI::HandleCommand(uint32 type, const std::string& text, Player& fr
|
||||
SetShouldLogOut(false);
|
||||
}
|
||||
}
|
||||
else if ((filtered.size() > 5) && (filtered.substr(0, 5) == "wait ") && (filtered.find("wait for attack") == std::string::npos))
|
||||
else if ((filtered.size() > 5) && (filtered.substr(0, 5) == "wait ") && (filtered.find("wait for attack") ==
|
||||
std::string::npos))
|
||||
{
|
||||
std::string remaining = filtered.substr(filtered.find(" ") + 1);
|
||||
uint32 delay = atof(remaining.c_str()) * IN_MILLISECONDS;
|
||||
@@ -928,10 +932,10 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet)
|
||||
{
|
||||
if (!sPlayerbotAIConfig->randomBotTalk)
|
||||
return;
|
||||
|
||||
|
||||
if (!AllowActivity())
|
||||
return;
|
||||
|
||||
|
||||
WorldPacket p(packet);
|
||||
if (!p.empty() && (p.GetOpcode() == SMSG_MESSAGECHAT || p.GetOpcode() == SMSG_GM_MESSAGECHAT))
|
||||
{
|
||||
@@ -1019,8 +1023,8 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet)
|
||||
if (isFromFreeBot && urand(0, 20))
|
||||
return;
|
||||
|
||||
//if (msgtype == CHAT_MSG_GUILD && (!sPlayerbotAIConfig->guildRepliesRate || urand(1, 100) >= sPlayerbotAIConfig->guildRepliesRate))
|
||||
//return;
|
||||
// if (msgtype == CHAT_MSG_GUILD && (!sPlayerbotAIConfig->guildRepliesRate || urand(1, 100) >=
|
||||
// sPlayerbotAIConfig->guildRepliesRate)) return;
|
||||
|
||||
if (!isFromFreeBot)
|
||||
{
|
||||
@@ -1034,7 +1038,9 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet)
|
||||
}
|
||||
}
|
||||
|
||||
QueueChatResponse(std::move(ChatQueuedReply{msgtype, guid1.GetCounter(), guid2.GetCounter(), message, chanName, name, time(nullptr) + urand(inCombat ? 10 : 5, inCombat ? 25 : 15)}));
|
||||
QueueChatResponse(
|
||||
std::move(ChatQueuedReply{msgtype, guid1.GetCounter(), guid2.GetCounter(), message, chanName,
|
||||
name, time(nullptr) + urand(inCombat ? 10 : 5, inCombat ? 25 : 15)}));
|
||||
GetAiObjectContext()->GetValue<time_t>("last said", "chat")->Set(time(0) + urand(5, 25));
|
||||
return;
|
||||
}
|
||||
@@ -2182,19 +2188,21 @@ WorldObject* PlayerbotAI::GetWorldObject(ObjectGuid guid)
|
||||
|
||||
const AreaTableEntry* PlayerbotAI::GetCurrentArea()
|
||||
{
|
||||
return sAreaTableStore.LookupEntry(bot->GetMap()->GetAreaId(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()));
|
||||
return sAreaTableStore.LookupEntry(
|
||||
bot->GetMap()->GetAreaId(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()));
|
||||
}
|
||||
|
||||
const AreaTableEntry* PlayerbotAI::GetCurrentZone()
|
||||
{
|
||||
return sAreaTableStore.LookupEntry(bot->GetMap()->GetZoneId(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()));
|
||||
return sAreaTableStore.LookupEntry(
|
||||
bot->GetMap()->GetZoneId(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()));
|
||||
}
|
||||
|
||||
std::string PlayerbotAI::GetLocalizedAreaName(const AreaTableEntry* entry)
|
||||
{
|
||||
if (entry)
|
||||
return entry->area_name[sWorld->GetDefaultDbcLocale()];
|
||||
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -2254,7 +2262,7 @@ bool PlayerbotAI::SayToWorld(const std::string& msg)
|
||||
if (!cMgr)
|
||||
return false;
|
||||
|
||||
//no zone
|
||||
// no zone
|
||||
if (Channel* worldChannel = cMgr->GetChannel("World", bot))
|
||||
{
|
||||
worldChannel->Say(bot->GetGUID(), msg.c_str(), LANG_UNIVERSAL);
|
||||
@@ -2277,7 +2285,7 @@ bool PlayerbotAI::SayToChannel(const std::string& msg, const ChatChannelId& chan
|
||||
const auto current_str_zone = GetLocalizedAreaName(current_zone);
|
||||
for (auto const& [key, channel] : cMgr->GetChannels())
|
||||
{
|
||||
//check for current zone
|
||||
// check for current zone
|
||||
if (channel && channel->GetChannelId() == chanId)
|
||||
{
|
||||
const auto does_contains = channel->GetName().find(current_str_zone) != std::string::npos;
|
||||
@@ -2304,7 +2312,8 @@ bool PlayerbotAI::SayToParty(const std::string& msg)
|
||||
return false;
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_PARTY, msg.c_str(), LANG_UNIVERSAL, CHAT_TAG_NONE, bot->GetGUID(), bot->GetName());
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_PARTY, msg.c_str(), LANG_UNIVERSAL, CHAT_TAG_NONE, bot->GetGUID(),
|
||||
bot->GetName());
|
||||
|
||||
for (auto reciever : GetPlayersInGroup())
|
||||
{
|
||||
@@ -2320,7 +2329,8 @@ bool PlayerbotAI::SayToRaid(const std::string& msg)
|
||||
return false;
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID, msg.c_str(), LANG_UNIVERSAL, CHAT_TAG_NONE, bot->GetGUID(), bot->GetName());
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID, msg.c_str(), LANG_UNIVERSAL, CHAT_TAG_NONE, bot->GetGUID(),
|
||||
bot->GetName());
|
||||
|
||||
for (auto reciever : GetPlayersInGroup())
|
||||
{
|
||||
@@ -2772,7 +2782,7 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
if (target->IsImmunedToSpell(spellInfo))
|
||||
{
|
||||
if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster()))
|
||||
@@ -4767,27 +4777,18 @@ Item* PlayerbotAI::FindOilFor(Item* weapon) const
|
||||
return nullptr;
|
||||
|
||||
// static const will only get created once whatever the call amout
|
||||
static const std::vector<uint32_t> uPriorizedWizardOilIds =
|
||||
{
|
||||
MINOR_WIZARD_OIL, MINOR_MANA_OIL,
|
||||
LESSER_WIZARD_OIL, LESSER_MANA_OIL,
|
||||
BRILLIANT_WIZARD_OIL, BRILLIANT_MANA_OIL,
|
||||
WIZARD_OIL, SUPERIOR_MANA_OIL, SUPERIOR_WIZARD_OIL
|
||||
};
|
||||
static const std::vector<uint32_t> uPriorizedWizardOilIds = {
|
||||
MINOR_WIZARD_OIL, MINOR_MANA_OIL, LESSER_WIZARD_OIL, LESSER_MANA_OIL, BRILLIANT_WIZARD_OIL,
|
||||
BRILLIANT_MANA_OIL, WIZARD_OIL, SUPERIOR_MANA_OIL, SUPERIOR_WIZARD_OIL};
|
||||
|
||||
// static const will only get created once whatever the call amout
|
||||
static const std::vector<uint32_t> uPriorizedManaOilIds =
|
||||
{
|
||||
MINOR_MANA_OIL, MINOR_WIZARD_OIL,
|
||||
LESSER_MANA_OIL, LESSER_WIZARD_OIL,
|
||||
BRILLIANT_MANA_OIL, BRILLIANT_WIZARD_OIL,
|
||||
SUPERIOR_MANA_OIL, WIZARD_OIL, SUPERIOR_WIZARD_OIL
|
||||
};
|
||||
static const std::vector<uint32_t> uPriorizedManaOilIds = {
|
||||
MINOR_MANA_OIL, MINOR_WIZARD_OIL, LESSER_MANA_OIL, LESSER_WIZARD_OIL, BRILLIANT_MANA_OIL,
|
||||
BRILLIANT_WIZARD_OIL, SUPERIOR_MANA_OIL, WIZARD_OIL, SUPERIOR_WIZARD_OIL};
|
||||
|
||||
Item* oil = nullptr;
|
||||
if (item_template->SubClass == ITEM_SUBCLASS_WEAPON_SWORD ||
|
||||
item_template->SubClass == ITEM_SUBCLASS_WEAPON_STAFF ||
|
||||
item_template->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)
|
||||
if (item_template->SubClass == ITEM_SUBCLASS_WEAPON_SWORD ||
|
||||
item_template->SubClass == ITEM_SUBCLASS_WEAPON_STAFF || item_template->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)
|
||||
{
|
||||
for (const auto& id : uPriorizedWizardOilIds)
|
||||
{
|
||||
@@ -4797,7 +4798,7 @@ Item* PlayerbotAI::FindOilFor(Item* weapon) const
|
||||
}
|
||||
}
|
||||
else if (item_template->SubClass == ITEM_SUBCLASS_WEAPON_MACE ||
|
||||
item_template->SubClass == ITEM_SUBCLASS_WEAPON_MACE2)
|
||||
item_template->SubClass == ITEM_SUBCLASS_WEAPON_MACE2)
|
||||
{
|
||||
for (const auto& id : uPriorizedManaOilIds)
|
||||
{
|
||||
@@ -4940,7 +4941,6 @@ uint32 PlayerbotAI::GetInventoryItemsCountWithId(uint32 itemId)
|
||||
|
||||
bool PlayerbotAI::HasItemInInventory(uint32 itemId)
|
||||
{
|
||||
|
||||
for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if (Bag* pBag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
@@ -5167,10 +5167,7 @@ bool PlayerbotAI::IsInRealGuild()
|
||||
return !(sPlayerbotAIConfig->IsInRandomAccountList(leaderAccount));
|
||||
}
|
||||
|
||||
void PlayerbotAI::QueueChatResponse(const ChatQueuedReply chatReply)
|
||||
{
|
||||
chatReplies.push_back(std::move(chatReply));
|
||||
}
|
||||
void PlayerbotAI::QueueChatResponse(const ChatQueuedReply chatReply) { chatReplies.push_back(std::move(chatReply)); }
|
||||
|
||||
bool PlayerbotAI::EqualLowercaseName(std::string s1, std::string s2)
|
||||
{
|
||||
@@ -5507,11 +5504,13 @@ uint8 PlayerbotAI::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool sw
|
||||
|
||||
bool PlayerbotAI::IsSafe(Player* player)
|
||||
{
|
||||
return player && player->GetMapId() == bot->GetMapId() && player->GetInstanceId() == bot->GetInstanceId() && !player->IsBeingTeleported();
|
||||
return player && player->GetMapId() == bot->GetMapId() && player->GetInstanceId() == bot->GetInstanceId() &&
|
||||
!player->IsBeingTeleported();
|
||||
}
|
||||
bool PlayerbotAI::IsSafe(WorldObject* obj)
|
||||
{
|
||||
return obj && obj->GetMapId() == bot->GetMapId() && obj->GetInstanceId() == bot->GetInstanceId() && (!obj->IsPlayer() || !((Player*)obj)->IsBeingTeleported());
|
||||
return obj && obj->GetMapId() == bot->GetMapId() && obj->GetInstanceId() == bot->GetInstanceId() &&
|
||||
(!obj->IsPlayer() || !((Player*)obj)->IsBeingTeleported());
|
||||
}
|
||||
ChatChannelSource PlayerbotAI::GetChatChannelSource(Player* bot, uint32 type, std::string channelName)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user