From 8c840261161b791a757bc8bcaa4d5a2d13879719 Mon Sep 17 00:00:00 2001 From: kadeshar Date: Thu, 5 Dec 2024 19:29:52 +0100 Subject: [PATCH] - added spec configuration for world buffs (#761) - added world buffs to configuration file - fixed NeedWorldBuffTrigger --- conf/playerbots.conf.dist | 50 ++++++++++++++++++++++++ src/PlayerbotAIConfig.cpp | 43 ++++++++++++++------ src/PlayerbotAIConfig.h | 3 +- src/strategy/actions/WorldBuffAction.cpp | 6 +++ src/strategy/triggers/CureTriggers.cpp | 6 ++- 5 files changed, 93 insertions(+), 15 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index c0cada68..182a8cec 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -1022,6 +1022,56 @@ AiPlayerbot.PremadeSpecLink.11.3.80 = -553202032322010053100030310511-205503012 # ################################################################################################### +################################### +# # +# WORLD BUFFS # +# # +################################### + +#################################################################################################### +# +# +# + +# Applies a permanent buff to all bots when not in combat simulating flasks, food, rune etc. +# WorldBuff.Faction.Class.Spec.MinLevel.MaxLevel + +AiPlayerbot.WorldBuff.0.1.0.80.80 = 53760,57358 #WARRIOR ARMS +AiPlayerbot.WorldBuff.0.1.1.80.80 = 53760,57358 #WARRIOR FURY +AiPlayerbot.WorldBuff.0.1.2.80.80 = 53758,57356 #WARRIOR PROTECTION +AiPlayerbot.WorldBuff.0.2.0.80.80 = 60347,53749,57332 #PALADIN HOLY +AiPlayerbot.WorldBuff.0.2.1.80.80 = 53758,57356 #PALADIN PROTECTION +AiPlayerbot.WorldBuff.0.2.2.80.80 = 53760,57371 #PALADIN RETRIBUTION +AiPlayerbot.WorldBuff.0.3.0.80.80 = 53760,57325 #HUNTER BEAST +AiPlayerbot.WorldBuff.0.3.1.80.80 = 53760,57358 #HUNTER MARKSMANSHIP +AiPlayerbot.WorldBuff.0.3.2.80.80 = 53760,57367 #HUNTER SURVIVAL +AiPlayerbot.WorldBuff.0.4.0.80.80 = 53760,57325 #ROGUE ASSASINATION +AiPlayerbot.WorldBuff.0.4.1.80.80 = 53760,57358 #ROGUE COMBAT +AiPlayerbot.WorldBuff.0.4.2.80.80 = 53760,57367 #ROGUE SUBTLETY +AiPlayerbot.WorldBuff.0.5.0.80.80 = 53755,57327 #PRIEST DISCIPLINE +AiPlayerbot.WorldBuff.0.5.1.80.80 = 53755,57327 #PRIEST HOLY +AiPlayerbot.WorldBuff.0.5.2.80.80 = 53755,57327 #PRIEST SHADOW +AiPlayerbot.WorldBuff.0.6.0.80.80 = 53758,57356 #DEATH KNIGHT BLOOD +AiPlayerbot.WorldBuff.0.6.1.80.80 = 53760,57358 #DEATH KNIGHT FROST +AiPlayerbot.WorldBuff.0.6.2.80.80 = 53760,57358 #DEATH KNIGHT UNHOLY +AiPlayerbot.WorldBuff.0.7.0.80.80 = 53755,57327 #SHAMAN ELEMENTAL +AiPlayerbot.WorldBuff.0.7.1.80.80 = 53760,57325 #SHAMAN ENHANCEMENT +AiPlayerbot.WorldBuff.0.7.2.80.80 = 53755,57327 #SHAMAN RESTORATION +AiPlayerbot.WorldBuff.0.8.0.80.80 = 53755,57327 #MAGE ARCANE +AiPlayerbot.WorldBuff.0.8.1.80.80 = 53755,57327 #MAGE FIRE +AiPlayerbot.WorldBuff.0.8.2.80.80 = 53755,57327 #MAGE FROST +AiPlayerbot.WorldBuff.0.9.0.80.80 = 53755,57327 #WARLOCK AFFLICTION +AiPlayerbot.WorldBuff.0.9.1.80.80 = 53755,57327 #WARLOCK DEMONOLOGY +AiPlayerbot.WorldBuff.0.9.2.80.80 = 53755,57327 #WARLOCK DESTRUCTION +AiPlayerbot.WorldBuff.0.11.0.80.80 = 53755,57327 #DRUID BALANCE +AiPlayerbot.WorldBuff.0.11.1.80.80 = 53749,53763,57367 #DRUID FERAL +AiPlayerbot.WorldBuff.0.11.2.80.80 = 54212,57334 #DRUID RESTORATION + +# +# +# +################################################################################################### + ################################### # # # RANDOM BOT DEFAULT TALENT SPEC # diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 53a7b720..0688c6b2 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -403,11 +403,14 @@ bool PlayerbotAIConfig::Initialize() { for (uint32 classId = 0; classId < MAX_CLASSES; classId++) { - for (uint32 minLevel = 0; minLevel < MAX_LEVEL; minLevel++) + for (uint32 specId = 0; specId < MAX_SPECNO; specId++) { - for (uint32 maxLevel = 0; maxLevel < MAX_LEVEL; maxLevel++) + for (uint32 minLevel = 0; minLevel < MAX_LEVEL; minLevel++) { - loadWorldBuf(factionId, classId, minLevel, maxLevel); + for (uint32 maxLevel = 0; maxLevel < MAX_LEVEL; maxLevel++) + { + loadWorldBuf(factionId, classId, specId, minLevel, maxLevel); + } } } } @@ -644,36 +647,50 @@ void PlayerbotAIConfig::log(std::string const fileName, char const* str, ...) fflush(stdout); } -void PlayerbotAIConfig::loadWorldBuf(uint32 factionId1, uint32 classId1, uint32 minLevel1, uint32 maxLevel1) +void PlayerbotAIConfig::loadWorldBuf(uint32 factionId1, uint32 classId1, uint32 specId1, uint32 minLevel1, uint32 maxLevel1) { std::vector buffs; std::ostringstream os; - os << "AiPlayerbot.WorldBuff." << factionId1 << "." << classId1 << "." << minLevel1 << "." << maxLevel1; + os << "AiPlayerbot.WorldBuff." << factionId1 << "." << classId1 << "." << specId1 << "." << minLevel1 << "." << maxLevel1; LoadList>(sConfigMgr->GetOption(os.str().c_str(), "", false), buffs); for (auto buff : buffs) { - worldBuff wb = {buff, factionId1, classId1, minLevel1, maxLevel1}; + worldBuff wb = {buff, factionId1, classId1, specId1, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } if (maxLevel1 == 0) { std::ostringstream os; - os << "AiPlayerbot.WorldBuff." << factionId1 << "." << classId1 << "." << minLevel1; + os << "AiPlayerbot.WorldBuff." << factionId1 << "." << classId1 << "." << specId1 << "." << minLevel1; LoadList>(sConfigMgr->GetOption(os.str().c_str(), "", false), buffs); for (auto buff : buffs) { - worldBuff wb = {buff, factionId1, classId1, minLevel1, maxLevel1}; + worldBuff wb = {buff, factionId1, classId1, specId1, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } } if (maxLevel1 == 0 && minLevel1 == 0) + { + std::ostringstream os; + os << "AiPlayerbot.WorldBuff." << factionId1 << "." << factionId1 << "." << classId1 << "." << specId1; + + LoadList>(sConfigMgr->GetOption(os.str().c_str(), "", false), buffs); + + for (auto buff : buffs) + { + worldBuff wb = {buff, factionId1, classId1, specId1, minLevel1, maxLevel1}; + worldBuffs.push_back(wb); + } + } + + if (maxLevel1 == 0 && minLevel1 == 0 && specId1 == 0) { std::ostringstream os; os << "AiPlayerbot.WorldBuff." << factionId1 << "." << factionId1 << "." << classId1; @@ -682,12 +699,12 @@ void PlayerbotAIConfig::loadWorldBuf(uint32 factionId1, uint32 classId1, uint32 for (auto buff : buffs) { - worldBuff wb = {buff, factionId1, classId1, minLevel1, maxLevel1}; + worldBuff wb = {buff, factionId1, classId1, specId1, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } } - if (classId1 == 0 && maxLevel1 == 0 && minLevel1 == 0) + if (classId1 == 0 && maxLevel1 == 0 && minLevel1 == 0 && specId1 == 0) { std::ostringstream os; os << "AiPlayerbot.WorldBuff." << factionId1; @@ -696,12 +713,12 @@ void PlayerbotAIConfig::loadWorldBuf(uint32 factionId1, uint32 classId1, uint32 for (auto buff : buffs) { - worldBuff wb = {buff, factionId1, classId1, minLevel1, maxLevel1}; + worldBuff wb = {buff, factionId1, classId1, specId1, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } } - if (factionId1 == 0 && classId1 == 0 && maxLevel1 == 0 && minLevel1 == 0) + if (factionId1 == 0 && classId1 == 0 && maxLevel1 == 0 && minLevel1 == 0 && specId1 == 0) { std::ostringstream os; os << "AiPlayerbot.WorldBuff"; @@ -710,7 +727,7 @@ void PlayerbotAIConfig::loadWorldBuf(uint32 factionId1, uint32 classId1, uint32 for (auto buff : buffs) { - worldBuff wb = {buff, factionId1, classId1, minLevel1, maxLevel1}; + worldBuff wb = {buff, factionId1, classId1, specId1, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } } diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index 0f34b41e..b2687fe8 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -247,6 +247,7 @@ public: uint32 spellId; uint32 factionId = 0; uint32 classId = 0; + uint32 specId = 0; uint32 minLevel = 0; uint32 maxLevel = 0; }; @@ -327,7 +328,7 @@ public: } void log(std::string const fileName, const char* str, ...); - void loadWorldBuf(uint32 factionId, uint32 classId, uint32 minLevel, uint32 maxLevel); + void loadWorldBuf(uint32 factionId, uint32 classId, uint32 specId, uint32 minLevel, uint32 maxLevel); static std::vector> ParseTempTalentsOrder(uint32 cls, std::string temp_talents_order); static std::vector> ParseTempPetTalentsOrder(uint32 spec, std::string temp_talents_order); }; diff --git a/src/strategy/actions/WorldBuffAction.cpp b/src/strategy/actions/WorldBuffAction.cpp index 577731bc..a21dfc56 100644 --- a/src/strategy/actions/WorldBuffAction.cpp +++ b/src/strategy/actions/WorldBuffAction.cpp @@ -5,6 +5,7 @@ #include "WorldBuffAction.h" +#include "AiFactory.h" #include "Event.h" #include "Playerbots.h" @@ -39,6 +40,11 @@ std::vector WorldBuffAction::NeedWorldBuffs(Unit* unit) if (wb.classId != 0 && wb.classId != unit->getClass()) continue; + uint8 tab = AiFactory::GetPlayerSpecTab(unit->ToPlayer()); + + if (wb.specId != tab) + continue; + if (wb.minLevel != 0 && wb.minLevel > unit->GetLevel()) continue; diff --git a/src/strategy/triggers/CureTriggers.cpp b/src/strategy/triggers/CureTriggers.cpp index abd23022..60aa29f6 100644 --- a/src/strategy/triggers/CureTriggers.cpp +++ b/src/strategy/triggers/CureTriggers.cpp @@ -25,4 +25,8 @@ bool PartyMemberNeedCureTrigger::IsActive() return target && target->IsInWorld(); } -bool NeedWorldBuffTrigger::IsActive() { return !WorldBuffAction::NeedWorldBuffs(bot).empty(); } +bool NeedWorldBuffTrigger::IsActive() +{ + std::any_of(WorldBuffAction::NeedWorldBuffs(bot).begin(), WorldBuffAction::NeedWorldBuffs(bot).end(), + [](const auto& wb) { return true; }); +}