mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix spacing issue and removed unnecessary spaces (#1684)
* Fix spacing issue and removed unnecessary spaces * Added spaces where suggested
This commit is contained in:
@@ -892,7 +892,7 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
|
|||||||
availableLeaders.push_back(leader);
|
availableLeaders.push_back(leader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create up to randomBotGuildCount by counting only EFFECTIVE creations
|
// Create up to randomBotGuildCount by counting only EFFECTIVE creations
|
||||||
uint32 createdThisRun = 0;
|
uint32 createdThisRun = 0;
|
||||||
for (; guildNumber < sPlayerbotAIConfig->randomBotGuildCount; /* ++guildNumber -> done only if creation */)
|
for (; guildNumber < sPlayerbotAIConfig->randomBotGuildCount; /* ++guildNumber -> done only if creation */)
|
||||||
@@ -972,7 +972,7 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
|
|||||||
LOG_DEBUG("playerbots",
|
LOG_DEBUG("playerbots",
|
||||||
"[TABARD] DB check guild id={} => style={}, color={}, borderStyle={}, borderColor={}, bgColor={}",
|
"[TABARD] DB check guild id={} => style={}, color={}, borderStyle={}, borderColor={}, bgColor={}",
|
||||||
guild->GetId(), f[0].Get<uint8>(), f[1].Get<uint8>(), f[2].Get<uint8>(), f[3].Get<uint8>(), f[4].Get<uint8>());
|
guild->GetId(), f[0].Get<uint8>(), f[1].Get<uint8>(), f[2].Get<uint8>(), f[3].Get<uint8>(), f[4].Get<uint8>());
|
||||||
}
|
}
|
||||||
|
|
||||||
sPlayerbotAIConfig->randomBotGuilds.push_back(guild->GetId());
|
sPlayerbotAIConfig->randomBotGuilds.push_back(guild->GetId());
|
||||||
// The guild is only counted if it is actually created
|
// The guild is only counted if it is actually created
|
||||||
|
|||||||
@@ -21,122 +21,125 @@
|
|||||||
|
|
||||||
namespace ai::buff
|
namespace ai::buff
|
||||||
{
|
{
|
||||||
std::string MakeAuraQualifierForBuff(std::string const& name)
|
std::string MakeAuraQualifierForBuff(std::string const& name)
|
||||||
{
|
{
|
||||||
// Paladin
|
// Paladin
|
||||||
if (name == "blessing of kings") return "blessing of kings,greater blessing of kings";
|
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 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 wisdom") return "blessing of wisdom,greater blessing of wisdom";
|
||||||
if (name == "blessing of sanctuary") return "blessing of sanctuary,greater blessing of sanctuary";
|
if (name == "blessing of sanctuary") return "blessing of sanctuary,greater blessing of sanctuary";
|
||||||
// Druid
|
// Druid
|
||||||
if (name == "mark of the wild") return "mark of the wild,gift of the wild";
|
if (name == "mark of the wild") return "mark of the wild,gift of the wild";
|
||||||
// Mage
|
// Mage
|
||||||
if (name == "arcane intellect") return "arcane intellect,arcane brilliance";
|
if (name == "arcane intellect") return "arcane intellect,arcane brilliance";
|
||||||
// Priest
|
// Priest
|
||||||
if (name == "power word: fortitude") return "power word: fortitude,prayer of fortitude";
|
if (name == "power word: fortitude") return "power word: fortitude,prayer of fortitude";
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GroupVariantFor(std::string const& name)
|
return 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 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)
|
return std::string();
|
||||||
{
|
}
|
||||||
if (!spellId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId))
|
bool HasRequiredReagents(Player* bot, uint32 spellId)
|
||||||
{ for (int i = 0; i < MAX_SPELL_REAGENTS; ++i)
|
{
|
||||||
{
|
if (!spellId)
|
||||||
if (info->Reagent[i] > 0)
|
return false;
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string UpgradeToGroupIfAppropriate(
|
if (SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId))
|
||||||
Player* bot,
|
{
|
||||||
PlayerbotAI* botAI,
|
for (int i = 0; i < MAX_SPELL_REAGENTS; ++i)
|
||||||
std::string const& baseName,
|
{
|
||||||
bool announceOnMissing,
|
if (info->Reagent[i] > 0)
|
||||||
std::function<void(std::string const&)> announce)
|
{
|
||||||
{
|
uint32 const itemId = info->Reagent[i];
|
||||||
std::string castName = baseName; Group* g = bot->GetGroup();
|
int32 const need = info->ReagentCount[i];
|
||||||
if (!g || g->GetMembersCount() < static_cast<uint32>(sPlayerbotAIConfig->minBotsForGreaterBuff))
|
if ((int32)bot->GetItemCount(itemId, false) < need)
|
||||||
return castName; // Group too small: stay in solo mode
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No reagent required
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (std::string const groupName = GroupVariantFor(baseName); !groupName.empty())
|
std::string UpgradeToGroupIfAppropriate(
|
||||||
{
|
Player* bot,
|
||||||
uint32 const groupVariantSpellId = botAI->GetAiObjectContext()
|
PlayerbotAI* botAI,
|
||||||
->GetValue<uint32>("spell id", groupName)->Get();
|
std::string const& baseName,
|
||||||
|
bool announceOnMissing,
|
||||||
|
std::function<void(std::string const&)> announce)
|
||||||
|
{
|
||||||
|
std::string castName = baseName;
|
||||||
|
Group* g = bot->GetGroup();
|
||||||
|
if (!g || g->GetMembersCount() < static_cast<uint32>(sPlayerbotAIConfig->minBotsForGreaterBuff))
|
||||||
|
return castName; // Group too small: stay in solo mode
|
||||||
|
|
||||||
// We check usefulness on the **basic** buff (not the greater version),
|
if (std::string const groupName = GroupVariantFor(baseName); !groupName.empty())
|
||||||
// because "spell cast useful" may return false for the greater variant.
|
{
|
||||||
bool const usefulBase = botAI->GetAiObjectContext()
|
uint32 const groupVariantSpellId = botAI->GetAiObjectContext()
|
||||||
->GetValue<bool>("spell cast useful", baseName)->Get();
|
->GetValue<uint32>("spell id", groupName)->Get();
|
||||||
|
|
||||||
if (groupVariantSpellId && HasRequiredReagents(bot, groupVariantSpellId))
|
// We check usefulness on the **basic** buff (not the greater version),
|
||||||
{
|
// because "spell cast useful" may return false for the greater variant.
|
||||||
// Learned + reagents OK -> switch to greater
|
bool const usefulBase = botAI->GetAiObjectContext()
|
||||||
return groupName;
|
->GetValue<bool>("spell cast useful", baseName)->Get();
|
||||||
}
|
|
||||||
|
|
||||||
// Missing reagents -> announce if (a) greater is known, (b) base buff is useful,
|
if (groupVariantSpellId && HasRequiredReagents(bot, groupVariantSpellId))
|
||||||
// (c) announce was requested, (d) a callback is provided.
|
{
|
||||||
if (announceOnMissing && groupVariantSpellId && usefulBase && announce)
|
// Learned + reagents OK -> switch to greater
|
||||||
{
|
return groupName;
|
||||||
static std::map<std::pair<uint32, std::string>, time_t> s_lastWarn; // par bot & par buff
|
}
|
||||||
time_t now = std::time(nullptr);
|
|
||||||
uint32 botLow = static_cast<uint32>(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";
|
|
||||||
|
|
||||||
// Placeholders
|
// Missing reagents -> announce if (a) greater is known, (b) base buff is useful,
|
||||||
std::map<std::string, std::string> placeholders;
|
// (c) announce was requested, (d) a callback is provided.
|
||||||
placeholders["%group_spell"] = groupName;
|
if (announceOnMissing && groupVariantSpellId && usefulBase && announce)
|
||||||
placeholders["%base_spell"] = baseName;
|
{
|
||||||
|
static std::map<std::pair<uint32, std::string>, time_t> s_lastWarn; // par bot & par buff
|
||||||
|
time_t now = std::time(nullptr);
|
||||||
|
uint32 botLow = static_cast<uint32>(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,
|
// Placeholders
|
||||||
"Out of components for %group_spell. Using %base_spell!", placeholders);
|
std::map<std::string, std::string> placeholders;
|
||||||
|
placeholders["%group_spell"] = groupName;
|
||||||
|
placeholders["%base_spell"] = baseName;
|
||||||
|
|
||||||
announce(announceText);
|
std::string announceText = sPlayerbotTextMgr->GetBotTextOrDefault(key,
|
||||||
last = now;
|
"Out of components for %group_spell. Using %base_spell!", placeholders);
|
||||||
}
|
|
||||||
}
|
announce(announceText);
|
||||||
}
|
last = now;
|
||||||
return castName;
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return castName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user