diff --git a/src/RandomPlayerbotFactory.cpp b/src/RandomPlayerbotFactory.cpp index 37d6ba49..cf5fdc91 100644 --- a/src/RandomPlayerbotFactory.cpp +++ b/src/RandomPlayerbotFactory.cpp @@ -892,7 +892,7 @@ void RandomPlayerbotFactory::CreateRandomGuilds() availableLeaders.push_back(leader); } } - + // Create up to randomBotGuildCount by counting only EFFECTIVE creations uint32 createdThisRun = 0; for (; guildNumber < sPlayerbotAIConfig->randomBotGuildCount; /* ++guildNumber -> done only if creation */) @@ -972,7 +972,7 @@ void RandomPlayerbotFactory::CreateRandomGuilds() LOG_DEBUG("playerbots", "[TABARD] DB check guild id={} => style={}, color={}, borderStyle={}, borderColor={}, bgColor={}", guild->GetId(), f[0].Get(), f[1].Get(), f[2].Get(), f[3].Get(), f[4].Get()); - } + } sPlayerbotAIConfig->randomBotGuilds.push_back(guild->GetId()); // The guild is only counted if it is actually created diff --git a/src/strategy/actions/GenericBuffUtils.cpp b/src/strategy/actions/GenericBuffUtils.cpp index fb27a234..9e227caf 100644 --- a/src/strategy/actions/GenericBuffUtils.cpp +++ b/src/strategy/actions/GenericBuffUtils.cpp @@ -21,122 +21,125 @@ namespace ai::buff { - std::string MakeAuraQualifierForBuff(std::string const& name) - { - // Paladin - if (name == "blessing of kings") return "blessing of kings,greater blessing of kings"; - if (name == "blessing of might") return "blessing of might,greater blessing of might"; - if (name == "blessing of wisdom") return "blessing of wisdom,greater blessing of wisdom"; - if (name == "blessing of sanctuary") return "blessing of sanctuary,greater blessing of sanctuary"; - // Druid - if (name == "mark of the wild") return "mark of the wild,gift of the wild"; - // Mage - if (name == "arcane intellect") return "arcane intellect,arcane brilliance"; - // Priest - if (name == "power word: fortitude") return "power word: fortitude,prayer of fortitude"; - return name; - } + std::string MakeAuraQualifierForBuff(std::string const& name) + { + // Paladin + if (name == "blessing of kings") return "blessing of kings,greater blessing of kings"; + if (name == "blessing of might") return "blessing of might,greater blessing of might"; + if (name == "blessing of wisdom") return "blessing of wisdom,greater blessing of wisdom"; + if (name == "blessing of sanctuary") return "blessing of sanctuary,greater blessing of sanctuary"; + // Druid + if (name == "mark of the wild") return "mark of the wild,gift of the wild"; + // Mage + if (name == "arcane intellect") return "arcane intellect,arcane brilliance"; + // Priest + if (name == "power word: fortitude") return "power word: fortitude,prayer of fortitude"; - std::string GroupVariantFor(std::string const& name) - { - // Paladin - if (name == "blessing of kings") return "greater blessing of kings"; - if (name == "blessing of might") return "greater blessing of might"; - if (name == "blessing of wisdom") return "greater blessing of wisdom"; - if (name == "blessing of sanctuary") return "greater blessing of sanctuary"; - // Druid - if (name == "mark of the wild") return "gift of the wild"; - // Mage - if (name == "arcane intellect") return "arcane brilliance"; - // Priest - if (name == "power word: fortitude") return "prayer of fortitude"; + return name; + } - return std::string(); - } + std::string GroupVariantFor(std::string const& name) + { + // Paladin + if (name == "blessing of kings") return "greater blessing of kings"; + if (name == "blessing of might") return "greater blessing of might"; + if (name == "blessing of wisdom") return "greater blessing of wisdom"; + if (name == "blessing of sanctuary") return "greater blessing of sanctuary"; + // Druid + if (name == "mark of the wild") return "gift of the wild"; + // Mage + if (name == "arcane intellect") return "arcane brilliance"; + // Priest + if (name == "power word: fortitude") return "prayer of fortitude"; - bool HasRequiredReagents(Player* bot, uint32 spellId) - { - if (!spellId) - return false; + return std::string(); + } - if (SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId)) - { for (int i = 0; i < MAX_SPELL_REAGENTS; ++i) - { - if (info->Reagent[i] > 0) - { - uint32 const itemId = info->Reagent[i]; - int32 const need = info->ReagentCount[i]; - if ((int32)bot->GetItemCount(itemId, false) < need) - return false; - } - } - // No reagent required - return true; - } - return false; - } + bool HasRequiredReagents(Player* bot, uint32 spellId) + { + if (!spellId) + return false; - std::string UpgradeToGroupIfAppropriate( - Player* bot, - PlayerbotAI* botAI, - std::string const& baseName, - bool announceOnMissing, - std::function announce) - { - std::string castName = baseName; Group* g = bot->GetGroup(); - if (!g || g->GetMembersCount() < static_cast(sPlayerbotAIConfig->minBotsForGreaterBuff)) - return castName; // Group too small: stay in solo mode + if (SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId)) + { + for (int i = 0; i < MAX_SPELL_REAGENTS; ++i) + { + if (info->Reagent[i] > 0) + { + uint32 const itemId = info->Reagent[i]; + int32 const need = info->ReagentCount[i]; + if ((int32)bot->GetItemCount(itemId, false) < need) + return false; + } + } + // No reagent required + return true; + } + return false; + } - if (std::string const groupName = GroupVariantFor(baseName); !groupName.empty()) - { - uint32 const groupVariantSpellId = botAI->GetAiObjectContext() - ->GetValue("spell id", groupName)->Get(); + std::string UpgradeToGroupIfAppropriate( + Player* bot, + PlayerbotAI* botAI, + std::string const& baseName, + bool announceOnMissing, + std::function announce) + { + std::string castName = baseName; + Group* g = bot->GetGroup(); + if (!g || g->GetMembersCount() < static_cast(sPlayerbotAIConfig->minBotsForGreaterBuff)) + return castName; // Group too small: stay in solo mode - // We check usefulness on the **basic** buff (not the greater version), - // because "spell cast useful" may return false for the greater variant. - bool const usefulBase = botAI->GetAiObjectContext() - ->GetValue("spell cast useful", baseName)->Get(); + if (std::string const groupName = GroupVariantFor(baseName); !groupName.empty()) + { + uint32 const groupVariantSpellId = botAI->GetAiObjectContext() + ->GetValue("spell id", groupName)->Get(); - if (groupVariantSpellId && HasRequiredReagents(bot, groupVariantSpellId)) - { - // Learned + reagents OK -> switch to greater - return groupName; - } + // We check usefulness on the **basic** buff (not the greater version), + // because "spell cast useful" may return false for the greater variant. + bool const usefulBase = botAI->GetAiObjectContext() + ->GetValue("spell cast useful", baseName)->Get(); - // Missing reagents -> announce if (a) greater is known, (b) base buff is useful, - // (c) announce was requested, (d) a callback is provided. - if (announceOnMissing && groupVariantSpellId && usefulBase && announce) - { - static std::map, time_t> s_lastWarn; // par bot & par buff - time_t now = std::time(nullptr); - uint32 botLow = static_cast(bot->GetGUID().GetCounter()); - time_t& last = s_lastWarn[ std::make_pair(botLow, groupName) ]; - if (!last || now - last >= sPlayerbotAIConfig->rpWarningCooldown) // Configurable anti-spam - { - // DB Key choice in regard of the buff - std::string key; - if (groupName.find("greater blessing") != std::string::npos) - key = "rp_missing_reagent_greater_blessing"; - else if (groupName == "gift of the wild") - key = "rp_missing_reagent_gift_of_the_wild"; - else if (groupName == "arcane brilliance") - key = "rp_missing_reagent_arcane_brilliance"; - else - key = "rp_missing_reagent_generic"; + if (groupVariantSpellId && HasRequiredReagents(bot, groupVariantSpellId)) + { + // Learned + reagents OK -> switch to greater + return groupName; + } - // Placeholders - std::map placeholders; - placeholders["%group_spell"] = groupName; - placeholders["%base_spell"] = baseName; + // Missing reagents -> announce if (a) greater is known, (b) base buff is useful, + // (c) announce was requested, (d) a callback is provided. + if (announceOnMissing && groupVariantSpellId && usefulBase && announce) + { + static std::map, time_t> s_lastWarn; // par bot & par buff + time_t now = std::time(nullptr); + uint32 botLow = static_cast(bot->GetGUID().GetCounter()); + time_t& last = s_lastWarn[ std::make_pair(botLow, groupName) ]; + if (!last || now - last >= sPlayerbotAIConfig->rpWarningCooldown) // Configurable anti-spam + { + // DB Key choice in regard of the buff + std::string key; + if (groupName.find("greater blessing") != std::string::npos) + key = "rp_missing_reagent_greater_blessing"; + else if (groupName == "gift of the wild") + key = "rp_missing_reagent_gift_of_the_wild"; + else if (groupName == "arcane brilliance") + key = "rp_missing_reagent_arcane_brilliance"; + else + key = "rp_missing_reagent_generic"; - std::string announceText = sPlayerbotTextMgr->GetBotTextOrDefault(key, - "Out of components for %group_spell. Using %base_spell!", placeholders); + // Placeholders + std::map placeholders; + placeholders["%group_spell"] = groupName; + placeholders["%base_spell"] = baseName; - announce(announceText); - last = now; - } - } - } - return castName; - } + std::string announceText = sPlayerbotTextMgr->GetBotTextOrDefault(key, + "Out of components for %group_spell. Using %base_spell!", placeholders); + + announce(announceText); + last = now; + } + } + } + return castName; + } }